nanterre: ajoute une vue pour contrôler l'état de la base
This commit is contained in:
parent
3e4d543205
commit
237e44f5a2
|
@ -0,0 +1,24 @@
|
|||
{% extends "gadjo/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Contrôle de l'import</h1>
|
||||
|
||||
<dl>
|
||||
<dt>Nombre d'individus</dt>
|
||||
<dd>{{ count }}</dd>
|
||||
<dt>Nombre d'individus majeurs</dt>
|
||||
<dd>{{ majeurs }}</dd>
|
||||
<dt>Nombre d'individus mineurs</dt>
|
||||
<dd>{{ mineurs }}</dd>
|
||||
<dt>Fédérations technocarte</dt>
|
||||
<dd>{{ federations_technocarte }}</dd>
|
||||
<dt>Fédérations infor</dt>
|
||||
<dd>{{ federations_infor }}</dd>
|
||||
<dt>Fédérations implicit</dt>
|
||||
<dd>{{ federations_implicit}}</dd>
|
||||
<dt>Fédérations saga</dt>
|
||||
<dd>{{ federations_saga}}</dd>
|
||||
<dt>Fédérations saga tiers</dt>
|
||||
<dd>{{ federations_saga_tiers}}</dd>
|
||||
</dl>
|
||||
{% endblock %}
|
|
@ -1,11 +1,12 @@
|
|||
from django.conf.urls import url
|
||||
|
||||
from .views import demo, search
|
||||
from .views import demo, search, import_control
|
||||
from . import api_views
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^demo/$', demo, name='demo'),
|
||||
url(r'^demo/search/$', search, name='demo'),
|
||||
url(r'^import_control/$', import_control, name='demo'),
|
||||
url(r'^search/$', api_views.search, name='rsu-api-search'),
|
||||
url(r'^individu/(?P<identifier>\d+)/$', api_views.reseau, name='rsu-api-reseau'),
|
||||
url(r'^individu/(?P<identifier>\d+)/journal/$', api_views.journal, name='rsu-api-journal'),
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
from django.views.generic import TemplateView
|
||||
from django.db.transaction import non_atomic_requests
|
||||
from django.db import connection
|
||||
|
||||
from . import forms
|
||||
|
||||
|
@ -23,4 +24,39 @@ class Search(TemplateView):
|
|||
return ctx
|
||||
|
||||
|
||||
class ImportControl(TemplateView):
|
||||
template_name = 'zoo_nanterre/import_control.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
ctx = super(ImportControl, self).get_context_data(**kwargs)
|
||||
c = connection.cursor()
|
||||
c.execute("SELECT count(e.id) from zoo_data_entity as e , zoo_meta_entityschema as s where "
|
||||
" e.schema_id = s.id and s.slug = 'individu'")
|
||||
ctx['count'] = c.fetchone()[0]
|
||||
c.execute("SELECT count(e.id) from zoo_data_entity as e , zoo_meta_entityschema as s where "
|
||||
" e.schema_id = s.id and s.slug = 'individu' and e.content->>'statut_legal' = 'majeur'")
|
||||
ctx['majeurs'] = c.fetchone()[0]
|
||||
c.execute("SELECT count(e.id) from zoo_data_entity as e , zoo_meta_entityschema as s where "
|
||||
" e.schema_id = s.id and s.slug = 'individu' and e.content->>'statut_legal' = 'mineur'")
|
||||
ctx['mineurs'] = c.fetchone()[0]
|
||||
c.execute("SELECT count(e.content->'cles_de_federation'->'technocarte') from "
|
||||
"zoo_data_entity as e")
|
||||
ctx['federations_technocarte'] = c.fetchone()[0]
|
||||
c.execute("SELECT count(e.content->'cles_de_federation'->'infor') from "
|
||||
"zoo_data_entity as e")
|
||||
ctx['federations_infor'] = c.fetchone()[0]
|
||||
c.execute("SELECT count(e.content->'cles_de_federation'->'implicit') from "
|
||||
"zoo_data_entity as e")
|
||||
ctx['federations_implicit'] = c.fetchone()[0]
|
||||
c.execute("SELECT count(e.content->'cles_de_federation'->'saga') from "
|
||||
"zoo_data_entity as e")
|
||||
ctx['federations_saga'] = c.fetchone()[0]
|
||||
c.execute("SELECT count(e.content->'cles_de_federation'->'saga_tiers') from "
|
||||
"zoo_data_entity as e")
|
||||
ctx['federations_saga_tiers'] = c.fetchone()[0]
|
||||
return ctx
|
||||
|
||||
|
||||
search = non_atomic_requests(Search.as_view())
|
||||
|
||||
import_control = ImportControl.as_view()
|
||||
|
|
Loading…
Reference in New Issue