начал работать с интерфейсом
All checks were successful
Deploy MES Core / deploy (push) Successful in 9s

This commit is contained in:
tertelius
2026-03-29 00:24:39 +03:00
parent f86f0bfcd4
commit a4ba577206
19 changed files with 561 additions and 14 deletions

View File

@@ -1,3 +1,32 @@
from django.shortcuts import render
from django.shortcuts import redirect
from django.views.generic import TemplateView, ListView
from django.contrib.auth.mixins import LoginRequiredMixin
from .models import Item # Проверь, как точно называется твоя модель деталей/заказов
# Create your views here.
# Класс главной страницы (роутер)
class IndexView(TemplateView):
template_name = 'shiftflow/landing.html'
def get(self, request, *args, **kwargs):
# Если юзер авторизован — сразу отправляем его в реестр
if request.user.is_authenticated:
return redirect('registry')
# Если нет — показываем кнопку "Войти"
return super().get(request, *args, **kwargs)
# Класс реестра деталей (защищен LoginRequiredMixin)
class RegistryView(LoginRequiredMixin, ListView):
model = Item
template_name = 'shiftflow/items_list.html'
context_object_name = 'items'
def get_queryset(self):
# Позже здесь добавим: .filter(machine__in=request.user.profile.machines.all())
return Item.objects.all().order_by('-id')
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
# Передаем роль в шаблон, чтобы скрывать/показывать кнопки
if hasattr(self.request.user, 'profile'):
context['user_role'] = self.request.user.profile.role
return context