add some views for the navigation between documents

This commit is contained in:
Fred Pauchet 2017-11-17 16:03:45 +01:00
parent 1f5667c323
commit bf20b1cc9c
21 changed files with 183 additions and 27 deletions

View File

@ -42,6 +42,7 @@ INSTALLED_APPS = [
'reversion',
'process',
'mptt',
'widget_tweaks',
]
MIDDLEWARE = [

View File

@ -1,7 +1,7 @@
from django import forms
import django_filters
from dms.models import Audience, Version, Site, Node
from dms.models import Audience, Version, Site
class VersionFilter(django_filters.FilterSet):
@ -13,11 +13,7 @@ class VersionFilter(django_filters.FilterSet):
queryset=Site.objects.all(),
widget=forms.CheckboxSelectMultiple
)
nodes = django_filters.ModelMultipleChoiceFilter(
queryset=Node.objects.all(),
widget=forms.CheckboxSelectMultiple
)
class Meta:
model = Version
fields = ('audiences', 'sites', 'nodes',)
fields = ('audiences', 'sites', )

View File

@ -0,0 +1,11 @@
from django import template
from ..models import Node
register = template.Library()
@register.inclusion_tag('templatetags/nodes.html')
def display_nodes():
nodes = Node.objects.all()
return {'nodes': nodes}

View File

@ -1,9 +1,11 @@
from django.conf.urls import url
from dms.views import document_details, filter_documents
from dms.views import document_details, filter_documents, node_documents, site_documents
urlpatterns = [
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'),
]

View File

@ -1,18 +1,30 @@
from django.shortcuts import render
from .models import Document, Version
from .models import Document, Version, Node, Site
from .filters import VersionFilter
def documents_list(request):
docs = Document.objects.all()
return render(request, 'evolus/documents_list.html', {'documents': docs})
return render(request, 'dms/documents_list.html', {'documents': docs})
def document_details(request, pk):
doc = Document.objects.get(pk=pk)
return render(request, 'evolus/document_details.html', {'document': doc})
return render(request, 'dms/document_details.html', {'document': doc})
def filter_documents(request):
f = VersionFilter(request.GET, queryset=Version.objects.select_related('document').all())
return render(request, 'evolus/filters.html', {'filter': f})
return render(request, 'dms/filters.html', {'filter': f})
def node_documents(request, pk):
f = VersionFilter(request.GET, queryset=Version.objects.select_related('document').filter(nodes=pk).all())
node = Node.objects.get(pk=pk)
return render(request, 'dms/node_filter.html', {'filter': f, 'node': node})
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})

View File

@ -1,8 +1,13 @@
from django.shortcuts import render
from .models import Process
from .models import Process, Task
def process_details(request, pk):
process = Process.objects.prefetch_related('tasks').select_related('document_version').get(pk=pk)
return render(request, 'process/process_details.html', {'process': process})
def user_tasks(request):
tasks = Task.objects.filter(user=request.user)
return render(request, 'process/user_tasks.html', {'tasks':tasks})

View File

@ -4,5 +4,6 @@ django-filter==1.0.4
django-simple-history==1.9.0
django-simple-history==1.9.0
django-mptt==0.8.7
django-widget-tweaks==1.4.1
pylint
markdown

16
static/css/accounts.css Normal file
View File

@ -0,0 +1,16 @@
body {
background-image: url(../img/shattered.png);
}
.logo {
font-family: 'Peralta', cursive;
}
.logo a {
color: rgba(0,0,0,.9);
}
.logo a:hover,
.logo a:active {
text-decoration: none;
}

BIN
static/img/shattered.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

4
static/js/jquery-3.2.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,18 +1,22 @@
{% load static %}
<!DOCTYPE html>
{% load static %}{% load structure %}<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Evolus</title>
<title>{% block title %}DMS{% endblock %}</title>
<link href="https://fonts.googleapis.com/css?family=Peralta" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}">
<link rel="stylesheet" href="{% static 'css/app.css' %}">
{% block stylesheet %}{% endblock %}
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-6 col-md-4">{% block "navigation" %}{% endblock %}</div>
<div class="col-12 col-md-8">{% block "content" %}{% endblock %}</div>
</div>
</div>
{% display_nodes %}
{% block body %}
<!-- code suppressed for brevity -->
{% endblock body %}
{% block "navigation" %}{% endblock %}
{% block "content" %}{% endblock %}
<script src="{% static 'js/jquery-3.2.1.min.js' %}"></script>
<script src="{% static 'js/popper.min.js' %}"></script>
<script src="{% static 'js/bootstrap.min.js' %}"></script>
</body>
</html>
</html>

View File

@ -0,0 +1,17 @@
{% extends 'base.html' %}
{% load static %}
{% block stylesheet %}
<link rel="stylesheet" href="{% static 'css/accounts.css' %}">
{% endblock %}
{% block body %}
<div class="container">
<h1 class="text-center logo my-4">
<a href="{% url 'home' %}">Django Boards</a>
</h1>
{% block content %}
{% endblock %}
</div>
{% endblock %}

View File

@ -20,8 +20,8 @@
<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>Audiences: {% for audience in document.last_published_version.audiences.all %}{{ audience }}{% endfor %}</li>
<li>Nodes: {% for node in document.last_published_version.nodes.all %}{{ node }}{% endfor %}</li>
<li>Sites: {% for site in document.last_published_version.sites.all %}{{ site }}{% 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>
</ul>
{% endif %}
@ -32,8 +32,8 @@
<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>Audiences: {% for audience in document.last_working_version.audiences.all %}{{ audience }}{% endfor %}</li>
<li>Nodes: {% for node in document.last_working_version.nodes.all %}{{ node }}{% endfor %}</li>
<li>Sites: {% for site in document.last_working_version.sites.all %}{{ site }}{% 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>
</ul>
<h4>Processes</h4>
<ul>

View File

@ -0,0 +1,18 @@
{% extends "../base.html" %}
{% block "navigation" %}
<form action="" method="get">
{{ filter.form.as_p }}
<input type="submit" />
</form>
{% endblock %}
{% block "content" %}
<h2>{% if node.acronym %}{{ node.acronym }} / {% endif %}{{ node.name }}</h2>
<ul>
{% for obj in filter.qs %}
<li><a href="{% url 'document_details' obj.document.id %}">{{ obj.document }} {{ obj }}</a></li>
{% endfor %}
</ul>
{% endblock %}

View File

@ -0,0 +1,12 @@
{% extends "../base.html" %}
{% block "content" %}
<h2>{{ site.name }}</h2>
<ul>
{% for doc in documents %}
<li><a href="{% url 'document_details' doc.id %}">{{ doc }}</a></li>
{% endfor %}
</ul>
{% endblock %}

View File

@ -0,0 +1,13 @@
{% load widget_tweaks %}
{% if form.non_field_errors %}
<div class="alert alert-danger" role="alert">
{% for error in form.non_field_errors %}
<p{% if forloop.last %} class="mb-0"{% endif %}>{{ error }}</p>
{% endfor %}
</div>
{% endif %}
{% for field in form %}
<!-- code suppressed -->
{% endfor %}

28
templates/login.html Normal file
View File

@ -0,0 +1,28 @@
{% extends 'base_accounts.html' %}
{% block title %}Log in to Django Boards{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-lg-4 col-md-6 col-sm-8">
<div class="card">
<div class="card-body">
<h3 class="card-title">Log in</h3>
<form method="post" novalidate>
{% csrf_token %}
{% include 'includes/form.html' %}
<button type="submit" class="btn btn-primary btn-block">Log in</button>
</form>
</div>
<div class="card-footer text-muted text-center">
New to Django Boards? <a href="{% url 'signup' %}">Sign up</a>
</div>
</div>
<div class="text-center py-2">
<small>
<a href="#" class="text-muted">Forgot your password?</a>
</small>
</div>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,11 @@
{% extends "../base.html" %}
{% block "content" %}
<h2>Tasks</h2>
<ul>
{% for task in tasks %}
<li>{{ task }}</li>
{% endfor %}
</ul>
{% endblock "content" %}

View File

@ -0,0 +1,5 @@
<ul>
{% for node in nodes %}
<li style="display: inline;"><a href="{% url 'node_documents' node.id %}">{{ node }}</a></li>
{% endfor %}
</ul>