diff --git a/mural/migrations/0006_auto_20170209_1434.py b/mural/migrations/0006_auto_20170209_1434.py new file mode 100644 index 0000000..874b3a2 --- /dev/null +++ b/mural/migrations/0006_auto_20170209_1434.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.4 on 2017-02-09 17:34 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('mural', '0005_mural_edited'), + ] + + operations = [ + migrations.AlterField( + model_name='comment', + name='post', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='comment_post', to='mural.Mural', verbose_name='Post'), + ), + ] diff --git a/pdf_file/forms.py b/pdf_file/forms.py index 5c5f071..e71e029 100644 --- a/pdf_file/forms.py +++ b/pdf_file/forms.py @@ -24,7 +24,7 @@ class PDFFileForm(forms.ModelForm): tags = forms.CharField(label = _('Tags'), required = False) class Meta: model = PDFFile - fields = ['name', 'file', 'brief_description', 'all_students', 'students', 'groups', 'visible'] + fields = ['name', 'file', 'brief_description','show_window', 'all_students', 'students', 'groups', 'visible'] labels = { 'name': _('File name'), } diff --git a/pdf_file/migrations/0002_auto_20170209_1434.py b/pdf_file/migrations/0002_auto_20170209_1434.py new file mode 100644 index 0000000..10bc994 --- /dev/null +++ b/pdf_file/migrations/0002_auto_20170209_1434.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.4 on 2017-02-09 17:34 +from __future__ import unicode_literals + +from django.db import migrations, models +import pdf_file.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pdf_file', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='pdffile', + name='file', + field=models.FileField(upload_to='files/', validators=[pdf_file.models.validate_file_extension], verbose_name='File'), + ), + ] diff --git a/pdf_file/models.py b/pdf_file/models.py index 1768fa9..158550a 100644 --- a/pdf_file/models.py +++ b/pdf_file/models.py @@ -16,6 +16,7 @@ def validate_file_extension(value): class PDFFile(Resource): file = models.FileField(_('File'), upload_to='files/', validators = [validate_file_extension]) + class Meta: verbose_name = "PDFFile" verbose_name_plural = "PDFFiles" diff --git a/pdf_file/templates/pdf_file/_form.html b/pdf_file/templates/pdf_file/_form.html index 8e0b58c..7c0d050 100644 --- a/pdf_file/templates/pdf_file/_form.html +++ b/pdf_file/templates/pdf_file/_form.html @@ -87,6 +87,29 @@ {% endif %} +
+
+ +
+ + {{ form.show_window.help_text }} + + {% if form.show_window.errors %} + + {% endif %} +
+
{% render_field form.tags class='form-control' data-role="tagsinput" %} diff --git a/pdf_file/templates/pdf_file/view.html b/pdf_file/templates/pdf_file/view.html index 7fe0d05..d36746b 100644 --- a/pdf_file/templates/pdf_file/view.html +++ b/pdf_file/templates/pdf_file/view.html @@ -17,13 +17,16 @@ {% breadcrumb topic 'subjects:topic_view' topic.subject.slug topic.slug %} - {% trans 'Edit: ' as bread %} - {% with bread|add:pdf_file.name as bread_slug %} - {% breadcrumb bread_slug 'pdf_file:update' topic.slug pdf_file.slug %} - {% endwith %} + {% endblock %} {% block content %} - {{context\pdf_file}} + + +

Insert your error message here, if the PDF cannot be displayed.

+
+ + + {% endblock content %} \ No newline at end of file diff --git a/pdf_file/views.py b/pdf_file/views.py index 238417b..1690655 100644 --- a/pdf_file/views.py +++ b/pdf_file/views.py @@ -32,6 +32,12 @@ class ViewPDFFile(generic.TemplateView): return super(ViewPDFFile, self).dispatch(request, *args, **kwargs) + def get_context_data(self, **kwargs): + context = super(ViewPDFFile, self).get_context_data(**kwargs) + slug = self.kwargs.get('slug', '') + pdf_file = PDFFile.objects.get(slug=slug) + context['pdf_file'] = pdf_file + return context def render_to_response(self, context, **response_kwargs): @@ -40,10 +46,18 @@ class ViewPDFFile(generic.TemplateView): if not path.exists(pdf_file.file.path): raise Http404() - - response = HttpResponse(open(pdf_file.file.path, 'rb').read(),content_type = 'application/pdf') - - return response + if pdf_file.show_window: + response = HttpResponse(open(pdf_file.file.path, 'rb').read(),content_type = 'application/pdf') + return response + + + response_kwargs.setdefault('content_type', self.content_type) + return self.response_class( + request = self.request, + template = self.get_template_names(), + context = context, + **response_kwargs + ) class PDFFileCreateView(LoginRequiredMixin, LogMixin , generic.CreateView): form_class = PDFFileForm diff --git a/subjects/views.py b/subjects/views.py index d4505a4..16fa767 100644 --- a/subjects/views.py +++ b/subjects/views.py @@ -566,9 +566,9 @@ class SubjectSearchView(LoginRequiredMixin, LogMixin, ListView): q = q | Q(tags__name__unaccent__iexact=word ) subjects = Subject.objects.filter(q).distinct() + self.resources = Resource.objects.select_related('link', 'filelink', 'webpage', 'ytvideo', 'pdffile').filter(q ).distinct() + - self.resources = Resource.objects.select_related('link', 'filelink', 'webpage', 'ytvideo').filter(q).distinct() - self.totals = {'resources': self.resources.count(), 'my_subjects': subjects.count()} option = self.kwargs.get('option') diff --git a/themes/migrations/0005_auto_20170209_1434.py b/themes/migrations/0005_auto_20170209_1434.py new file mode 100644 index 0000000..90feb1b --- /dev/null +++ b/themes/migrations/0005_auto_20170209_1434.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.4 on 2017-02-09 17:34 +from __future__ import unicode_literals + +from django.db import migrations, models +import themes.models + + +class Migration(migrations.Migration): + + dependencies = [ + ('themes', '0004_themes_favicon'), + ] + + operations = [ + migrations.AlterField( + model_name='themes', + name='favicon', + field=models.ImageField(blank=True, null=True, upload_to='themes/', validators=[themes.models.validate_img_extension], verbose_name='Favicon'), + ), + migrations.AlterField( + model_name='themes', + name='large_logo', + field=models.ImageField(blank=True, null=True, upload_to='themes/', validators=[themes.models.validate_img_extension], verbose_name='Large Logo'), + ), + migrations.AlterField( + model_name='themes', + name='small_logo', + field=models.ImageField(blank=True, null=True, upload_to='themes/', validators=[themes.models.validate_img_extension], verbose_name='Small Logo'), + ), + ] -- libgit2 0.21.2