0001-wcs-don-t-display-empty-sites-in-BackofficeSubmissio.patch
combo/apps/wcs/models.py | ||
---|---|---|
736 | 736 | |
737 | 737 |
def get_cell_extra_context(self, context): |
738 | 738 |
context = super(BackofficeSubmissionCell, self).get_cell_extra_context(context) |
739 |
all_formdefs = context.pop('all_formdefs') |
|
740 |
formdefs = {} |
|
739 | 741 |
# add a fake category where it's missing |
740 |
for site_formdefs in context['all_formdefs'].values(): |
|
742 |
for key, site_formdefs in all_formdefs.items(): |
|
743 |
if not site_formdefs['data']: |
|
744 |
continue |
|
745 |
formdefs[key] = site_formdefs |
|
741 | 746 |
for formdef in site_formdefs['data']: |
742 |
if not 'category' in formdef:
|
|
747 |
if 'category' not in formdef:
|
|
743 | 748 |
formdef['category'] = _('Misc') |
749 |
context['all_formdefs'] = formdefs |
|
744 | 750 |
return context |
combo/apps/wcs/templates/combo/wcs/backoffice_submission.html | ||
---|---|---|
1 | 1 |
{% load i18n %} |
2 | 2 |
{% block cell-content %} |
3 |
{% if all_formdefs %} |
|
3 | 4 |
<h2>{% trans "New Form" %}</h2> |
4 | 5 |
{% for site_formdefs in all_formdefs.values %} |
5 | 6 |
<div class="links-list"> |
... | ... | |
15 | 16 |
</ul> |
16 | 17 |
</div> |
17 | 18 |
{% endfor %} |
19 |
{% endif %} |
|
18 | 20 |
{% endblock %} |
tests/test_wcs.py | ||
---|---|---|
1162 | 1162 |
assert 'tracking-code' not in search_engines.keys() |
1163 | 1163 |
assert len([x for x in search_engines.keys() if x.startswith('formdata:')]) == 0 |
1164 | 1164 | |
1165 | ||
1165 | 1166 |
@wcs_present |
1166 | 1167 |
def test_backoffice_submission_cell_render(context): |
1167 | 1168 |
page = Page(title='xxx', slug='test_backoffice_submission_cell_render', template_name='standard') |
... | ... | |
1170 | 1171 |
cell.wcs_site = 'default' |
1171 | 1172 |
cell.save() |
1172 | 1173 | |
1173 |
context['synchronous'] = True # to get fresh content |
|
1174 |
context['synchronous'] = True # to get fresh content
|
|
1174 | 1175 | |
1175 | 1176 |
result = cell.render(context) |
1176 | 1177 |
assert '/backoffice/submission/a-private-form/' not in result |
1178 |
assert context['all_formdefs'] == {} |
|
1179 |
assert 'h2' not in result |
|
1177 | 1180 | |
1178 | 1181 |
context['request'].user = MockUser() |
1179 | 1182 | |
1180 | 1183 |
result = cell.render(context) |
1181 | 1184 |
assert '/backoffice/submission/a-private-form/' not in result |
1185 |
assert context['all_formdefs'] == {} |
|
1186 |
assert 'h2' not in result |
|
1182 | 1187 | |
1183 | 1188 |
class MockUser2(MockUser): |
1184 | 1189 |
email = 'foo2@example.net' |
... | ... | |
1186 | 1191 | |
1187 | 1192 |
result = cell.render(context) |
1188 | 1193 |
assert '/backoffice/submission/a-private-form/' in result |
1194 |
assert list(context['all_formdefs'].keys()) == ['default'] |
|
1195 |
assert 'h2' in result |
|
1189 | 1196 | |
1190 | 1197 | |
1191 | 1198 |
@wcs_present |
1192 |
- |