Browse Source

Interface for new em

prieto 8 years ago
parent
commit
7178d9116d

+ 19
- 0
lodel/leapi/lefactory_common.py View File

@@ -25,6 +25,25 @@ def lowername2class(name):
25 25
         return False
26 26
     return new_dict[name]
27 27
 
28
+##@brief Return the list of authors of a publication
29
+
30
+def get_authors(publication):
31
+    texts = publication.data('linked_texts')
32
+    text_objects = Text.get(("%s in (%s)") % ("lodel_id", str(texts).strip('[]')))
33
+    #authors = [str(text.data('linked_persons')).strip('[]') for text in text_objects]
34
+    authors = list()
35
+    for text in text_objects:
36
+        for lp in text.data('linked_persons'):
37
+            authors.append(lp)
38
+    parts = publication.data('linked_parts')
39
+    part_objects = Part.get(("%s in (%s)") % ("lodel_id", str(parts).strip('[]')))
40
+    for part in part_objects:
41
+        for elem in get_authors(part):
42
+            authors.append(elem)
43
+
44
+    authors_list = list()
45
+    [authors_list.append(author) for author in authors if not author in authors_list]
46
+    return authors_list
28 47
 
29 48
 ##@brief Trigger dynclasses datasources initialisation
30 49
 @LodelHook("lodel2_plugins_loaded")

+ 7
- 0
lodel/plugins/webui/interface/controllers/listing.py View File

@@ -15,6 +15,13 @@ from ...exceptions import *
15 15
 def collections(request):
16 16
     return get_response('listing/collections.html', my_classes=dyncode)
17 17
 
18
+##@brief Controller's function to list all types (classes) of the editorial model
19
+# @param request : the request (get or post)
20
+# @note the response is given in a html page called in get_response_function
21
+def issue(request):
22
+    lodel_id = request.GET['lodel_id']
23
+    return get_response('listing/issue.html', lodel_id=lodel_id[0], my_classes=dyncode )
24
+
18 25
 ##@brief Controller's function to list all types (classes) of the editorial model
19 26
 # @param request : the request (get or post)
20 27
 # @note the response is given in a html page called in get_response_function

+ 2
- 0
lodel/plugins/webui/interface/urls.py View File

@@ -19,6 +19,8 @@ urls = (
19 19
     (r'^/list_classes?$', list_classes),
20 20
     (r'^/collections', collections),
21 21
     (r'^/collections?$', collections),
22
+    (r'^/issue?$', issue),
23
+    (r'^/issue', issue),
22 24
     (r'^/show_object?$', show_object),
23 25
     (r'^/show_object_detailled?$', show_object_detailled),
24 26
     (r'^/show_class?$', show_class),

+ 31
- 0
lodel/plugins/webui/templates/listing/collections.html View File

@@ -0,0 +1,31 @@
1
+{% extends "base.html" %}
2
+{% block title %}Lodel 2 - Collections {% endblock %}
3
+{% block content %} 
4
+{% set collections = my_classes.Collection.get(None) %}
5
+
6
+<ol class="breadcrumb">
7
+  <li><a href="/{{ root_url }}/">Home</a></li>
8
+  <li class="active">Collections</li>
9
+</ol>
10
+<h1 class="h1_lodel">Collections </h1>
11
+    <ul>
12
+        {% for collection in collections %}
13
+        <h2>{{ collection.data('title') }}</h2>
14
+        {% set filter = ("%s = %s") % ('collection', collection.uid()) %}
15
+        {% set issues = my_classes.Issue.get((filter)) %}
16
+        <ul>
17
+        {% if issues is not none: %}
18
+            {% for issue in issues %}
19
+                <li>
20
+                    <h3><a href="/{{ root_url }}/issue?lodel_id={{ issue.uid() }}"> {{ issue.data('title') }}</a></h3>
21
+                    <h3>{{ issue.data('subtitle') }}</h3>
22
+                    {% set author_ids = my_classes.get_authors(issue) %}
23
+                    {% set authors = my_classes.Person.get(("%s in (%s)") % ("lodel_id", author_ids|join(','))) %}
24
+                    <p>Authors : {% for author in authors %} {{ author.data('firstname')}} {{ author.data('lastname')}} ; {% endfor %} </p>
25
+                </li>
26
+            {% endfor %}
27
+        {% endif %}
28
+        </ul>
29
+        {% endfor %}
30
+     <ul>
31
+{% endblock %} 

+ 59
- 0
lodel/plugins/webui/templates/listing/issue.html View File

@@ -0,0 +1,59 @@
1
+{% extends "base.html" %}
2
+{% block title %}Lodel 2 - Issue {{ lodel_id }} {% endblock %}
3
+{% set uidfield = my_classes.Issue.uid_fieldname()[0] %}
4
+{% set objects = my_classes.Issue.get(('%s = %s') % (uidfield, lodel_id)) %}
5
+{% set person_class = leapi.name2class('Person') %}
6
+{% set obj = objects.pop() %}
7
+{% block content %} 
8
+<ol class="breadcrumb">
9
+  <li><a href="/{{ root_url }}/">Home</a></li>
10
+  <li><a href="/{{ root_url }}/collection">Collections</a></li>
11
+  <li class="active"><a href="/{{ root_url }}/issue?lodel_id={{ lodel_id}}">Collection {{ obj.data('collection') }} - Issue {{lodel_id}}</a></li>
12
+</ol>
13
+<h1 class="h1_lodel">Issue {{ obj.data('title') }} </h1>
14
+<h2>{{ obj.data('subtitle') }}</h2>
15
+{% set directors=person_class.get(("%s in (%s)") % (person_class.uid_fieldname()[0], obj.data('linked_directors')|join(','))) %}
16
+<p><strong>Directors : </strong>{% for director in directors %} <a href="/{{ root_url }}/show_object?classname=Person&lodel_id={{ director.uid() }} " target="_blank" >{{ director.data('firstname')}} {{ director.data('lastname')}}</a> ; {% endfor %}</p>
17
+{% set texts=my_classes.Text.get(("%s in (%s)") % (my_classes.Text.uid_fieldname()[0], obj.data('linked_texts')|join(','))) %}
18
+{% set parts=my_classes.Part.get(("%s in (%s)") % (my_classes.Part.uid_fieldname()[0], obj.data('linked_parts')|join(','))) %}
19
+{% if texts is not none: %}
20
+    <ul>
21
+     {% for text in texts %}
22
+          <li>
23
+              <h3><a href="/{{ root_url }}/show_object?classname={{ text.data('classname') }}&lodel_id={{ text.uid() }}"> {{ text.data('title') }}</a></h3>
24
+              <h4>{{ text.data('subtitle') }}</h4>
25
+              {% set authors = my_classes.Person.get(("%s in (%s)") % (person_class.uid_fieldname()[0], text.data('linked_persons')|join(','))) %}
26
+              <p>Authors : {% for author in authors %} {{ author.data('firstname')}} {{ author.data('lastname')}} ; {% endfor %} </p>
27
+              <div style="margin-left:20px; text-align:justify">{{ text.data('text') }}</div>
28
+            </li>
29
+    {% endfor %}
30
+</ul>
31
+{% endif %}
32
+
33
+{% if parts is not none: %}
34
+<ul>
35
+     {% for part in parts %}
36
+          <li>
37
+              <h3><a href="/{{ root_url }}/show_object?classname{{ part.data('classname') }}=&lodel_id={{ part.uid() }}" target="_blank"> {{ part.data('title') }}</a></h3>
38
+              <h4>{{ part.data('subtitle') }}</h4>
39
+              {% set directors = my_classes.Person.get(("%s in (%s)") % (person_class.uid_fieldname()[0], part.data('linked_directors')|join(','))) %}
40
+              <p>Directors : {% for director in directors %} {{ director.data('firstname')}} {{ director.data('lastname')}} ; {% endfor %} </p>
41
+              {% set p_texts=my_classes.Text.get(("%s in (%s)") % (my_classes.Text.uid_fieldname()[0], part.data('linked_texts')|join(','))) %}
42
+              {% if texts is not none: %}
43
+                 {% for text in p_texts %}
44
+                      <li>
45
+                          <h3><a href="/{{ root_url }}/show_object?classname={{ text.data('classname') }}&lodel_id={{ text.uid() }}"  target="_blank"> {{ text.data('title') }}</a></h3>
46
+                          <h4>{{ text.data('subtitle') }}</h4>
47
+                          {% set authors = my_classes.Person.get(("%s in (%s)") % (person_class.uid_fieldname()[0], text.data('linked_persons')|join(','))) %}
48
+                          <p>Authors : {% for author in authors %} {{ author.data('firstname')}} {{ author.data('lastname')}} ; {% endfor %} </p>
49
+                          <div style="margin-left:20px; text-align:justify">{{ text.data('text') }}</div>
50
+                        </li>
51
+                {% endfor %}
52
+              {% endif %}
53
+          </li>
54
+    {% endfor %}
55
+</ul>
56
+{% endif %}
57
+
58
+
59
+{% endblock %} 

Loading…
Cancel
Save