add templates for jci standards and intents

This commit is contained in:
Fred Pauchet 2017-10-23 15:44:28 +02:00
parent 7198032a30
commit eb259d972f
7 changed files with 47 additions and 5 deletions

View File

@ -13,14 +13,13 @@ Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.conf.urls import url, include
from django.contrib import admin
from evolus.views import documents_list
from jci.views import jci_list
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^docs/search', documents_list),
url(r'^jci/list', jci_list)
url(r'^jci/', include('jci.urls')),
]

View File

@ -52,7 +52,7 @@ class Standard(models.Model):
order = models.CharField(max_length=50)
parent = models.ForeignKey('self', null=True, blank=True)
require_written_procedure = models.BooleanField(default=False)
intent = models.ForeignKey(Intent, null=True, blank=True)
intent = models.ForeignKey(Intent, null=True, blank=True, related_name='standards')
@property
def structure(self):

10
jci/urls.py Normal file
View File

@ -0,0 +1,10 @@
from django.conf.urls import url
from jci.views import get_intent, get_standard, jci_list
urlpatterns = [
url(r'intent/(?P<intent_id>[0-9]+)$', get_intent, name='intent_details'),
url(r'standard/(?P<standard_id>[0-9]+)$', get_standard, name='standard_details'),
url(r'$', jci_list, name='jci_home'),
]

View File

@ -1,8 +1,17 @@
from django.shortcuts import render
from jci.models import Section
from jci.models import Intent, Section, Standard
def jci_list(request):
sections = Section.objects.prefetch_related('headlines').prefetch_related('headlines__standards')
return render(request, 'jci/list.html', {'sections': sections})
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})

3
templates/jci/base.html Normal file
View File

@ -0,0 +1,3 @@
<html>
{% block "content"%} {% endblock %}
</html>

View File

@ -0,0 +1,13 @@
{% extends "../base.html" %}
{% block "content" %}
{{ intent.content }}
{% if intent.standards.all %}
<ul>
{% for standard in intent.standards.all %}
<li><a href="{% url 'standard_details' standard.id %}">{{ standard }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endblock %}

View File

@ -0,0 +1,8 @@
{% extends "../base.html" %}
{% block "content" %}
{{ standard }}
<h2><a href="{% url 'intent_details' standard.intent.id %}">Intent</a></h2>
{{ standard.intent.content }}
{% endblock %}