0001-backoffice-keep-track-of-agent-doing-backoffice-subm.patch
tests/test_api.py | ||
---|---|---|
393 | 393 |
assert data_class.get(resp.json['data']['id']).status == 'wf-new' |
394 | 394 |
assert data_class.get(resp.json['data']['id']).backoffice_submission is True |
395 | 395 |
assert data_class.get(resp.json['data']['id']).user_id is None |
396 |
assert data_class.get(resp.json['data']['id']).submission_context.get('agent_id') == local_user.id |
|
396 | 397 | |
397 | 398 |
formdef.enable_tracking_codes = True |
398 | 399 |
formdef.store() |
... | ... | |
407 | 408 |
assert data_class.get(resp.json['data']['id']).status == 'wf-new' |
408 | 409 |
assert data_class.get(resp.json['data']['id']).backoffice_submission is True |
409 | 410 |
assert data_class.get(resp.json['data']['id']).user_id is None |
410 |
assert data_class.get(resp.json['data']['id']).submission_context == {'comments': 'blah'} |
|
411 |
assert data_class.get(resp.json['data']['id']).submission_context == { |
|
412 |
'comments': 'blah', 'agent_id': local_user.id} |
|
411 | 413 |
assert data_class.get(resp.json['data']['id']).submission_channel == 'mail' |
412 | 414 | |
413 | 415 |
data_class.wipe() |
tests/test_backoffice_pages.py | ||
---|---|---|
935 | 935 |
formdata.data = {} |
936 | 936 |
formdata.status = 'draft' |
937 | 937 |
formdata.backoffice_submission = True |
938 |
formdata.submission_context = {'agent_id': user.id} |
|
938 | 939 |
formdata.store() |
939 | 940 | |
940 | 941 |
resp = app.get('/backoffice/') |
941 | 942 |
assert 'Submission' in resp.body |
942 | 943 |
resp = app.get('/backoffice/submission/') |
943 | 944 |
assert 'Submission to complete' in resp.body |
945 |
# check agent name is displayed next to pending submission |
|
946 |
assert '(%s)' % user.display_name in resp.body |
|
944 | 947 | |
945 | 948 |
def test_backoffice_submission_dispatch(pub): |
946 | 949 |
user = create_user(pub) |
wcs/api.py | ||
---|---|---|
177 | 177 |
formdata.submission_context = json_input['context'] |
178 | 178 |
formdata.submission_channel = formdata.submission_context.pop('channel', None) |
179 | 179 |
formdata.user_id = formdata.submission_context.pop('user_id', None) |
180 | ||
181 |
if meta.get('backoffice-submission'): |
|
182 |
# keep track of the agent that did the submit |
|
183 |
if not formdata.submission_context: |
|
184 |
formdata.submission_context = {} |
|
185 |
formdata.submission_context['agent_id'] = user.id |
|
186 | ||
180 | 187 |
formdata.store() |
181 | 188 |
if self.formdef.enable_tracking_codes: |
182 | 189 |
code = get_publisher().tracking_code_class() |
wcs/backoffice/submission.py | ||
---|---|---|
128 | 128 |
filled.just_created() |
129 | 129 |
filled.data = self.formdef.get_data(form) |
130 | 130 |
filled.backoffice_submission = True |
131 |
if not filled.submission_context: |
|
132 |
filled.submission_context = {} |
|
133 |
filled.submission_context['agent_id'] = get_request().user.id |
|
131 | 134 |
filled.store() |
132 | 135 | |
133 | 136 |
self.set_tracking_code(filled) |
... | ... | |
147 | 150 |
def save_draft(self, data, page_no): |
148 | 151 |
formdata = super(FormFillPage, self).save_draft(data, page_no) |
149 | 152 |
formdata.backoffice_submission = True |
153 |
if not formdata.submission_context: |
|
154 |
formdata.submission_context = {} |
|
155 |
formdata.submission_context['agent_id'] = get_request().user.id |
|
150 | 156 |
formdata.store() |
151 | 157 |
return formdata |
152 | 158 | |
... | ... | |
273 | 279 |
label = '%s ' % formdata.get_submission_channel_label() |
274 | 280 |
label += _('#%(id)s, %(time)s') % {'id': formdata.id, |
275 | 281 |
'time': misc.localstrftime(formdata.receipt_time)} |
282 |
if formdata.submission_context and 'agent_id' in formdata.submission_context: |
|
283 |
agent_user = get_publisher().user_class.get( |
|
284 |
formdata.submission_context['agent_id'], ignore_errors=True) |
|
285 |
if agent_user: |
|
286 |
label += ' (%s)' % agent_user.display_name |
|
276 | 287 |
r += htmltext('<a href="%s/%s">%s</a>') % ( |
277 | 288 |
formdef.url_name, formdata.id, label) |
278 | 289 |
r += htmltext('</li>') |
279 |
- |