evolve ux

This commit is contained in:
Fred Pauchet 2018-02-23 21:39:35 +01:00
parent 07d570afb9
commit 43ed342bcd
22 changed files with 182 additions and 66 deletions

Binary file not shown.

View File

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2018-02-23 20:03
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('jci', '0025_auto_20171024_1102'),
('dms', '0003_auto_20171117_0823'),
]
operations = [
migrations.AddField(
model_name='document',
name='jci_standard',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='documents', to='jci.Standard'),
preserve_default=False,
),
]

View File

@ -77,6 +77,7 @@ class Document(models.Model):
type = models.ForeignKey(DocumentType)
created_at = models.DateTimeField(auto_now_add=True)
manager = models.ForeignKey(User)
jci_standard = models.ForeignKey('jci.Standard', related_name='documents')
@property
def last_published_version(self):

View File

@ -1,11 +1,14 @@
from django.conf.urls import url
from dms.views import document_details, filter_documents, node_documents, site_documents
from dms.views import document_details, filter_documents, node_documents, site_documents, home, standard_documents, keyword_documents
urlpatterns = [
url(r'std/(?P<pk>\d+)', standard_documents, name='standard_documents'),
url(r'kw/(?P<pk>\d+)', keyword_documents, name='kw_documents'),
url(r'd/(?P<pk>\d+)', document_details, name='document_details'),
url(r'node/(?P<pk>\d+)', node_documents, name='node_documents'),
url(r'site/(?P<pk>\d+)', site_documents, name='site_documents'),
url(r'filter', filter_documents, name='filter_documents'),
url(r'', home, name='docs_home'),
]

View File

@ -3,6 +3,10 @@ from .models import Document, Version, Node, Site
from .filters import VersionFilter
def home(request):
return render(request, 'dms/home.html', {})
def documents_list(request):
docs = Document.objects.all()
return render(request, 'dms/documents_list.html', {'documents': docs})
@ -28,3 +32,13 @@ def site_documents(request, pk):
site = Site.objects.get(pk=pk)
documents = Version.objects.filter(sites=pk).all()
return render(request, 'dms/site_details.html', {'site': site, 'documents': documents})
def standard_documents(request, pk):
docs = Document.objects.filter(jci_standard=pk)
return render(request, 'dms/documents_list.html', {'documents': docs})
def keyword_documents(request, pk):
docs = Document.objects.filter(versions__keywords__pk=pk)
return render(request, 'dms/documents_list.html', {'documents': docs})

View File

@ -3,6 +3,10 @@ from django.shortcuts import render
from jci.models import Intent, Section, Standard
def home(request):
return render(request, 'jci/home.html', {})
def jci_list(request):
sections = Section.objects.prefetch_related('headlines').prefetch_related('headlines__standards')
return render(request, 'jci/list.html', {'sections': sections})
@ -12,6 +16,7 @@ def get_intent(request, intent_id):
intent = Intent.objects.prefetch_related('standards').get(pk=intent_id)
return render(request, 'jci/intent/details.html', {'intent': intent})
def get_standard(request, standard_id):
standard = Standard.objects.select_related('intent').select_related('headline').get(pk=standard_id)
return render(request, 'jci/standard/details.html', {'standard': standard})

View File

View File

@ -1,4 +1,4 @@
{% load static %}{% load structure %}<!DOCTYPE html>
{% load static %}<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
@ -9,15 +9,42 @@
{% block stylesheet %}{% endblock %}
</head>
<body>
{% display_nodes %}
{% block body %}
<!-- code suppressed for brevity -->
{% endblock body %}
{% block "navigation" %}{% endblock %}
{% block "content" %}{% endblock %}
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">DMS</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="/jci">Dashboard</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="/docs">Documents</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Processus</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Rédaction</a>
</li>
{% block "navigation" %}{% endblock %}
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Recherche" aria-label="Recherche">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Recherche</button>
</form>
</div>
</nav>
{% block "content" %}{% endblock %}
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
{% block javascript %}{% endblock %} <!-- Add this empty block here! -->
</body>
</html>

11
templates/dms/base.html Normal file
View File

@ -0,0 +1,11 @@
{% load structure %}
{% extends "../base.html" %}
{% block "navigation" %}
blabla
{% display_nodes %}
{% endblock %}
{% block "content" %}
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "../base.html" %}
{% extends "base.html" %}
{% block "navigation" %}
<ul>
@ -18,7 +18,7 @@
<h3>Last published version: {{ document.last_published_version }}</h3>
<ul>
<li>Authors: {% for author in document.last_published_version.authors.all %}{{ author }}{% endfor %}</li>
<li>Keywords: {% for keyword in document.last_published_version.keywords.all %}{{ keyword }}{% endfor %}</li>
<li>Keywords: {% for keyword in document.last_published_version.keywords.all %}<a href="{% url 'kw_documents' keyword.pk %}">{{keyword}}</a>{% endfor %}</li>
<li>Audiences: {% for audience in document.last_published_version.audiences.all %}{{ audience }}{% endfor %}</li>
<li>Nodes: {% for node in document.last_published_version.nodes.all %}<a href="{% url 'node_documents' node.pk %}">{{ node }}</a>{% endfor %}</li>
<li>Sites: {% for site in document.last_published_version.sites.all %}<a href="{% url 'site_documents' site.pk %}">{{ site }}</a>{% endfor %}</li>
@ -30,7 +30,7 @@
<h4>Properties</h4>
<ul>
<li>Authors: {% for author in document.last_working_version.authors.all %}{{ author }}{% endfor %}</li>
<li>Keywords: {% for keyword in document.last_working_version.keywords.all %}{{ keyword }}{% endfor %}</li>
<li>Keywords: {% for keyword in document.last_working_version.keywords.all %}<a href="{% url 'kw_documents' keyword.pk %}">{{keyword}}</a>{% endfor %}</li>
<li>Audiences: {% for audience in document.last_working_version.audiences.all %}{{ audience }}{% endfor %}</li>
<li>Nodes: {% for node in document.last_working_version.nodes.all %}<a href="{% url 'node_documents' node.pk %}">{{ node }}</a>{% endfor %}</li>
<li>Sites: {% for site in document.last_working_version.sites.all %}<a href="{% url 'site_documents' site.pk %}">{{ site }}</a>{% endfor %}</li>

View File

@ -0,0 +1,11 @@
{% extends "base.html" %}
{% block "content" %}
<ul>
{% for doc in documents %}
<li><a href="{% url 'document_details' doc.pk %}">{{doc}}</a>
{% for keyword in doc.last_working_version.keywords.all %}<a href="{% url 'kw_documents' keyword.pk %}">{{keyword}}</a>{% endfor %}
</li>
{% endfor %}
</ul>
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "../base.html" %}
{% extends "base.html" %}
{% block "navigation" %}
<form action="" method="get">
@ -6,6 +6,7 @@
<input type="submit" />
</form>
{% endblock %}
{% block "content" %}
<ul>
{% for obj in filter.qs %}

5
templates/dms/home.html Normal file
View File

@ -0,0 +1,5 @@
{% extends "base.html" %}
{% block "content" %}
<h2>Derniers documents publiés</h2>
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "../base.html" %}
{% extends "base.html" %}
{% block "navigation" %}
<form action="" method="get">

View File

@ -1,4 +1,4 @@
{% extends "../base.html" %}
{% extends "base.html" %}
{% block "content" %}

View File

@ -1,3 +1,9 @@
<html>
{% block "content"%} {% endblock %}
</html>
{% extends "../base.html" %}
{% block "navigation" %}
{% endblock %}
{% block "content" %}
{% endblock %}

View File

@ -1,25 +1,23 @@
{% load jci_extras %}
{% if sections %}
<ul>
{% for section in sections %}
<li>{{section}}
{% if section.headlines.all %}
<ul>
{% for headline in section.headlines.all %}
<li>{{headline}}
{% if headline.standards.all %}
<ul>
{% for std in headline.standards.all %}
<li>{{std}} - {{std.name}} {% count_documents std %} </li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
</ul>
<h2>{{section}}</h2>
{% if section.headlines.all %}
{% for headline in section.headlines.all %}
<h2>{{ headline }}</h2>
{% if headline.standards.all %}
<table>
{% for std in headline.standards.all %}
<tr>
<td>{{std}}</td>
<td>{{std.name}}</td>
<td><a href="{% url 'standard_documents' std.pk %}">{% count_documents std %}</a></td>
</tr>
{% endfor %}
{% endif %}
</li>
</table>
{% endfor %}
{% endif %}
{% endfor %}
</ul>
{% endif %}

View File

@ -1,31 +1,10 @@
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">DMS</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Menu</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
{% for node in nodes %}
<a class="dropdown-item" href="{% url 'node_documents' node.id %}">{{ node }}</a>
{% endfor %}
</div>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Recherche" aria-label="Recherche">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Recherche</button>
</form>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
{% for node in nodes %}
<a class="dropdown-item" href="{% url 'node_documents' node.id %}">{{ node }}</a>
{% endfor %}
</div>
</nav>
</li>

View File

@ -0,0 +1,9 @@
{% extends "../base.html" %}
{% block "navigation" %}
{% endblock %}
{% block "content" %}
{% endblock %}

View File

@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2018-02-23 20:03
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('writer', '0002_section_title'),
]
operations = [
migrations.AlterModelOptions(
name='section',
options={'ordering': ('document', 'order')},
),
]

View File

@ -21,7 +21,7 @@ class Section(models.Model):
def to_pdf():
x = '[TOC]\n'
x = '# Tables des matières \n [TOC]\n'
for section in Section.objects.all():
x += '# ' + section.title

View File

@ -2,6 +2,10 @@ from django.shortcuts import render
from .models import Section
def home(request):
return render(request, 'writer/home.html', {})
def list_sections(request, document_id):
sections = Section.objects.filter(document=document_id)