diff --git a/accounts/management/commands/create_roles.py b/accounts/management/commands/create_roles.py index 92f57c0..cb1305a 100644 --- a/accounts/management/commands/create_roles.py +++ b/accounts/management/commands/create_roles.py @@ -45,6 +45,10 @@ class Command(BaseCommand): "name": "ستاد آبمنطقهای", "slug": UserRoles.HEADQUARTER, }, + { + "name": "مدیر پیمانکار", + "slug": UserRoles.CONTRACTOR_MANAGER, + }, ] for role in roles: diff --git a/accounts/templatetags/accounts_tags.py b/accounts/templatetags/accounts_tags.py index e2aec6b..7b3831e 100644 --- a/accounts/templatetags/accounts_tags.py +++ b/accounts/templatetags/accounts_tags.py @@ -58,3 +58,7 @@ def is_headquarter(user): def is_customer(user): return _has_profile(user) and user.profile.has_role(UserRoles.CUSTOMER) +@register.filter +def is_contractor_manager(user): + return _has_profile(user) and user.profile.has_role(UserRoles.CONTRACTOR_MANAGER) + diff --git a/common/consts.py b/common/consts.py index c367ad3..37b4258 100644 --- a/common/consts.py +++ b/common/consts.py @@ -11,6 +11,7 @@ class UserRoles(Enum): REGIONAL_WATER_AUTHORITY = "rwa" # کارشناس امور WATER_RESOURCE_MANAGER = "wrm" # مدیر منابع آب HEADQUARTER = "hdq" # ستاد آب منطقهای + CONTRACTOR_MANAGER = "cmn" # مدیر پیمانکار USER_TYPE_CHOICES = [ diff --git a/db.sqlite3 b/db.sqlite3 index b5fffe0..54bffa7 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/installations/views.py b/installations/views.py index ea73453..02325ba 100644 --- a/installations/views.py +++ b/installations/views.py @@ -30,7 +30,7 @@ def installation_assign_step(request, instance_id, step_id): profile = getattr(request.user, 'profile', None) is_manager = False try: - is_manager = bool(profile and profile.has_role(UserRoles.MANAGER)) + is_manager = bool(profile and profile.has_role(UserRoles.MANAGER)) or bool(profile and profile.has_role(UserRoles.CONTRACTOR_MANAGER)) except Exception: is_manager = False diff --git a/processes/templates/processes/request_list.html b/processes/templates/processes/request_list.html index 1ae210a..5549f07 100644 --- a/processes/templates/processes/request_list.html +++ b/processes/templates/processes/request_list.html @@ -155,7 +155,7 @@ {% endfor %} - {% if request.user|is_admin or request.user|is_manager or request.user|is_accountant %} + {% if request.user|is_admin or request.user|is_manager or request.user|is_accountant or request.user|is_contractor_manager %}