diff --git a/pdf_file/models.py b/pdf_file/models.py index 67ada69..0216785 100644 --- a/pdf_file/models.py +++ b/pdf_file/models.py @@ -1,5 +1,7 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ +import os +from django.core.exceptions import ValidationError from topics.models import Resource # Create your models here. @@ -13,7 +15,7 @@ def validate_file_extension(value): raise ValidationError(_('File not supported, use PDF format instead.')) class PDFFile(Resource): - file = models.FileField(_('File'), upload_to='/files', validators = [validate_file_extension]) + 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/create.html b/pdf_file/templates/pdf_file/create.html index 1ea1b7d..c5446da 100644 --- a/pdf_file/templates/pdf_file/create.html +++ b/pdf_file/templates/pdf_file/create.html @@ -17,8 +17,8 @@ {% breadcrumb topic 'subjects:topic_view' topic.subject.slug topic.slug %} - {% trans 'Create File Link' as bread %} - {% breadcrumb bread 'file_links:create' topic.slug %} + {% trans 'Create PDF file' as bread %} + {% breadcrumb bread 'pdf_file:create' topic.slug %} {% endblock %} {% block content %} diff --git a/pdf_file/templates/pdf_file/update.html b/pdf_file/templates/pdf_file/update.html new file mode 100644 index 0000000..59f6ab9 --- /dev/null +++ b/pdf_file/templates/pdf_file/update.html @@ -0,0 +1,36 @@ +{% extends 'subjects/view.html' %} + +{% load static i18n django_bootstrap_breadcrumbs %} + +{% block style %} + {{block.super}} + +{% endblock %} + +{% block javascript %} + {{block.super}} + +{% endblock %} + +{% block breadcrumbs %} + {{ block.super }} + + {% 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 %} +