use semantic.card for document { title, overview, metadata }

This commit is contained in:
Fred Pauchet 2018-03-12 13:34:44 +01:00
parent 448d058fa7
commit aa7e400b6f
3 changed files with 45 additions and 13 deletions

View File

@ -18,6 +18,7 @@
<link rel="stylesheet" type="text/css" href="{% static 'semantic/components/segment.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'semantic/components/dropdown.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'semantic/components/icon.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'semantic/components/card.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'semantic/components/progress.css' %}">
{% block stylesheet %}{% endblock %}
@ -50,13 +51,16 @@
<a class="item" href="/docs">Documents</a>
<a class="item" href="/docs">Tâches</a>
{% block "navigation" %} {% endblock %}
</div>
</div>
<div class="ui main text container">
<h1 class="ui header">{% block "title" %}{% endblock %}</h1>
{% block "content" %}{% endblock %}
<div class="ui two column stackable grid">
<div class="three wide column">
{% block "content_navigation" %}{% endblock %}
</div>
<div class="ten wide colum">
{% block "content" %}{% endblock %}
</div>
</div>

View File

@ -9,13 +9,29 @@
</ul>
{% endblock "navigation" %}
{% block "content" %}
{% block "title" %}
{{ document.title }}
{% endblock "title" %}
<h2>{{ document.title }}</h2>
<p>Document Type: {{ document.type }} - Created at {{ document.created_at }}</p>
<p>Overview: {{ document.overview }}</p>
{% block "content_navigation" %}
<div class="segment">
<div class="ui card">
<div class="content">
<a class="header">{{ document.title }}</a>
{% if document.last_published_version %}
<div class="meta">
<span class="date">{{ document.created_at }}</span>
</div>
<div class="description">
{{ document.overview }}
</div>
</div>
<div class="extra content">
Type : {{ document.type }}
</div>
</div>
{% if document.last_published_version %}
<h3>Last published version: {{ document.last_published_version }}</h3>
<ul>
<li>Authors: {% for author in document.last_published_version.authors.all %}{{ author }}{% endfor %}</li>
@ -53,8 +69,16 @@
<h4>Rédaction</h4>
<ul>
<li><a href="{% url 'document_sections' document.pk %}">Rédaction inline</a></li>
<li><a href="#">Visualiser le document (HTML)</a></li>
<li><a href="#">Convertir en PDF et créer une nouvelle version</a></li>
</ul>
{% endblock "content" %}
</div>
{% endblock %}
{% block "content" %}
<div class="segment">
{% for section in document.sections.all %}
<h1>{{ section }}</h1>
{{ section.get_message_as_markdown | safe }}
{% endfor %}
</div>
{% endblock "content" %}

View File

@ -1,17 +1,21 @@
from django.db import models
from markdown import Markdown
from django.utils.html import mark_safe
from markdown import Markdown, markdown
import pdfkit
from dms.models import Document
class Section(models.Model):
document = models.ForeignKey(Document)
document = models.ForeignKey(Document, related_name='sections')
order = models.IntegerField()
title = models.CharField(max_length=255)
content = models.TextField()
def get_message_as_markdown(self):
return mark_safe(markdown(self.content, safe_mode='escape'))
class Meta:
unique_together = ('document', 'order')
ordering = ('document', 'order')