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
File details
Details for the file edc_form_label-0.3.19.tar.gz
.
File metadata
- Download URL: edc_form_label-0.3.19.tar.gz
- Upload date:
- Size: 30.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30bc5100be79ce04a2d59d2cedbba34b1416895af1bc251f3f0d1e44c7715c57 |
|
MD5 | 06301b8463629b5afe7050a96b2727bd |
|
BLAKE2b-256 | af7c9d4ce9cdc9c55d5f3e174d4a22538cfbd98836f9535c7de20e29b0017e92 |
File details
Details for the file edc_form_label-0.3.19-py3-none-any.whl
.
File metadata
- Download URL: edc_form_label-0.3.19-py3-none-any.whl
- Upload date:
- Size: 29.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d5cd519de5a9537f0c382664b77b0660db63afa14772d00025b1bb6f2d98246 |
|
MD5 | 1ebb06e3da64c9ab2ba6c0d394f5c0c3 |
|
BLAKE2b-256 | a24f84a19a1966f301def6e360eac1614e3336ae98a28a84951604e52fde4351 |