0001-misc-display-after-job-progression-46672.patch
tests/backoffice_pages/test_export.py | ||
---|---|---|
221 | 221 | |
222 | 222 |
# check afterjob ajax call |
223 | 223 |
status_resp = app.get('/afterjobs/' + job_id) |
224 |
assert status_resp.text == 'completed|completed' |
|
224 |
assert status_resp.text == 'completed|completed 2/2 (100%)'
|
|
225 | 225 | |
226 | 226 |
# check error handling |
227 | 227 |
app.get('/afterjobs/whatever', status=404) |
wcs/api.py | ||
---|---|---|
1171 | 1171 |
'label': self.afterjob.label, |
1172 | 1172 |
'creation_time': self.afterjob.creation_time, |
1173 | 1173 |
'completion_time': self.afterjob.completion_time, |
1174 |
'completion_status': self.afterjob.completion_status,
|
|
1174 |
'completion_status': self.afterjob.get_completion_status(),
|
|
1175 | 1175 |
}, |
1176 | 1176 |
}, |
1177 | 1177 |
cls=misc.JSONEncoder, |
wcs/backoffice/data_management.py | ||
---|---|---|
363 | 363 |
def execute(self): |
364 | 364 |
self.carddef = self.kwargs['carddef_class'].get(self.kwargs['carddef_id']) |
365 | 365 |
carddata_class = self.carddef.data_class() |
366 |
for item in self.kwargs['data_lines']: |
|
366 |
self.total_count = len(self.kwargs['data_lines']) |
|
367 |
self.store() |
|
368 | ||
369 |
for i, item in enumerate(self.kwargs['data_lines']): |
|
367 | 370 |
data_instance = carddata_class() |
368 | 371 |
user_value = item.pop('_user', None) |
369 | 372 |
data_instance.user = self.user_lookup(user_value) |
... | ... | |
371 | 374 |
data_instance.just_created() |
372 | 375 |
data_instance.store() |
373 | 376 |
data_instance.perform_workflow(event='csv-import-created') |
377 |
self.current_count = i + 1 |
|
378 |
self.store() |
|
374 | 379 | |
375 | 380 |
def done_action_url(self): |
376 | 381 |
carddef = self.kwargs['carddef_class'].get(self.kwargs['carddef_id']) |
wcs/backoffice/management.py | ||
---|---|---|
3887 | 3887 |
return |
3888 | 3888 | |
3889 | 3889 |
formdatas = formdef.data_class().get_ids(item_ids, order_by='receipt_time') |
3890 |
self.completion_status = f'0/{len(formdatas)}'
|
|
3890 |
self.total_count = len(formdatas)
|
|
3891 | 3891 |
self.store() |
3892 | 3892 | |
3893 | 3893 |
publisher = get_publisher() |
... | ... | |
3903 | 3903 |
{ |
3904 | 3904 |
'oldest_form': oldest_lazy_form, |
3905 | 3905 |
'mass_action_index': i, |
3906 |
'mass_action_length': len(formdatas),
|
|
3906 |
'mass_action_length': self.total_count,
|
|
3907 | 3907 |
} |
3908 | 3908 |
) |
3909 | 3909 |
if getattr(action['action'], 'status_action', False): |
... | ... | |
3914 | 3914 |
else: |
3915 | 3915 |
# global action |
3916 | 3916 |
formdata.perform_global_action(action['action'].id, user) |
3917 |
self.completion_status = f'{i + 1}/{len(formdatas)}'
|
|
3917 |
self.current_count = i + 1
|
|
3918 | 3918 |
self.store() |
3919 | 3919 | |
3920 | 3920 |
def done_action_url(self): |
... | ... | |
3963 | 3963 |
items, total_count = FormDefUI(formdef).get_listing_items( |
3964 | 3964 |
fields, selected_filter, user=user, query=query, criterias=criterias, order_by=order_by |
3965 | 3965 |
) |
3966 |
self.total_count = total_count |
|
3967 |
self.store() |
|
3966 | 3968 | |
3967 | 3969 |
return self.create_export(formdef, fields, items, total_count) |
3968 | 3970 | |
... | ... | |
3973 | 3975 |
if not self.kwargs.get('skip_header_line'): |
3974 | 3976 |
csv_output.writerow(self.csv_tuple_heading(fields)) |
3975 | 3977 | |
3976 |
for filled in items:
|
|
3978 |
for i, filled in enumerate(items):
|
|
3977 | 3979 |
csv_output.writerow(tuple(x['value'] for x in self.get_spreadsheet_line(fields, filled))) |
3980 |
self.current_count = i + 1 |
|
3981 |
self.store() |
|
3978 | 3982 | |
3979 | 3983 |
self.file_content = output.getvalue() |
3980 | 3984 |
self.content_type = 'text/csv' |
... | ... | |
4018 | 4022 |
data_field=item['field'], |
4019 | 4023 |
native_value=item['native_value'], |
4020 | 4024 |
) |
4025 |
self.current_count = i + 1 |
|
4026 |
self.store() |
|
4021 | 4027 | |
4022 | 4028 |
output = io.BytesIO() |
4023 | 4029 |
workbook.save(output) |
wcs/qommon/afterjobs.py | ||
---|---|---|
35 | 35 | |
36 | 36 |
response = get_response() |
37 | 37 |
response.set_content_type('text/plain') |
38 |
if not job.completion_status: |
|
38 |
completion_status = job.get_completion_status() |
|
39 |
if not completion_status: |
|
39 | 40 |
return job.status + '|' + str(_(job.status)) |
40 |
return job.status + '|' + str(_(job.status)) + ' ' + job.completion_status
|
|
41 |
return job.status + '|' + str(_(job.status)) + ' ' + str(completion_status)
|
|
41 | 42 | |
42 | 43 | |
43 | 44 |
class AfterJob(StorableObject): |
... | ... | |
48 | 49 |
status = None |
49 | 50 |
creation_time = None |
50 | 51 |
completion_time = None |
51 |
completion_status = None |
|
52 |
current_count = None |
|
53 |
total_count = None |
|
52 | 54 | |
53 | 55 |
execute = None |
54 | 56 | |
... | ... | |
73 | 75 |
def done_action_attributes(self): |
74 | 76 |
return self.done_button_attributes_arg |
75 | 77 | |
78 |
def get_completion_status(self): |
|
79 |
if not self.total_count: |
|
80 |
return '' |
|
81 |
current_count = self.current_count or 0 |
|
82 |
percent = int(current_count * 100 / self.total_count) |
|
83 |
return _(f'{current_count}/{self.total_count} ({percent}%)') |
|
84 | ||
76 | 85 |
def run(self, spool=False): |
77 | 86 |
if self.completion_time: |
78 | 87 |
return |
79 |
- |