Skip to content
Snippets Groups Projects
Commit 6ca347b1 authored by Carlos Vega's avatar Carlos Vega
Browse files

added method add_permissions_to_worker to functions for Issue #31 tests

parent 7f20ff18
No related branches found
No related tags found
1 merge request!192Feature/add way to change password and PERMISSIONS
......@@ -13,6 +13,7 @@ from web.models.constants import REDCAP_TOKEN_CONFIGURATION_TYPE, REDCAP_BASE_UR
from web.models.worker_study_role import ROLE_CHOICES_DOCTOR, WORKER_VOUCHER_PARTNER
from web.redcap_connector import RedcapSubject
from web.views.notifications import get_today_midnight_date
from django.contrib.auth.models import Permission
logger = logging.getLogger(__name__)
......@@ -238,6 +239,11 @@ def create_user(username=None, password=None):
create_worker(user)
return user
def add_permissions_to_worker(worker, codenames):
roles = WorkerStudyRole.objects.filter(worker=worker, study_id=GLOBAL_STUDY_ID)
perms = Permission.objects.filter(codename__in=codenames).all()
roles[0].permissions.set(perms)
roles[0].save()
def create_worker(user=None, with_test_location=False):
worker = Worker.objects.create(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment