Exemplo n.º 1
0
def print_medication_stock_labels(modeladmin, request, queryset):
    zpl_data = []
    label = Label(
        label_template_name="medication_stock_label.lbl",
        static_files_path="edc_pharmacy/label_templates",
    )
    for obj in queryset:
        for i in range(1, obj.qty):
            stock_identifier = uuid4().hex
            context = dict(
                protocol=Protocol().protocol,
                protocol_title=Protocol().protocol_title,
                stock_identifier=stock_identifier,
                barcode_value=stock_identifier,
                medication_name=obj.medication_product.formulation.medication.display_name,
                medication_strength=obj.medication_product.formulation.strength,
                medication_units=obj.medication_product.formulation.units,
            )
            # keys = [k for k in context]
            # for fld in obj._meta.get_fields():
            #     if fld.name not in keys and fld.name != "assignment":
            #         context.update({fld.name: getattr(obj, fld.name)})
            zpl_data.append(
                str(label.render_as_zpl_data(copies=1, context=context, encoding=False))
                .strip("\n")
                .replace("\n", "")
            )
    request.session["zpl_data"] = "|".join(zpl_data)
    url = reverse("edc_label:browser_print_labels_url")
    return HttpResponseRedirect(url)
Exemplo n.º 2
0
 def setUp(self):
     site_consents.registry = {}
     self.study_open_datetime = Protocol().study_open_datetime
     self.study_close_datetime = Protocol().study_close_datetime
     site_visit_schedules._registry = {}
     site_visit_schedules.register(visit_schedule)
     self.subject_identifier = "12345"
     super().setUp()
Exemplo n.º 3
0
    def setUp(self):

        v1_consent = Consent(
            "visit_schedule_app.subjectconsent",
            version="1",
            start=Protocol().study_open_datetime,
            end=Protocol().study_close_datetime,
            age_min=18,
            age_is_adult=18,
            age_max=64,
            gender=[MALE, FEMALE],
        )

        import_holidays()
        site_consents.registry = {}
        site_consents.register(v1_consent)

        self.visit_schedule = VisitSchedule(
            name="visit_schedule",
            verbose_name="Visit Schedule",
            offstudy_model="visit_schedule_app.subjectoffstudy",
            death_report_model="visit_schedule_app.deathreport",
        )

        self.schedule = Schedule(
            name="schedule",
            onschedule_model="visit_schedule_app.onschedule",
            offschedule_model="visit_schedule_app.offschedule",
            appointment_model="edc_appointment.appointment",
            consent_model="visit_schedule_app.subjectconsent",
        )

        visit = Visit(
            code="1000",
            rbase=relativedelta(days=0),
            rlower=relativedelta(days=0),
            rupper=relativedelta(days=6),
            timepoint=1,
        )
        self.schedule.add_visit(visit)
        self.visit_schedule.add_schedule(self.schedule)
        site_visit_schedules._registry = {}
        site_visit_schedules.register(self.visit_schedule)

        site_reference_configs.registry = {}
        site_reference_configs.register_from_visit_schedule(visit_models={
            "edc_appointment.appointment":
            "visit_schedule_app.subjectvisit"
        })

        self.subject_consent = SubjectConsent.objects.create(
            subject_identifier="12345",
            consent_datetime=get_utcnow() - relativedelta(seconds=1),
            dob=date(1995, 1, 1),
            identity="11111",
            confirm_identity="11111",
        )
        self.subject_identifier = self.subject_consent.subject_identifier
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     self.subject_identifier = self.kwargs.get("subject_identifier")
     if self.subject_identifier:
         if not re.match(Protocol().subject_identifier_pattern,
                         self.subject_identifier):
             raise RegisteredSubjectError(
                 f"Invalid subject identifier format. "
                 f"Valid pattern is `{Protocol().subject_identifier_pattern}`. "
                 f"See `edc_protocol.Protocol().subject_identifier_pattern`. "
                 f"Got `{self.subject_identifier}`.")
         try:
             obj = RegisteredSubject.objects.get(
                 subject_identifier=self.subject_identifier)
         except ObjectDoesNotExist:
             raise RegisteredSubjectError(
                 f"Unknown subject identifier. "
                 f"Got `{self.subject_identifier}`.")
         context.update(
             subject_identifier=obj.subject_identifier,
             gender=obj.gender,
             dob=obj.dob,
             initials=obj.initials,
             identity=obj.identity,
             firstname=obj.first_name,
             lastname=obj.last_name,
             registered_subject=obj,
             registered_subject_pk=str(obj.pk),
         )
     return context
Exemplo n.º 5
0
 def label_context(self):
     tz = pytz.timezone(settings.TIME_ZONE)
     local = Arrow.fromdatetime(self.requisition.drawn_datetime
                                or self.requisition.created).to(tz)
     formatted_date = local.format("YYYY-MM-DD HH:mm")
     printed = "PRINTED: " if not self.requisition.drawn_datetime else "DRAWN: "
     drawn_datetime = f"{printed}{formatted_date}"
     try:
         clinician_initials = self.requisition.user_created[0:2].upper()
     except IndexError:
         clinician_initials = "??"
     return {
         "requisition_identifier": self.requisition.requisition_identifier,
         "item": self.item,
         "item_count": self.requisition.item_count or 1,
         "primary": "<P>",
         "barcode_value": self.requisition.requisition_identifier,
         "protocol": Protocol().protocol,
         "site": str(self.requisition.site.id),
         "site_name": str(self.requisition.site.name),
         "site_title": str(self.requisition.site.siteprofile.title),
         "clinician_initials": clinician_initials,
         "drawn_datetime": drawn_datetime,
         "subject_identifier": self.registered_subject.subject_identifier,
         "gender": self.registered_subject.gender,
         "dob": self.registered_subject.dob,
         "initials": self.registered_subject.initials,
         "identity": self.registered_subject.identity,
         "alpha_code": self.requisition.panel_object.alpha_code,
         "panel": self.requisition.panel_object.abbreviation,
         "panel_name": self.requisition.panel.display_name,
     }
    def __init__(
        self,
        identifier_type: Optional[str] = None,
        template: Optional[str] = None,
        device_id: Optional[str] = None,
        protocol_number: Optional[str] = None,
        site: Site = None,
        requesting_model: Optional[str] = None,
        identifier: Optional[str] = None,
    ) -> None:

        self._identifier = None
        self.requesting_model = requesting_model
        if not self.requesting_model:
            raise IdentifierError("Invalid requesting_model. Got None")
        self.identifier_type = identifier_type or self.identifier_type
        if not self.identifier_type:
            raise IdentifierError("Invalid identifier_type. Got None")
        self.template = template or self.template
        app_config = django_apps.get_app_config("edc_device")
        self.device_id = device_id or app_config.device_id
        self.protocol_number = protocol_number or Protocol().protocol_number
        self.site = site or Site.objects.get_current()
        if identifier:
            # load an existing identifier
            self.identifier_model = self.identifier_model_cls.objects.get(
                identifier=identifier
            )
            self._identifier = self.identifier_model.identifier
            self.subject_type = self.identifier_model.subject_type
            self.site = self.identifier_model.site
        self.get_identifier()
Exemplo n.º 7
0
    def get_template_options(self, instance=None, test_message=None, **kwargs):
        """Returns a dictionary of message template options.

        Extend using `extra_template_options`.
        """
        test_message = test_message or self.test_message
        template_options = dict(
            name=self.name,
            protocol_name=Protocol().protocol_name,
            display_name=self.get_display_name(instance=instance,
                                               test_message=test_message,
                                               **kwargs),
            email_from=self.email_from,
            test_subject_line=(self.email_test_subject_line
                               if test_message else "").strip(),
            test_body_line=self.email_test_body_line if test_message else "",
            test_line=self.sms_test_line if test_message else "",
            message_datetime=get_utcnow(),
            message_reference="",
        )
        if "subject_identifier" not in template_options:
            try:
                template_options.update(
                    subject_identifier=instance.subject_identifier)
            except AttributeError:
                pass
        if "site_name" not in template_options:
            try:
                template_options.update(
                    site_name=instance.site.name.replace("_", " ").title())
            except AttributeError:
                pass
        return template_options
 def get_protocol_number(self):
     """Returns the protocol number from the field or
     AppConfig.
     """
     protocol_number = self.protocol_number
     if not self.protocol_number:
         protocol_number = Protocol().protocol_number
     return protocol_number
Exemplo n.º 9
0
 def setUp(self):
     self.subject_identifier = "12345"
     site_visit_schedules._registry = {}
     site_visit_schedules.register(visit_schedule=visit_schedule3)
     self.helper = self.helper_cls(
         subject_identifier=self.subject_identifier,
         now=Protocol().study_open_datetime,
     )
Exemplo n.º 10
0
    def setUp(self):
        import_holidays()
        v1_consent = Consent(
            "visit_schedule_app.subjectconsent",
            version="1",
            start=Protocol().study_open_datetime,
            end=Protocol().study_close_datetime,
            age_min=18,
            age_is_adult=18,
            age_max=64,
            gender=[MALE, FEMALE],
        )
        site_consents.registry = {}
        site_consents.register(v1_consent)

        self.visit_schedule = VisitSchedule(
            name="visit_schedule",
            verbose_name="Visit Schedule",
            offstudy_model="visit_schedule_app.subjectoffstudy",
            death_report_model="visit_schedule_app.deathreport",
        )

        self.schedule = Schedule(
            name="schedule",
            onschedule_model="visit_schedule_app.onschedule",
            offschedule_model="visit_schedule_app.offschedule",
            appointment_model="edc_appointment.appointment",
            consent_model="visit_schedule_app.subjectconsent",
        )

        self.schedule2 = Schedule(
            name="schedule_two",
            onschedule_model="visit_schedule_app.onscheduletwo",
            offschedule_model="visit_schedule_app.offscheduletwo",
            appointment_model="edc_appointment.appointment",
            consent_model="visit_schedule_app.subjectconsent",
        )

        self.schedule3 = Schedule(
            name="schedule_three",
            onschedule_model="visit_schedule_app.onschedulethree",
            offschedule_model="visit_schedule_app.offschedulethree",
            appointment_model="edc_appointment.appointment",
            consent_model="visit_schedule_app.subjectconsent",
        )
Exemplo n.º 11
0
 def get_institution_extra_context(extra_context):
     protocol = Protocol()
     extra_context.update({
         "institution": protocol.institution,
         "copyright": protocol.copyright,
         "license": protocol.license or "",
         "disclaimer": protocol.disclaimer,
     })
     return extra_context
Exemplo n.º 12
0
 def setUp(self):
     super().setUp()
     v1_consent = Consent(
         "visit_schedule_app.subjectconsent",
         version="1",
         start=Protocol().study_open_datetime,
         end=Protocol().study_close_datetime,
         age_min=18,
         age_is_adult=18,
         age_max=64,
         gender=[MALE, FEMALE],
     )
     import_holidays()
     site_reference_configs.register_from_visit_schedule(visit_models={
         "edc_appointment.appointment":
         "visit_schedule_app.subjectvisit"
     })
     site_consents.registry = {}
     site_consents.register(v1_consent)
Exemplo n.º 13
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     protocol = Protocol()
     context.update({
         "protocol": protocol.protocol,
         "protocol_number": protocol.protocol_number,
         "protocol_name": protocol.protocol_name,
         "protocol_title": protocol.protocol_title,
     })
     return context
Exemplo n.º 14
0
 def label_context(self) -> dict:
     context = {
         "protocol": Protocol().protocol,
         "subject_identifier": self.registered_subject.subject_identifier,
         "gender": self.registered_subject.gender,
         "dob": self.registered_subject.dob,
         "initials": self.registered_subject.initials,
         "identity": self.registered_subject.identity,
     }
     context.update(self.site_context)
     return context
Exemplo n.º 15
0
 def setUp(self):
     super().setUp()
     site_consents.registry = {}
     self.study_open_datetime = Protocol().study_open_datetime
     self.study_close_datetime = Protocol().study_close_datetime
     consent_object_factory(start=self.study_open_datetime,
                            end=self.study_close_datetime)
     self.request = HttpRequest()
     user = User.objects.create(username="******")
     self.request.user = user
     for _ in range(3):
         first_name = fake.first_name()
         last_name = fake.last_name()
         initials = first_name[0] + choice(
             string.ascii_uppercase) + last_name[0]
         baker.make_recipe(
             "edc_consent.subjectconsent",
             consent_datetime=self.study_open_datetime +
             relativedelta(days=1),
             initials=initials.upper(),
         )
Exemplo n.º 16
0
 def setUp(self):
     site_visit_schedules.loaded = False
     site_visit_schedules._registry = {}
     site_visit_schedules.register(visit_schedule)
     site_reference_configs.register_from_visit_schedule(visit_models={
         "edc_appointment.appointment":
         "visit_schedule_app.subjectvisit"
     })
     v1_consent = Consent(
         "visit_schedule_app.subjectconsent",
         version="1",
         start=Protocol().study_open_datetime,
         end=Protocol().study_close_datetime,
         age_min=18,
         age_is_adult=18,
         age_max=64,
         gender=[MALE, FEMALE],
     )
     self.subject_identifier = "1234"
     site_consents.registry = {}
     site_consents.register(v1_consent)
Exemplo n.º 17
0
 def label_context(self):
     return {
         "barcode_value": self.model_obj.box_identifier,
         "box_identifier": self.model_obj.human_readable_identifier,
         "box_name": self.model_obj.name,
         "protocol": Protocol().protocol,
         "site": str(self.model_obj.site.id),
         "box_datetime": self.model_obj.box_datetime.strftime("%Y-%m-%d %H:%M"),
         "category": self.model_obj.get_category_display().upper(),
         "specimen_types": self.model_obj.specimen_types,
         "site_name": str(self.model_obj.site.siteprofile.title),
     }
Exemplo n.º 18
0
 def setUp(self):
     self.study_open_datetime = Protocol().study_open_datetime
     self.study_close_datetime = Protocol().study_close_datetime
     site_consents.registry = {}
     consent_factory(
         start=self.study_open_datetime,
         end=self.study_open_datetime + timedelta(days=50),
         version="1.0",
     )
     consent_factory(
         start=self.study_open_datetime + timedelta(days=51),
         end=self.study_open_datetime + timedelta(days=100),
         version="2.0",
     )
     consent_factory(
         start=self.study_open_datetime + timedelta(days=101),
         end=self.study_open_datetime + timedelta(days=150),
         version="3.0",
         updates_versions="1.0, 2.0",
     )
     self.dob = self.study_open_datetime - relativedelta(years=25)
Exemplo n.º 19
0
    def __init__(self,
                 page=None,
                 header_line=None,
                 filename=None,
                 request=None,
                 **kwargs):
        self._styles = None
        self.request = request
        self.page = page or self.default_page

        self.report_filename = filename or f"{uuid4()}.pdf"

        if not header_line:
            header_line = Protocol().institution
        self.header_line = header_line
class UrlRequestContextMixin(ContextMixin):

    urlconfig_getattr = "dashboard_urls"
    urlconfig_identifier_label = "subject_identifier"
    urlconfig_identifier_pattern = Protocol().subject_identifier_pattern
    urlconfig_label = None
    url_name = None

    @classmethod
    def get_urlname(cls):
        return cls.url_name

    @classmethod
    def urls(cls,
             namespace=None,
             label=None,
             identifier_label=None,
             identifier_pattern=None):
        label = (label or cls.urlconfig_label or convert_from_camel(
            cls.__name__.replace("view", "")).lower())
        urlconfig = UrlConfig(
            url_name=cls.get_urlname(),
            namespace=namespace,
            view_class=cls,
            label=label,
            identifier_label=identifier_label
            or cls.urlconfig_identifier_label,
            identifier_pattern=identifier_pattern
            or cls.urlconfig_identifier_pattern,
        )
        return getattr(urlconfig, cls.urlconfig_getattr)

    @staticmethod
    def add_url_to_context(new_key=None, existing_key=None, context=None):
        """Add a url as new_key to the context using the value
        of the existing_key from request.context_data.
        """
        try:
            context.update({new_key: url_names.get(existing_key)})
        except InvalidUrlName as e:
            raise UrlRequestContextError(
                f"Url name not defined in url_names. "
                f"Expected one of {url_names.registry}. Got {e}. "
                f"Hint: check if dashboard middleware is loaded.")
        return context
Exemplo n.º 21
0
 def extra_context(self):
     protocol = Protocol()
     try:
         live_system = settings.LIVE_SYSTEM
     except AttributeError:
         live_system = None
     return {
         "DEBUG": settings.DEBUG,
         "copyright": protocol.copyright,
         "disclaimer": protocol.disclaimer,
         "institution": protocol.institution,
         "license": protocol.license,
         "revision": site_revision.tag,
         "project_name": protocol.project_name,
         "live_system": live_system,
         "INDEX_PAGE": getattr(settings, "INDEX_PAGE", None),
         "INDEX_PAGE_LABEL": getattr(settings, "INDEX_PAGE_LABEL", None),
     }
Exemplo n.º 22
0
    def on_first_page(self, canvas, doc):
        super().on_first_page(canvas, doc)
        width, height = A4
        if self.draw_logo and self.logo:
            canvas.drawImage(self.logo,
                             35,
                             height - 50,
                             *self.logo_data["first_page"],
                             mask="auto")
        else:
            canvas.setFontSize(10)
            canvas.drawString(48, height - 40, Protocol().protocol_name)
        if self.confidential:
            canvas.setFontSize(10)
            canvas.drawString(48, height - 50, "CONFIDENTIAL")
            canvas.drawRightString(width - 35, height - 50, "CONFIDENTIAL")

        canvas.setFontSize(10)
        canvas.drawRightString(width - 35, height - 40, self.title)
Exemplo n.º 23
0
 def label_context(self):
     registered_subject = django_apps.get_model(
         self.registered_subject_model).objects.get(
             subject_identifier=self.requisition.subject_identifier)
     return {
         "aliquot_identifier":
         self.model_obj.human_readable_identifier,
         "aliquot_count":
         1 if self.model_obj.is_primary else self.model_obj.count,
         "children_count":
         1 if self.model_obj.is_primary else self.children_count,
         "primary":
         "<P>" if self.model_obj.is_primary else "",
         "barcode_value":
         self.model_obj.aliquot_identifier,
         "protocol":
         Protocol().protocol,
         "site":
         str(self.requisition.site.id),
         "site_name":
         str(self.requisition.site.name),
         "site_title":
         str(self.requisition.site.siteprofile.title),
         "clinician_initials":
         self.requisition.user_created[0:2].upper(),
         "drawn_datetime":
         self.requisition.drawn_datetime.strftime("%Y-%m-%d %H:%M"),
         "subject_identifier":
         registered_subject.subject_identifier,
         "gender":
         registered_subject.gender,
         "dob":
         registered_subject.dob.strftime("%Y-%m-%d"),
         "initials":
         registered_subject.initials,
         "alpha_code":
         self.model_obj.alpha_code,
         "panel":
         self.requisition.panel_object.abbreviation,
         "panel_name":
         self.requisition.panel.display_name,
     }
 def check_consent_period_within_study_period(new_consent=None):
     """Raises if the start or end date of the consent period
     it not within the opening and closing dates of the protocol.
     """
     protocol = Protocol()
     study_open_datetime = protocol.study_open_datetime
     study_close_datetime = protocol.study_close_datetime
     for index, dt in enumerate([new_consent.start, new_consent.end]):
         if not (study_open_datetime <= dt <= study_close_datetime):
             dt_label = "start" if index == 0 else "end"
             formatted_study_open_datetime = study_open_datetime.strftime(
                 convert_php_dateformat(settings.SHORT_DATE_FORMAT))
             formatted_study_close_datetime = study_close_datetime.strftime(
                 convert_php_dateformat(settings.SHORT_DATE_FORMAT))
             formatted_dt = dt.strftime(
                 convert_php_dateformat(settings.SHORT_DATE_FORMAT))
             raise ConsentPeriodError(
                 f"Invalid consent. Consent period for {new_consent.name} "
                 "must be within study opening/closing dates of "
                 f"{formatted_study_open_datetime} - "
                 f"{formatted_study_close_datetime}. "
                 f"Got {dt_label}={formatted_dt}.")
Exemplo n.º 25
0
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        try:
            edc_device_app_config = django_apps.get_app_config(
                self.edc_device_app)
        except LookupError as e:
            edc_device_app_config = None
            warnings.warn(str(e))

        live_system = getattr(settings, "LIVE_SYSTEM", "TEST")
        sentry_dsn = getattr(settings, "SENTRY_DSN", "sentry_dsn?")
        protocol = Protocol()
        context.update({
            "copyright":
            getattr(protocol, "copyright", "copyright?"),
            "device_id":
            getattr(edc_device_app_config, "device_id", "device_id?"),
            "device_role":
            getattr(edc_device_app_config, "device_role", "device_role?"),
            "disclaimer":
            getattr(protocol, "disclaimer", "disclaimer?"),
            "institution":
            getattr(protocol, "institution", "institution?"),
            "license":
            getattr(protocol, "license", "license?"),
            "project_name":
            getattr(protocol, "project_name", "project_name?"),
            "project_repo":
            getattr(protocol, "project_repo", "project_repo?"),
            "live_system":
            live_system,
            "sentry_dsn":
            sentry_dsn,
        })

        self.check_for_warning_messages(live_system=live_system)

        return context
Exemplo n.º 26
0
 def extra_context(self):
     protocol = Protocol()
     try:
         live_system = settings.LIVE_SYSTEM
     except AttributeError:
         live_system = None
     try:
         allow_password_reset = settings.ALLOW_PASSWORD_RESET
     except AttributeError:
         allow_password_reset = None
     return {
         "edc_base_template":
         get_template_path_with_bootstrap("edc_dashboard/base.html"),
         "DEBUG":
         settings.DEBUG,
         "ALLOW_PASSWORD_RESET":
         allow_password_reset,
         "copyright":
         protocol.copyright,
         "disclaimer":
         protocol.disclaimer,
         "institution":
         protocol.institution,
         "license":
         protocol.license,
         "revision":
         site_revision.tag,
         "project_name":
         protocol.project_name,
         "live_system":
         live_system,
         "INDEX_PAGE":
         getattr(settings, "INDEX_PAGE", None),
         "INDEX_PAGE_LABEL":
         getattr(settings, "INDEX_PAGE_LABEL", None),
     }
Exemplo n.º 27
0
from edc_consent.consent import Consent
from edc_consent.site_consents import site_consents
from edc_constants.constants import FEMALE, MALE
from edc_protocol import Protocol

v1 = Consent(
    "data_manager_app.subjectconsent",
    version="1",
    start=Protocol().study_open_datetime,
    end=Protocol().study_close_datetime,
    age_min=18,
    age_is_adult=18,
    age_max=110,
    gender=[MALE, FEMALE],
)

site_consents.register(v1)
Exemplo n.º 28
0
 def test_protocol(self):
     self.assertEqual(Protocol().study_open_datetime.date(), opendte.date())
     self.assertEqual(Protocol().study_close_datetime.date(),
                      closedte.date())
Exemplo n.º 29
0
    def __init__(
        self,
        username: str = None,
        first_name: str = None,
        last_name: str = None,
        job_title: str = None,
        email: str = None,
        alternate_email: str = None,
        mobile: str = None,
        site_names: List[str] = None,
        role_names: List[str] = None,
        is_active: bool = None,
        is_staff: bool = None,
        resource_name: str = None,
        created_email_template: Optional[Template] = None,
        updated_email_template: Optional[Template] = None,
        send_email_to_user: Optional[Any] = None,
        test_email_address: Optional[Any] = None,
        resend_as_new: Optional[Any] = None,
        nwords: Optional[int] = None,
        **kwargs,
    ):
        self._messages: List[str] = []
        self._user = None
        self.created = False
        self.password = None
        try:
            self.email, self.alternate_email = email.split(",")
        except (ValueError, AttributeError):
            self.email = email
            self.alternate_email = alternate_email
        self.first_name = first_name
        self.job_title = job_title or "staff member"
        self.last_name = last_name
        self.mobile = mobile
        self.is_active = is_active or False
        self.is_staff = is_staff or False
        self.password_generator = PasswordGenerator(nwords=nwords
                                                    or self.password_nwords,
                                                    **kwargs)
        self.resource_name = resource_name or self.resource_name
        self.resend_as_newly_created = resend_as_new
        self.test_email_address = test_email_address
        self.username = username or self.get_username()
        self.created_email_template = (created_email_template
                                       or self.created_email_template)
        self.updated_email_template = (updated_email_template
                                       or self.updated_email_template)
        self.validate_username()
        if ACCOUNT_MANAGER_ROLE in role_names:
            site_names = [s.name for s in Site.objects.all()]
        self.update_user_sites(site_names or [])
        self.update_user_roles(role_names or [STAFF_ROLE])
        self.user.save()
        self.user.userprofile.job_title = self.job_title
        self.user.userprofile.mobile = self.mobile
        self.user.userprofile.alternate_email = self.alternate_email
        self.user.userprofile.save()

        self.site_names = (
            "\n  - ".join([s.name for s in self.user.userprofile.sites.all()])
            or "(You have not been granted access to any sites)")
        self.role_names = "\n  - ".join(
            [g.display_name for g in self.user.userprofile.roles.all()])
        self.project_name = Protocol().protocol_name
        if send_email_to_user:
            try:
                self.email_message.send(fail_silently=False)
            except ConnectionRefusedError:
                print(self.email_message.body)
Exemplo n.º 30
0
from .patterns import screening_identifier
from .views import (
    AeListboardView,
    DeathReportListboardView,
    ScreeningListboardView,
    SubjectDashboardView,
    SubjectListboardView,
)

app_name = "meta_dashboard"

urlpatterns = SubjectListboardView.urls(
    namespace=app_name,
    label="subject_listboard",
    identifier_pattern=Protocol().subject_identifier_pattern,
)
urlpatterns += ScreeningListboardView.urls(
    namespace=app_name,
    label="screening_listboard",
    identifier_label="screening_identifier",
    identifier_pattern=screening_identifier,
)
urlpatterns += SubjectDashboardView.urls(
    namespace=app_name,
    label="subject_dashboard",
    identifier_pattern=Protocol().subject_identifier_pattern,
)

urlpatterns += SubjectReviewListboardView.urls(
    namespace=app_name,