Customize Django form label in realtime in clinicedc/edc projects
Project description
edc-form-label
Customize Django’s form label in realtime
For a sequence of data collection timepoints, we ask the question, “Are you circumcised?”. At some time point we hope the response will be YES, but until then, we need to ask “Since we last saw you, were you circumcised?”. It is a lot better if we can ask, “Since we last saw you in ‘October 2018’, were you circumcised?”, where ‘October 2018’ represents the timepoint from which we got our last reponse.
This module shows how you can insert ‘October 2018’ into the ModelAdmin/ModelForm the form label in realtime.
For example:
For a sequence of data collection timepoints, we ask the question, “Are you circumcised”. At some point we hope the response will be YES. But until then we need to ask “Since we last saw you in October 2018, were you circumcised?”, etc.
from edc_form_label import FormLabel, CustomFormLabel, FormLabelModelAdminMixin
class MyCustomLabelCondition(CustomLabelCondition):
def check(self, **kwargs):
if self.previous_obj.circumcised == NO:
return True
return False
@register(MyModel)
class MyModelAdmin(FormLabelModelAdminMixin admin.ModelAdmin):
fieldsets = (
(None, {
'fields': (
'subject_visit',
'report_datetime',
'circumcised')},
),
)
custom_form_labels = [
FormLabel(
field='circumcised',
custom_label='Since we last saw you in {previous_visit}, were you circumcised?',
condition_cls=MyCustomLabelCondition)
]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for edc_form_label-0.3.12-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ca42078ebaba5e66e1290791fdac3ed6e74fedfefffbadb4654175a4fa1c4dc |
|
MD5 | 5f3f7eaa21bfe89245bae792012a3204 |
|
BLAKE2b-256 | 80092220a2d817cc84a5146432f1cb0a5e38af3d02604406966274c4a6ae4794 |