0001-backoffice-use-a-template-to-render-data-management-.patch
wcs/backoffice/data_management.py | ||
---|---|---|
19 | 19 | |
20 | 20 |
from ..qommon import _ |
21 | 21 |
from ..qommon import errors |
22 |
from ..qommon import template |
|
22 | 23 |
from ..qommon.backoffice.menu import html_top |
23 | 24 | |
24 | 25 |
from wcs.carddef import CardDef |
... | ... | |
26 | 27 | |
27 | 28 | |
28 | 29 |
class DataManagementDirectory(ManagementDirectory): |
30 |
do_not_call_in_templates = True |
|
29 | 31 |
_q_exports = [''] |
30 | 32 | |
31 | 33 |
def _q_traverse(self, path): |
... | ... | |
44 | 46 |
return True |
45 | 47 |
return False |
46 | 48 | |
47 |
def _q_index(self): |
|
48 |
html_top('data_management', _('Cards')) |
|
49 |
formdefs = CardDef.select(order_by='name', ignore_errors=True, lightweight=True) |
|
50 |
if len(formdefs) == 0: |
|
51 |
return self.empty_site_message(_('Cards')) |
|
52 |
r = TemplateIO(html=True) |
|
53 |
r += get_session().display_message() |
|
54 | ||
55 |
r += htmltext('<div id="appbar">') |
|
56 |
r += htmltext('<h2>%s</h2>') % _('Cards') |
|
57 |
r += htmltext('</div>') |
|
58 | ||
49 |
def get_carddefs(self): |
|
59 | 50 |
user = get_request().user |
60 | 51 |
if user: |
61 |
cards = [] |
|
62 |
for formdef in formdefs: |
|
52 |
for formdef in CardDef.select(order_by='name', ignore_errors=True, lightweight=True): |
|
63 | 53 |
if user.is_admin or formdef.is_of_concern_for_user(user): |
64 |
cards.append(formdef) |
|
65 |
r += htmltext('<ul class="biglist">') |
|
66 |
for carddef in cards: |
|
67 |
r += htmltext('<li><strong><a href="%s/">%s</a></strong></li>') % (carddef.url_name, carddef.name) |
|
68 |
r += htmltext('</ul>') |
|
54 |
yield formdef |
|
55 | ||
56 |
def _q_index(self): |
|
57 |
html_top('data_management', _('Cards')) |
|
58 |
if CardDef.count() == 0: |
|
59 |
return self.empty_site_message(_('Cards')) |
|
69 | 60 | |
70 |
return r.getvalue() |
|
61 |
return template.QommonTemplateResponse( |
|
62 |
templates=['wcs/backoffice/data-management.html'], |
|
63 |
context={'view': self}) |
|
71 | 64 | |
72 | 65 |
def _q_lookup(self, component): |
73 | 66 |
return CardPage(component) |
wcs/context_processors.py | ||
---|---|---|
14 | 14 |
# You should have received a copy of the GNU General Public License |
15 | 15 |
# along with this program; if not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 |
from quixote import get_publisher, get_response, get_request |
|
17 |
from quixote import get_publisher, get_response, get_request, get_session
|
|
18 | 18 | |
19 | 19 |
def get_global_context(): |
20 | 20 |
pub = get_publisher() |
... | ... | |
31 | 31 |
'user': lambda: get_request() and get_request().user, |
32 | 32 |
'template_base': template_base, |
33 | 33 |
'global_context': get_global_context, |
34 |
'session_message': lambda: get_session() and get_session().display_message(), |
|
34 | 35 |
} |
wcs/templates/wcs/backoffice/base.html | ||
---|---|---|
1 |
{% block appbar %} |
|
2 |
<div id="appbar"> |
|
3 |
<h2>{% block appbar-title %}{% endblock %}</h2> |
|
4 |
</div> |
|
5 |
{% endblock %} |
|
6 | ||
7 |
{% block session-message %} |
|
8 |
{{session_message|safe}} |
|
9 |
{% endblock %} |
|
10 | ||
11 |
{% block content %} |
|
12 |
{% endblock %} |
wcs/templates/wcs/backoffice/data-management.html | ||
---|---|---|
1 |
{% extends "wcs/backoffice/base.html" %} |
|
2 |
{% load i18n %} |
|
3 | ||
4 |
{% block appbar-title %}{% trans "Cards" %}{% endblock %} |
|
5 | ||
6 |
{% block content %} |
|
7 |
<ul class="objects-list single-links"> |
|
8 |
{% for carddef in view.get_carddefs %} |
|
9 |
<li><a href="{{ carddef.url_name }}">{{ carddef.name }}</a></li> |
|
10 |
{% endfor %} |
|
11 |
</ul> |
|
12 |
{% endblock %} |
wcs/templates/wcs/backoffice/studio.html | ||
---|---|---|
1 |
{% extends "wcs/backoffice/base.html" %} |
|
1 | 2 |
{% load i18n %} |
2 | 3 | |
3 |
{% block body %}
|
|
4 |
{% block appbar %}
|
|
4 | 5 |
<div id="appbar" class="highlight"> |
5 | 6 |
<h2>{% trans "Studio" %}</h2> |
6 | 7 |
</div> |
8 |
{% endblock %} |
|
9 | ||
10 |
{% block content %} |
|
7 | 11 |
<div id="studio"> |
8 | 12 |
{% if user.can_go_in_backoffice_forms %} |
9 | 13 |
<a class="button button-paragraph" href="../forms/">{% trans "Forms" context "studio" %} |
10 |
- |