0001-formdef-forbid-use-of-data_class-on-lightweight-form.patch
wcs/api.py | ||
---|---|---|
685 | 685 |
) |
686 | 686 |
else: |
687 | 687 |
# naive count |
688 |
count = formdef.data_class().count() |
|
688 |
count = formdef.data_class(lightweight=True).count()
|
|
689 | 689 |
formdict['count'] = count |
690 | 690 | |
691 | 691 |
formdict['functions'] = {} |
wcs/backoffice/management.py | ||
---|---|---|
508 | 508 |
count_forms = total_counts.get(formdef.id) or 0 |
509 | 509 |
waiting_forms_count = actionable_counts.get(formdef.id) or 0 |
510 | 510 |
else: |
511 |
formdef_data_class = formdef.data_class() |
|
511 |
formdef_data_class = formdef.data_class(lightweight=True)
|
|
512 | 512 |
count_forms = formdef_data_class.count() - len( |
513 | 513 |
formdef_data_class.get_ids_with_indexed_value('status', 'draft') |
514 | 514 |
) |
wcs/formdef.py | ||
---|---|---|
287 | 287 |
def data_class_name(self): |
288 | 288 |
return '_wcs_%s' % self.url_name.title() |
289 | 289 | |
290 |
def data_class(self, mode=None): |
|
290 |
def data_class(self, mode=None, lightweight=False): |
|
291 |
if getattr(self, 'fields', None) is Ellipsis and not lightweight: |
|
292 |
raise RuntimeError('accessing data from a lightweight object is not allowed') |
|
293 | ||
291 | 294 |
if not 'formdef' in sys.modules: |
292 | 295 |
sys.modules['formdef'] = sys.modules[__name__] |
293 | 296 |
if hasattr(sys.modules['formdef'], self.data_class_name): |
... | ... | |
1403 | 1406 |
# if no formdata was given, lookup if there are some existing formdata |
1404 | 1407 |
# where the user has access. |
1405 | 1408 |
if not formdata: |
1406 |
data_class = self.data_class() |
|
1409 |
data_class = self.data_class(lightweight=True)
|
|
1407 | 1410 |
for role_id in user.get_roles(): |
1408 | 1411 |
if data_class.get_ids_with_indexed_value('workflow_roles', role_id): |
1409 | 1412 |
return True |
1410 |
- |