def setUpClass(cls): super().setUpClass() ContentType.objects.clear_cache() clear_workflow_caches() get_or_create_user('*****@*****.**', is_superuser=True) settings.STORAGE_VAULT['dir'] = tempfile.mkdtemp() settings.EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend' settings.EMAIL_BACKEND_UNFILTERED = 'django.core.mail.backends.locmem.EmailBackend' settings.ETHICS_COMMISSION_UUID = 'ecececececececececececececececec' integration_bootstrap.create_settings_dirs() core_bootstrap.auth_groups() core_bootstrap.medical_categories() core_bootstrap.auth_user_testusers() core_bootstrap.advanced_settings() core_bootstrap.ethics_commissions() documents_bootstrap.document_types() documents_bootstrap.import_keys() documents_bootstrap.create_local_storage_vault() integration_bootstrap.workflow_sync() core_bootstrap.auth_groups() checklists_bootstrap.checklist_blueprints() core_bootstrap.submission_workflow()
def create_user(self, name, extra=None, profile_extra=None): extra = extra or {} profile_extra = profile_extra or {} user, created = get_or_create_user('{0}@example.com'.format(name), is_superuser=True, **extra) user.set_password('password') user.save() profile = user.profile for k, v in profile_extra.items(): setattr(profile, k, v) profile.save() return user
def _create_root_user(): root, _ = get_or_create_user('*****@*****.**') root.first_name = '' root.last_name = 'Ethik-Kommission' root.is_staff = True root.is_superuser = True root.set_unusable_password() # root (System) is not supposed to login root.save() profile = root.profile profile.forward_messages_after_minutes = 0 # Never forward messages profile.gender = 'x' profile.save()
def auth_user_developers(): ''' Developer Account Creation ''' from ecs.core.bootstrap_settings import developers for first, last, email, gender in developers: user, created = get_or_create_user(email) user.first_name = first user.last_name = last user.is_staff = False user.is_superuser = False user.save() user.profile.forward_messages_after_minutes = 30 user.profile.gender = gender user.profile.save()
def test_document_download_anyone(self): submission_form = create_submission_form() document_pk = submission_form.documents.get().pk user, created = get_or_create_user('*****@*****.**') user.set_password('password') user.save() self.client.logout() self.client.login(email='*****@*****.**', password='******') response = self.client.get( reverse('ecs.core.views.submissions.download_document', kwargs={ 'submission_form_pk': submission_form.pk, 'document_pk': document_pk })) self.assertEqual(response.status_code, 404)
def setUp(self): super().setUp() checklists_bootstrap.checklist_blueprints() bootstrap.ethics_commissions() VALID_SUBMISSION_FORM_DATA['investigator-0-ethics_commission'] = [ str(EthicsCommission.objects.all()[0].pk) ] VALID_SUBMISSION_FORM_DATA['investigator-1-ethics_commission'] = [ str(EthicsCommission.objects.all()[0].pk) ] self.office_user, created = get_or_create_user( '*****@*****.**') self.office_user.set_password('password') self.office_user.save() office_group = Group.objects.get(name='EC-Office') self.office_user.groups.add(office_group) profile = self.office_user.profile profile.is_internal = True profile.save()
def create_submission_form(ec_number=None, presenter=None): presenter = presenter or get_or_create_user( '*****@*****.**')[0] sub = Submission(ec_number=ec_number, presenter=presenter, susar_presenter=presenter) sub.save() sform = SubmissionForm.objects.create( submission=sub, project_title="High Risk Test Study", eudract_number="2010-002323-99", sponsor_name="testsponsor", sponsor_address="mainstreet 1", sponsor_zip_code="2323", sponsor_city="Wien", sponsor_phone="+4309876543456789", sponsor_fax="+430987654345678", sponsor_email="*****@*****.**", invoice_name="", invoice_address="", invoice_zip_code="", invoice_city="", invoice_phone="", invoice_fax="", invoice_email="", invoice_uid="", project_type_non_reg_drug=True, project_type_reg_drug=False, project_type_reg_drug_within_indication=False, project_type_reg_drug_not_within_indication=False, project_type_medical_method=False, project_type_medical_device=False, project_type_medical_device_with_ce=False, project_type_medical_device_without_ce=False, project_type_medical_device_performance_evaluation=False, project_type_basic_research=False, project_type_genetic_study=False, project_type_register=False, project_type_biobank=False, project_type_retrospective=False, project_type_questionnaire=False, project_type_education_context=None, project_type_misc=None, specialism="Pädiatrische Onkologie / Immunologie", pharma_checked_substance="", pharma_reference_substance="", medtech_checked_product="", medtech_reference_substance="", clinical_phase="III", already_voted=True, subject_count=175, subject_minage=0, subject_maxage=21, subject_noncompetents=True, subject_males=True, subject_females=True, subject_childbearing=True, subject_duration="48 months", subject_duration_active="12 months", subject_duration_controls="36 months", subject_planned_total_duration="99", substance_preexisting_clinical_tries=True, substance_p_c_t_phase="III", substance_p_c_t_period="to long", substance_p_c_t_application_type="IV in children", substance_p_c_t_gcp_rules=True, substance_p_c_t_final_report=True, medtech_product_name="", medtech_manufacturer="", medtech_certified_for_exact_indications=False, medtech_certified_for_other_indications=False, medtech_ce_symbol=False, medtech_manual_included=False, medtech_technical_safety_regulations="", medtech_departure_from_regulations="", insurance_name="Insurance", insurance_address="insurancestreet 1", insurance_phone="+43123456", insurance_contract_number="", insurance_validity="", additional_therapy_info="long blabla", german_project_title="bla bla bla", german_summary="bla bla bla", german_preclinical_results="bla bla bla", german_primary_hypothesis="bla bla bla", german_inclusion_exclusion_crit="bla bla bla", german_ethical_info="bla bla bla", german_protected_subjects_info="bla bla bla", german_recruitment_info="bla bla bla", german_consent_info="bla bla bla", german_risks_info="bla bla bla", german_benefits_info="bla bla bla", german_relationship_info="bla bla bla", german_concurrent_study_info="bla bla bla", german_sideeffects_info="bla bla bla", german_statistical_info="bla bla bla", german_dataprotection_info="bla bla bla", german_aftercare_info="bla bla bla", german_payment_info="bla bla bla", german_abort_info="bla bla bla", german_dataaccess_info="bla bla bla", german_financing_info="bla bla bla", german_additional_info="bla bla bla", study_plan_blind=0, study_plan_observer_blinded=False, study_plan_randomized=True, study_plan_parallelgroups=True, study_plan_controlled=True, study_plan_cross_over=False, study_plan_placebo=False, study_plan_factorized=False, study_plan_pilot_project=False, study_plan_equivalence_testing=False, study_plan_misc=None, study_plan_number_of_groups= "two sequential randomisations, each with 2 arms", study_plan_stratification="Age, Stage, National Groups", study_plan_sample_frequency=None, study_plan_primary_objectives="Event Free Survival", study_plan_null_hypothesis=False, study_plan_alternative_hypothesis="my thesis", study_plan_secondary_objectives="secondary objective", study_plan_alpha="0.03", study_plan_power="0.75", study_plan_statalgorithm="blabla", study_plan_multiple_test_correction_algorithm="", study_plan_dropout_ratio="0", study_plan_population_intention_to_treat=True, study_plan_population_per_protocol=False, study_plan_abort_crit="Peto", study_plan_planned_statalgorithm="log rank test", study_plan_dataquality_checking="None", study_plan_datamanagement="Datamanagement", study_plan_biometric_planning="Mag. rer.soc.oec. Jane Doe", study_plan_statistics_implementation= "Mag. rer.soc.oec. Jane Doe / Statistikerin", #study_plan_dataprotection_anonalgoritm="Electronically generated unique patient number within SIOPEN-R-Net", study_plan_dataprotection_anonalgoritm="to long", study_plan_dataprotection_dvr="", study_plan_dataprotection_reason="", submitter_contact_gender="f", submitter_contact_first_name="Jane", submitter_contact_title="Univ. Doz. Dr.", submitter_contact_last_name="Doe", submitter_organisation="Organisation", submitter_jobtitle="jobtitle", submitter_is_coordinator=True, submitter_is_main_investigator=False, submitter_is_sponsor=False, submitter_is_authorized_by_sponsor=False, substance_registered_in_countries=[], substance_p_c_t_countries=['AT', 'DE', 'US'], presenter=presenter, ) with open(TEST_PDF, 'rb') as f: attach_document(sform, f, 'protocol.pdf', 'protocol') ek1 = EthicsCommission(name='EK von Neverland') ek1.save() Investigator.objects.create(submission_form=sform, main=True, contact_last_name="Univ. Doz. Dr. Joseph doe", subject_count=1, ethics_commission=ek1) sform.render_pdf_document() return sform
def auth_user_testusers(): ''' Test User Creation, target to userswitcher''' testusers = ( ('presenter', None), ('sponsor', None), ('investigator', None), ('office', 'EC-Office'), ('executive', 'EC-Executive'), ('signing', 'EC-Signing'), ('signing_fail', 'EC-Signing'), ('signing_mock', 'EC-Signing'), ('statistic.rev', 'Statistic Reviewer'), ('insurance.rev', 'Insurance Reviewer'), ('external.reviewer', None), ('gcp.reviewer', 'GCP Reviewer'), ('ext.rev', 'External Reviewer'), ) boardtestusers = ( ('b.member1.klph', ('KlPh', )), ('b.member2.radio.klph', ( 'Radio', 'KlPh', )), ('b.member3.anaesth', ('Anästh', )), ('b.member4.chir', ('Chir', )), ('b.member5.nephro', ('Nephro', )), ('b.member6.psychol', ('Psychol', )), ('b.member7.gastro', ('Gastro', )), ('b.member8.neuro', ('Neuro', )), ('b.member9.angio', ('Angio', )), ) userswitcher_group = Group.objects.get(name='Userswitcher Target') boardmember_group = Group.objects.get(name='Board Member') specialist_group = Group.objects.get(name='Specialist') for testuser, group in testusers: for number in range(1, 4): user, created = get_or_create_user('{0}{1}@example.org'.format( testuser, number)) if group: group = Group.objects.get(name=group) user.groups.add(group) if group.name in ('EC-Executive', 'EC-Office', 'EC-Signing'): uids = set(user.profile.task_uids) uids.update( group.task_types.values_list('workflow_node__uid', flat=True).distinct()) user.profile.task_uids = list(uids) user.groups.add(userswitcher_group) user.profile.is_testuser = True user.profile.update_flags() user.profile.save() for testuser, medcategories in boardtestusers: user, created = get_or_create_user('{0}@example.org'.format(testuser)) user.groups.add(boardmember_group) user.groups.add(specialist_group) user.groups.add(userswitcher_group) user.profile.is_testuser = True user.profile.update_flags() user.profile.save() for medcategory in medcategories: m = MedicalCategory.objects.get(abbrev=medcategory) m.users.add(user)