Skip to main content

Customize Django form label in realtime in clinicedc/edc projects

Project description

pypi actions coverage

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

edc-form-label-0.3.11.tar.gz (30.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

edc_form_label-0.3.11-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file edc-form-label-0.3.11.tar.gz.

File metadata

  • Download URL: edc-form-label-0.3.11.tar.gz
  • Upload date:
  • Size: 30.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for edc-form-label-0.3.11.tar.gz
Algorithm Hash digest
SHA256 f8b61d036b40c9a641b391965398765eb343067be8a25d7793e187e7f071832c
MD5 f9ddf2a0cc0b17c22668c75231231457
BLAKE2b-256 c8cff2dbd6f4b6977a5b99d22522194a4c539c18d945d0858732184d8ff84570

See more details on using hashes here.

File details

Details for the file edc_form_label-0.3.11-py3-none-any.whl.

File metadata

File hashes

Hashes for edc_form_label-0.3.11-py3-none-any.whl
Algorithm Hash digest
SHA256 202f6b5fa47ab4ea68ac644730c2874724a61aefe1b808d19c968ad227dab58d
MD5 d6add13cbca723ef77ade980af72befe
BLAKE2b-256 1cb34be8d5d421747106ab6b08663b3bc8ab86ad34c82151b7a494e7cd615cf3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page