0001-manager-set-agenda-export-filename-43941.patch
chrono/manager/views.py | ||
---|---|---|
1135 | 1135 | |
1136 | 1136 |
def get(self, request, *args, **kwargs): |
1137 | 1137 |
response = HttpResponse(content_type='application/json') |
1138 |
today = datetime.date.today() |
|
1139 |
response['Content-Disposition'] = 'attachment; filename="export_agenda_{}_{}.json"'.format( |
|
1140 |
self.get_object().slug, today.strftime('%Y%m%d') |
|
1141 |
) |
|
1138 | 1142 |
json.dump({'agendas': [self.get_object().export_json()]}, response, indent=2) |
1139 | 1143 |
return response |
1140 | 1144 |
tests/test_manager.py | ||
---|---|---|
2792 | 2792 |
agenda.view_role = manager_user.groups.all()[0] |
2793 | 2793 |
agenda.save() |
2794 | 2794 |
app = login(app, username='manager', password='manager') |
2795 |
resp = app.get('/manage/', status=200)
|
|
2796 |
resp = app.get('/manage/agendas/import/', status=403)
|
|
2795 |
app.get('/manage/', status=200) |
|
2796 |
app.get('/manage/agendas/import/', status=403) |
|
2797 | 2797 | |
2798 | 2798 | |
2799 | 2799 |
def test_import_agenda(app, admin_user): |
... | ... | |
2802 | 2802 | |
2803 | 2803 |
app = login(app) |
2804 | 2804 |
resp = app.get('/manage/agendas/%s/settings' % agenda.id) |
2805 |
resp = resp.click('Export') |
|
2805 |
with freezegun.freeze_time('2020-06-15'): |
|
2806 |
resp = resp.click('Export') |
|
2806 | 2807 |
assert resp.headers['content-type'] == 'application/json' |
2808 |
assert resp.headers['content-disposition'] == 'attachment; filename="export_agenda_foo-bar_20200615.json"' |
|
2807 | 2809 |
agenda_export = resp.text |
2808 | 2810 | |
2809 | 2811 |
# invalid json |
2810 |
- |