Подправил фильтр цехов на странице реестра
All checks were successful
Deploy MES Core / deploy (push) Successful in 11s
All checks were successful
Deploy MES Core / deploy (push) Successful in 11s
This commit is contained in:
@@ -513,12 +513,7 @@ class RegistryView(LoginRequiredMixin, ListView):
|
|||||||
|
|
||||||
m_ids = [int(i) for i in self.request.GET.getlist('m_ids') if str(i).isdigit()]
|
m_ids = [int(i) for i in self.request.GET.getlist('m_ids') if str(i).isdigit()]
|
||||||
if m_ids:
|
if m_ids:
|
||||||
ws_ids = list(
|
work_qs = work_qs.filter(Q(machine_id__in=m_ids) | Q(machine_id__isnull=True))
|
||||||
Machine.objects.filter(id__in=m_ids)
|
|
||||||
.exclude(workshop_id__isnull=True)
|
|
||||||
.values_list('workshop_id', flat=True)
|
|
||||||
)
|
|
||||||
work_qs = work_qs.filter(Q(machine_id__in=m_ids) | Q(machine_id__isnull=True, workshop_id__in=ws_ids))
|
|
||||||
|
|
||||||
filtered = self.request.GET.get('filtered')
|
filtered = self.request.GET.get('filtered')
|
||||||
reset = self.request.GET.get('reset')
|
reset = self.request.GET.get('reset')
|
||||||
@@ -553,12 +548,16 @@ class RegistryView(LoginRequiredMixin, ListView):
|
|||||||
work_qs = work_qs.filter(status__in=expanded)
|
work_qs = work_qs.filter(status__in=expanded)
|
||||||
|
|
||||||
if role == 'operator':
|
if role == 'operator':
|
||||||
|
allowed_ws = list(profile.allowed_workshops.values_list('id', flat=True)) if profile else []
|
||||||
|
if allowed_ws:
|
||||||
|
work_qs = work_qs.filter(Q(workshop_id__in=allowed_ws) | Q(machine__workshop_id__in=allowed_ws))
|
||||||
|
else:
|
||||||
user_machines = profile.machines.all() if profile else Machine.objects.none()
|
user_machines = profile.machines.all() if profile else Machine.objects.none()
|
||||||
work_qs = work_qs.filter(machine__in=user_machines)
|
work_qs = work_qs.filter(machine__in=user_machines)
|
||||||
elif role == 'master':
|
elif role == 'master':
|
||||||
allowed_ws = list(profile.allowed_workshops.values_list('id', flat=True)) if profile else []
|
allowed_ws = list(profile.allowed_workshops.values_list('id', flat=True)) if profile else []
|
||||||
if allowed_ws:
|
if allowed_ws:
|
||||||
work_qs = work_qs.filter(Q(machine__workshop_id__in=allowed_ws) | Q(machine_id__isnull=True, workshop_id__in=allowed_ws))
|
work_qs = work_qs.filter(Q(workshop_id__in=allowed_ws) | Q(machine__workshop_id__in=allowed_ws))
|
||||||
|
|
||||||
workitems = list(work_qs.order_by('-date', 'deal__number', 'id')[:2000])
|
workitems = list(work_qs.order_by('-date', 'deal__number', 'id')[:2000])
|
||||||
for wi in workitems:
|
for wi in workitems:
|
||||||
|
|||||||
Reference in New Issue
Block a user