anbar permission
This commit is contained in:
1 parent
489fda27d3
commit
8d5665a1dc
4 files changed
+15
No files matched your search
@@ -20,8 +20,10 @@
|
|||||||
<div class="select is-fullwidth">
|
<div class="select is-fullwidth">
|
||||||
<select name="actionType" id="actionType" required>
|
<select name="actionType" id="actionType" required>
|
||||||
<option></option>
|
<option></option>
|
||||||
|
{% if not user|has_group:"khadamat" %}
|
||||||
<option value="vorod">ورود</option>
|
<option value="vorod">ورود</option>
|
||||||
<option value="khoroj">خروج</option>
|
<option value="khoroj">خروج</option>
|
||||||
|
{% endif %}
|
||||||
<option value="transfer">انتقال</option>
|
<option value="transfer">انتقال</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -93,8 +93,12 @@
|
|||||||
|
|
||||||
<td>
|
<td>
|
||||||
{% if perms.admin_panel.ViewStore or perms.admin_panel.OnlyAnbar %}
|
{% if perms.admin_panel.ViewStore or perms.admin_panel.OnlyAnbar %}
|
||||||
|
|
||||||
|
{% if not user|has_group:"khadamat" %}
|
||||||
<span class="Oedit_prd" style="cursor: pointer;"><img style="width: 20px; height: 20px;" src="{% static 'admin_panel/icons/edit.png' %}"></span>
|
<span class="Oedit_prd" style="cursor: pointer;"><img style="width: 20px; height: 20px;" src="{% static 'admin_panel/icons/edit.png' %}"></span>
|
||||||
<span class="delet_prd" style="cursor: pointer;"><img style="width: 20px; height: 20px;" src="{% static 'admin_panel/icons/delet.png' %}"></span>
|
<span class="delet_prd" style="cursor: pointer;"><img style="width: 20px; height: 20px;" src="{% static 'admin_panel/icons/delet.png' %}"></span>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<a href="{% url 'admin_panel:newOperation' s_id prd.id %}">
|
<a href="{% url 'admin_panel:newOperation' s_id prd.id %}">
|
||||||
<span><img style="width: 20px; height: 20px;" src="{% static 'admin_panel/icons/add.png' %}"></span>
|
<span><img style="width: 20px; height: 20px;" src="{% static 'admin_panel/icons/add.png' %}"></span>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -8,5 +8,8 @@ def toJalali(value):
|
|||||||
if(value):
|
if(value):
|
||||||
return JalaliDate(value).strftime("%Y/%m/%d")
|
return JalaliDate(value).strftime("%Y/%m/%d")
|
||||||
|
|
||||||
|
def has_group(user, group_name):
|
||||||
|
return user.groups.filter(name=group_name).exists()
|
||||||
|
|
||||||
|
register.filter('has_group', has_group)
|
||||||
register.filter('toJalali', toJalali)
|
register.filter('toJalali', toJalali)
|
||||||
@@ -1191,6 +1191,9 @@ def operation(request):
|
|||||||
if request.method != 'POST':
|
if request.method != 'POST':
|
||||||
return HttpResponseBadRequest("متد ارسالی نامعتبر است.")
|
return HttpResponseBadRequest("متد ارسالی نامعتبر است.")
|
||||||
|
|
||||||
|
user_op = request.user
|
||||||
|
user_store_room = get_object_or_404(StoreRoom, owners=user_op)
|
||||||
|
|
||||||
# استفاده از توابع امن اختصاصی پروژه برای جداسازی مقادیر عددی
|
# استفاده از توابع امن اختصاصی پروژه برای جداسازی مقادیر عددی
|
||||||
prd_id = _safe_int(request.POST.get('prd_id'))
|
prd_id = _safe_int(request.POST.get('prd_id'))
|
||||||
action_type = request.POST.get('actionType', '')
|
action_type = request.POST.get('actionType', '')
|
||||||
@@ -1234,6 +1237,9 @@ def operation(request):
|
|||||||
# بخش دوم: ورود و خروج دستی (کنترل مستقیم با Transaction و Lock)
|
# بخش دوم: ورود و خروج دستی (کنترل مستقیم با Transaction و Lock)
|
||||||
# =====================================================================
|
# =====================================================================
|
||||||
elif action_type in ['vorod', 'khoroj']:
|
elif action_type in ['vorod', 'khoroj']:
|
||||||
|
user_s_room = get_object_or_404(StoreRoom, owners=user_op)
|
||||||
|
if not user_op.is_superuser and s_room != user_s_room:
|
||||||
|
return HttpResponse("شما دسترسی ورود / خروج به این انبار ندارید")
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
# ساخت کوئری پایه برای دریافت تراکنشهای سال جاری کالا
|
# ساخت کوئری پایه برای دریافت تراکنشهای سال جاری کالا
|
||||||
qs = ProductInStore.objects.filter(
|
qs = ProductInStore.objects.filter(
|
||||||
|
|||||||
Reference in new issue
Block a user