general: add home and term views
This commit is contained in:
parent
5bed45419b
commit
5e1b59288f
|
@ -1,3 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Django settings for pfwb_thesaurus project.
|
||||
|
||||
|
@ -97,6 +99,14 @@ STATICFILES_DIRS = (
|
|||
|
||||
|
||||
TABELLIO_DB_SETTINGS = {}
|
||||
HOMEPAGE_START_TERMS = ["matières culturelles",
|
||||
"politique de la santé",
|
||||
"budget et finances publiques",
|
||||
"fonction publique",
|
||||
"enseignement",
|
||||
"aide aux personnes",
|
||||
"recherche scientifique",
|
||||
"relations extérieures"]
|
||||
|
||||
local_settings_file = os.environ.get('PFWB_THESAURUS_SETTINGS_FILE',
|
||||
os.path.join(os.path.dirname(__file__), 'local_settings.py'))
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
table td {
|
||||
vertical-align: top;
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div>
|
||||
<h3>TG (Termes génériques)</h3>
|
||||
{% if object.broader.count %}
|
||||
<ul>
|
||||
{% for term in object.broader.all %}
|
||||
<li><a href="{% url 'term' pk=term.pk %}">{{term.term}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<i>néant</i>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><h2>{{object.term}}</h2>
|
||||
{% if object.alternativeterm_set.count %}
|
||||
<div>
|
||||
<h3>Employé pour (équivalences)</h3>
|
||||
<ul>
|
||||
{% for alt in object.alternativeterm_set.all %}
|
||||
<li>[{{alt.term}}]</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if object.historical_note %}
|
||||
<div>
|
||||
<p>{{ object.historical_note }}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<div>
|
||||
<h3>TA (Termes associés — Voir aussi)</h3>
|
||||
{% if object.related.count %}
|
||||
<ul>
|
||||
{% for term in object.related.all %}
|
||||
<li><a href="{% url 'term' pk=term.pk %}">{{term.term}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<i>néant</i>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div>
|
||||
<h3>TS (Termes spécifiques)</h3>
|
||||
{% if object.narrower.count %}
|
||||
<ul>
|
||||
{% for term in object.narrower.all %}
|
||||
<li><a href="{% url 'term' pk=term.pk %}">{{term.term}}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<i>néant</i>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,12 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Points d'entrée</h2>
|
||||
|
||||
<ul>
|
||||
{% for term in object_list %}
|
||||
<li><a href="{% url 'term' pk=term.pk %}">{{ term.term }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
|
@ -2,9 +2,7 @@ from django.conf.urls import patterns, include, url
|
|||
from django.contrib import admin
|
||||
|
||||
urlpatterns = patterns('',
|
||||
# Examples:
|
||||
# url(r'^$', 'pfwb_thesaurus.views.home', name='home'),
|
||||
# url(r'^blog/', include('blog.urls')),
|
||||
|
||||
url(r'^$', 'pfwb_thesaurus.views.home', name='home'),
|
||||
url(r'^term/(?P<pk>\w+)$', 'pfwb_thesaurus.views.term', name='term'),
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
)
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
# pfwb_thesaurus - thesaurus system
|
||||
# Copyright (C) 2016 Entr'ouvert
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Affero General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from django.views.generic import DetailView, ListView
|
||||
from django.conf import settings
|
||||
|
||||
from .thesaurus.models import Term
|
||||
|
||||
|
||||
class HomeView(ListView):
|
||||
model = Term
|
||||
|
||||
def get_queryset(self, qs=None):
|
||||
return Term.objects.filter(term__in=settings.HOMEPAGE_START_TERMS)
|
||||
|
||||
home = HomeView.as_view()
|
||||
|
||||
|
||||
class TermView(DetailView):
|
||||
model = Term
|
||||
|
||||
term = TermView.as_view()
|
Reference in New Issue