Add contractor manager role.
This commit is contained in:
parent
9cadf4eed5
commit
5971860c4f
7 changed files with 15 additions and 6 deletions
|
|
@ -45,6 +45,10 @@ class Command(BaseCommand):
|
||||||
"name": "ستاد آبمنطقهای",
|
"name": "ستاد آبمنطقهای",
|
||||||
"slug": UserRoles.HEADQUARTER,
|
"slug": UserRoles.HEADQUARTER,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "مدیر پیمانکار",
|
||||||
|
"slug": UserRoles.CONTRACTOR_MANAGER,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
for role in roles:
|
for role in roles:
|
||||||
|
|
|
||||||
|
|
@ -58,3 +58,7 @@ def is_headquarter(user):
|
||||||
def is_customer(user):
|
def is_customer(user):
|
||||||
return _has_profile(user) and user.profile.has_role(UserRoles.CUSTOMER)
|
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)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ class UserRoles(Enum):
|
||||||
REGIONAL_WATER_AUTHORITY = "rwa" # کارشناس امور
|
REGIONAL_WATER_AUTHORITY = "rwa" # کارشناس امور
|
||||||
WATER_RESOURCE_MANAGER = "wrm" # مدیر منابع آب
|
WATER_RESOURCE_MANAGER = "wrm" # مدیر منابع آب
|
||||||
HEADQUARTER = "hdq" # ستاد آب منطقهای
|
HEADQUARTER = "hdq" # ستاد آب منطقهای
|
||||||
|
CONTRACTOR_MANAGER = "cmn" # مدیر پیمانکار
|
||||||
|
|
||||||
|
|
||||||
USER_TYPE_CHOICES = [
|
USER_TYPE_CHOICES = [
|
||||||
|
|
|
||||||
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
|
|
@ -30,7 +30,7 @@ def installation_assign_step(request, instance_id, step_id):
|
||||||
profile = getattr(request.user, 'profile', None)
|
profile = getattr(request.user, 'profile', None)
|
||||||
is_manager = False
|
is_manager = False
|
||||||
try:
|
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:
|
except Exception:
|
||||||
is_manager = False
|
is_manager = False
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
{% 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 %}
|
||||||
<div class="col-sm-6 col-md-3">
|
<div class="col-sm-6 col-md-3">
|
||||||
<label class="form-label">امور</label>
|
<label class="form-label">امور</label>
|
||||||
<select class="form-select" name="affairs">
|
<select class="form-select" name="affairs">
|
||||||
|
|
@ -166,7 +166,7 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% 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 %}
|
||||||
<div class="col-sm-6 col-md-3">
|
<div class="col-sm-6 col-md-3">
|
||||||
<label class="form-label">کارگزار</label>
|
<label class="form-label">کارگزار</label>
|
||||||
<select class="form-select" name="broker">
|
<select class="form-select" name="broker">
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ def scope_instances_queryset(user, queryset=None):
|
||||||
return qs.filter(id__in=assign_ids)
|
return qs.filter(id__in=assign_ids)
|
||||||
if profile.has_role(UserRoles.BROKER):
|
if profile.has_role(UserRoles.BROKER):
|
||||||
return qs.filter(broker=profile.broker)
|
return qs.filter(broker=profile.broker)
|
||||||
if profile.has_role(UserRoles.ACCOUNTANT) or profile.has_role(UserRoles.MANAGER) or profile.has_role(UserRoles.WATER_RESOURCE_MANAGER):
|
if profile.has_role(UserRoles.ACCOUNTANT) or profile.has_role(UserRoles.MANAGER) or profile.has_role(UserRoles.WATER_RESOURCE_MANAGER) or profile.has_role(UserRoles.CONTRACTOR_MANAGER):
|
||||||
return qs.filter(broker__affairs__county__city=profile.county.city)
|
return qs.filter(broker__affairs__county__city=profile.county.city)
|
||||||
if profile.has_role(UserRoles.ADMIN):
|
if profile.has_role(UserRoles.ADMIN):
|
||||||
return qs
|
return qs
|
||||||
|
|
@ -69,7 +69,7 @@ def scope_wells_queryset(user, queryset=None):
|
||||||
return qs
|
return qs
|
||||||
if profile.has_role(UserRoles.BROKER):
|
if profile.has_role(UserRoles.BROKER):
|
||||||
return qs.filter(broker=profile.broker)
|
return qs.filter(broker=profile.broker)
|
||||||
if profile.has_role(UserRoles.ACCOUNTANT) or profile.has_role(UserRoles.MANAGER) or profile.has_role(UserRoles.WATER_RESOURCE_MANAGER):
|
if profile.has_role(UserRoles.ACCOUNTANT) or profile.has_role(UserRoles.MANAGER) or profile.has_role(UserRoles.WATER_RESOURCE_MANAGER) or profile.has_role(UserRoles.CONTRACTOR_MANAGER):
|
||||||
return qs.filter(broker__affairs__county__city=profile.county.city)
|
return qs.filter(broker__affairs__county__city=profile.county.city)
|
||||||
if profile.has_role(UserRoles.INSTALLER):
|
if profile.has_role(UserRoles.INSTALLER):
|
||||||
# Wells that have instances assigned to this installer
|
# Wells that have instances assigned to this installer
|
||||||
|
|
@ -102,7 +102,7 @@ def scope_customers_queryset(user, queryset=None):
|
||||||
return qs
|
return qs
|
||||||
if profile.has_role(UserRoles.BROKER):
|
if profile.has_role(UserRoles.BROKER):
|
||||||
return qs.filter(broker=profile.broker)
|
return qs.filter(broker=profile.broker)
|
||||||
if profile.has_role(UserRoles.ACCOUNTANT) or profile.has_role(UserRoles.MANAGER) or profile.has_role(UserRoles.WATER_RESOURCE_MANAGER):
|
if profile.has_role(UserRoles.ACCOUNTANT) or profile.has_role(UserRoles.MANAGER) or profile.has_role(UserRoles.WATER_RESOURCE_MANAGER) or profile.has_role(UserRoles.CONTRACTOR_MANAGER):
|
||||||
return qs.filter(county__city=profile.county.city)
|
return qs.filter(county__city=profile.county.city)
|
||||||
if profile.has_role(UserRoles.INSTALLER):
|
if profile.has_role(UserRoles.INSTALLER):
|
||||||
# Customers that are representatives of instances assigned to this installer
|
# Customers that are representatives of instances assigned to this installer
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue