def test_add_group_with_callable(self): def codenames_callable(): return [ "edc_auth.add_subjectrequisition", "edc_auth.change_subjectrequisition", "edc_auth.delete_subjectrequisition", "edc_auth.view_subjectrequisition", ] codenames = [ "edc_auth.add_testmodel", "edc_auth.change_testmodel", "edc_auth.delete_testmodel", "edc_auth.view_testmodel", ] codenames_with_callable = copy(codenames) codenames_with_callable.append(codenames_callable) site_auths.clear() site_auths.add_group(*codenames_with_callable, name="GROUP") AuthUpdater() group = Group.objects.get(name="GROUP") codenames.extend(codenames_callable()) codenames.sort() self.assertEqual( [ p.codename for p in group.permissions.filter( content_type__app_label="edc_auth").order_by("codename") ], [c.split(".")[1] for c in codenames], )
def test_add_group_convert_to_export_with_callable(self): def more_codenames(): return [ "edc_auth.add_subjectrequisition", "edc_auth.change_subjectrequisition", "edc_auth.delete_subjectrequisition", "edc_auth.view_subjectrequisition", ] codenames = [ "edc_auth.add_testmodel", "edc_auth.change_testmodel", "edc_auth.delete_testmodel", "edc_auth.view_testmodel", more_codenames, ] site_auths.clear() site_auths.add_group(*codenames, name="GROUP_EXPORT", convert_to_export=True) AuthUpdater() group = Group.objects.get(name="GROUP_EXPORT") self.assertEqual( [ p.codename for p in group.permissions.filter( content_type__app_label="edc_auth") ], ["export_subjectrequisition", "export_testmodel"], )
def setUpTestData(cls): url_names.register("dashboard_url", "dashboard_url", "edc_dashboard") site_auths.clear() site_auths.add_group("edc_dashboard.view_my_listboard", name=CLINIC) site_auths.add_custom_permissions_tuples( model="edc_dashboard.dashboard", codename_tuples=(("edc_dashboard.view_my_listboard", "View my listboard"), ), ) AuthUpdater(verbose=False, warn_only=True) return super().setUpTestData()
def test_add_group(self): codenames = [ "edc_auth.add_testmodel", "edc_auth.change_testmodel", "edc_auth.delete_testmodel", "edc_auth.view_testmodel", ] site_auths.clear() site_auths.add_group(*codenames, name="GROUP") AuthUpdater() group = Group.objects.get(name="GROUP") self.assertEqual( [ p.codename for p in group.permissions.filter( content_type__app_label="edc_auth") ], [c.split(".")[1] for c in codenames], )
def test_add_group_view_only(self): codenames = [ "edc_auth.add_testmodel", "edc_auth.change_testmodel", "edc_auth.delete_testmodel", "edc_auth.view_testmodel", ] site_auths.clear() site_auths.add_group(*codenames, name="GROUP_VIEW_ONLY", view_only=True) AuthUpdater() group = Group.objects.get(name="GROUP_VIEW_ONLY") self.assertEqual( [ p.codename for p in group.permissions.filter( content_type__app_label="edc_auth") ], ["view_testmodel"], )
def test_add_group_remove_delete_with_callable(self): def more_codenames(): return [ "edc_auth.add_subjectrequisition", "edc_auth.change_subjectrequisition", "edc_auth.delete_subjectrequisition", "edc_auth.view_subjectrequisition", ] codenames = [ "edc_auth.add_testmodel", "edc_auth.change_testmodel", "edc_auth.delete_testmodel", "edc_auth.view_testmodel", more_codenames, ] site_auths.clear() site_auths.add_group(*codenames, name="GROUP_NO_DELETE", no_delete=True) AuthUpdater() group = Group.objects.get(name="GROUP_NO_DELETE") codenames = [ "add_subjectrequisition", "add_testmodel", "change_subjectrequisition", "change_testmodel", "view_subjectrequisition", "view_testmodel", ] self.assertEqual( [ p.codename for p in group.permissions.filter( content_type__app_label="edc_auth").order_by("codename") ], codenames, )
from edc_auth.site_auths import site_auths from .auth_objects import APPOINTMENT, APPOINTMENT_EXPORT, APPOINTMENT_VIEW site_auths.add_group( "edc_appointment.view_appointment", "edc_appointment.view_historicalappointment", name=APPOINTMENT_VIEW, ) site_auths.add_group( "edc_appointment.add_appointment", "edc_appointment.change_appointment", "edc_appointment.view_appointment", "edc_appointment.view_historicalappointment", name=APPOINTMENT, ) site_auths.add_group( "edc_appointment.export_appointment", name=APPOINTMENT_EXPORT, )
from edc_auth.site_auths import site_auths from .auth_objects import ( ACTION_ITEM, ACTION_ITEM_EXPORT, ACTION_ITEM_VIEW_ONLY, action_items_codenames, navbar_tuples, ) site_auths.add_group(*action_items_codenames, name=ACTION_ITEM) site_auths.add_group(*action_items_codenames, name=ACTION_ITEM_VIEW_ONLY, view_only=True) # site_auths.add_group(*action_items_codenames, name=ACTION_ITEM_EXPORT, # convert_to_export=True) site_auths.add_custom_permissions_tuples(model="edc_navbar.navbar", codename_tuples=navbar_tuples) site_auths.add_custom_permissions_tuples( model="edc_action_item.historicalactionitem", codename_tuples=[ ( "edc_action_item.export_historicalactionitem", "Cane export historicalactionitem", ), ( "edc_action_item.export_historicalreference", "Cane export historicalreference", ),
from edc_auth.site_auths import site_auths from .auth_objects import ( PHARMACIST_ROLE, PHARMACY, PHARMACY_VIEW, SITE_PHARMACIST_ROLE, pharmacy_codenames, ) site_auths.add_group(*pharmacy_codenames, name=PHARMACY_VIEW, view_only=True) site_auths.add_group(*pharmacy_codenames, name=PHARMACY, no_delete=False) site_auths.add_role(PHARMACY, name=PHARMACIST_ROLE) site_auths.add_role(PHARMACY, name=SITE_PHARMACIST_ROLE)
from edc_auth.auth_objects import ( AUDITOR_ROLE, CLINICIAN_ROLE, CLINICIAN_SUPER_ROLE, NURSE_ROLE, ) from edc_auth.site_auths import site_auths from .auth_objects import OFFSTUDY, OFFSTUDY_SUPER, OFFSTUDY_VIEW, codenames site_auths.add_group(*codenames, name=OFFSTUDY, no_delete=True) site_auths.add_group(*codenames, name=OFFSTUDY_SUPER) site_auths.add_group(*codenames, name=OFFSTUDY_VIEW, view_only=True) site_auths.update_role(OFFSTUDY, name=CLINICIAN_ROLE) site_auths.update_role(OFFSTUDY, name=NURSE_ROLE) site_auths.update_role(OFFSTUDY_SUPER, name=CLINICIAN_SUPER_ROLE) site_auths.update_role(OFFSTUDY_VIEW, name=AUDITOR_ROLE)
NURSE_ROLE, PII_VIEW, ) from edc_auth.site_auths import site_auths from edc_data_manager.auth_objects import DATA_MANAGER_ROLE from edc_export.auth_objects import EXPORT from .auth_objects import ( LAB, LAB_TECHNICIAN_ROLE, LAB_VIEW, lab_codenames, lab_view_codenames, ) site_auths.add_group(*lab_codenames, name=LAB) site_auths.add_group(*lab_view_codenames, name=LAB_VIEW) site_auths.update_group( "edc_lab.export_aliquot", "edc_lab.export_box", "edc_lab.export_boxitem", "edc_lab.export_boxtype", "edc_lab.export_order", "edc_lab.export_panel", "edc_lab.export_result", "edc_lab.export_resultitem", name=EXPORT, ) site_auths.add_role(ADMINISTRATION, EVERYONE,
AE_REVIEW, AE_ROLE, AE_SUPER, TMG, TMG_REVIEW, TMG_ROLE, ae_codenames, ae_dashboard_tuples, ae_navbar_tuples, tmg_codenames, tmg_dashboard_tuples, tmg_navbar_tuples, ) # groups site_auths.add_group(*ae_codenames, name=AE, no_delete=True) site_auths.update_group(*[c[0] for c in ae_dashboard_tuples], *[c[0] for c in ae_navbar_tuples], name=AE) site_auths.add_group(*ae_codenames, name=AE_SUPER) site_auths.update_group(*[c[0] for c in ae_dashboard_tuples], *[c[0] for c in ae_navbar_tuples], name=AE_SUPER) site_auths.add_group(*ae_codenames, name=AE_REVIEW, view_only=True) site_auths.update_group(*[c[0] for c in ae_dashboard_tuples], *[c[0] for c in ae_navbar_tuples], name=AE_REVIEW) site_auths.add_group(*tmg_codenames, name=TMG)
from edc_auth.site_auths import site_auths from .auth_objects import LABELING, codenames site_auths.add_group(*codenames, name=LABELING, no_delete=False)
from edc_auth.site_auths import site_auths from .auth_objects import DATA_EXPORTER_ROLE, EXPORT, export_codenames site_auths.add_group(*export_codenames, name=EXPORT) site_auths.add_role(EXPORT, name=DATA_EXPORTER_ROLE)
) from edc_auth.site_auths import site_auths from .auth_objects import ( DATA_MANAGER, DATA_MANAGER_EXPORT, DATA_MANAGER_ROLE, DATA_QUERY, DATA_QUERY_VIEW, SITE_DATA_MANAGER_ROLE, data_manager, data_query, ) # groups site_auths.add_group(*data_manager, name=DATA_MANAGER) site_auths.add_group(*data_manager, name=DATA_QUERY_VIEW, view_only=True) site_auths.add_group(*data_manager, name=DATA_QUERY, view_only=True) site_auths.update_group("edc_data_manager.change_dataquery", name=DATA_QUERY) site_auths.add_group( "edc_data_manager.export_datadictionary", "edc_data_manager.export_dataquery", "edc_data_manager.export_queryrule", name=DATA_MANAGER_EXPORT, ) # roles site_auths.add_role(CELERY_MANAGER, DATA_MANAGER, name=DATA_MANAGER_ROLE) site_auths.add_role(DATA_QUERY, name=SITE_DATA_MANAGER_ROLE) site_auths.update_role(DATA_QUERY, name=CLINICIAN_ROLE) site_auths.update_role(DATA_QUERY, name=NURSE_ROLE)