diff --git a/dms/models.py b/dms/models.py index a7ac7cf..3ddc5a4 100644 --- a/dms/models.py +++ b/dms/models.py @@ -145,14 +145,15 @@ class Document(models.Model): super().save() def to_pdf(self): - x = '# Tables des matières \n [TOC]\n' + x = "" + x += '# Tables des matières \n [TOC]\n' for section in self.sections.all(): x += '# ' + section.title x += '\n' x += section.content x += '\n' - md = Markdown(extensions=['markdown.extensions.toc']) + md = Markdown(extensions=['markdown.extensions.toc', 'markdown.extensions.tables']) html = md.convert(x) options = { diff --git a/dms/views.py b/dms/views.py index af4bc22..0827e82 100644 --- a/dms/views.py +++ b/dms/views.py @@ -5,8 +5,14 @@ from .filters import VersionFilter def home(request): - latest_versions = Version.objects.filter(is_published=True) - return render(request, 'dms/home.html', {'latest_versions': latest_versions}) + query = request.GET.get('q', None) + + if query: + documents = Document.objects.filter(title__icontains=query) + else: + documents = Document.objects.filter(versions__is_published=True) + + return render(request, 'dms/home.html', {'documents': documents}) def documents_list(request): diff --git a/templates/dms/document_details.html b/templates/dms/document_details.html index 4efa9a9..11f573b 100644 --- a/templates/dms/document_details.html +++ b/templates/dms/document_details.html @@ -56,6 +56,57 @@ {% endfor %} +{% if document.last_published_version %} +
+
+
Dernière version publiée
+
+ {{ document.last_published_version }} +
+
+ Authors: {% for author in document.last_published_version.authors.all %}{{ author }}{% endfor %} +
+
+ Keywords: {% for keyword in document.last_published_version.keywords.all %}{{keyword}}{% endfor %} +
+
+ Audiences: {% for audience in document.last_published_version.audiences.all %}{{ audience }}{% endfor %} +
+
+ Nodes: {% for node in document.last_published_version.nodes.all %}{{ node }}{% endfor %} +
+
+ Sites: {% for site in document.last_published_version.sites.all %}{{ site }}{% endfor %} +
+
+
+ {% endif %} + + {% if document.last_working_version %} +
+
+
Dernier draft
+
+ {{ document.last_working_version }} +
+
+ Authors: {% for author in document.last_working_version.authors.all %}{{ author }}{% endfor %} +
+
+ Keywords: {% for keyword in document.last_working_version.keywords.all %}{{keyword}}{% endfor %} +
+
+ Audiences: {% for audience in document.last_working_version.audiences.all %}{{ audience }}{% endfor %} +
+
+ Nodes: {% for node in document.last_working_version.nodes.all %}{{ node }}{% endfor %} +
+
+ Sites: {% for site in document.last_working_version.sites.all %}{{ site }}{% endfor %} +
+
+
+ {% endif %} {% endblock %} diff --git a/templates/dms/home.html b/templates/dms/home.html index 340add5..19084ea 100644 --- a/templates/dms/home.html +++ b/templates/dms/home.html @@ -1,8 +1,21 @@ {% extends "./base.html" %} {% block "content" %} -

Derniers documents publiés

- {% for version in latest_versions %} - {{ version }} - {% endfor %} + + + {% regroup documents by type as documents_types %} + {% if documents_types %} + + {% endif %} + {% endblock %} \ No newline at end of file diff --git a/templates/templatetags/nodes.html b/templates/templatetags/nodes.html index 50e0e58..6fcda47 100644 --- a/templates/templatetags/nodes.html +++ b/templates/templatetags/nodes.html @@ -1,5 +1,5 @@