add templates for jci standards and intents
This commit is contained in:
parent
7198032a30
commit
eb259d972f
|
@ -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')),
|
||||
]
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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'),
|
||||
]
|
11
jci/views.py
11
jci/views.py
|
@ -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})
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<html>
|
||||
{% block "content"%} {% endblock %}
|
||||
</html>
|
|
@ -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 %}
|
|
@ -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 %}
|
Loading…
Reference in New Issue