You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.4 KiB
90 lines
2.4 KiB
from django.shortcuts import render
|
|
from django.contrib.auth.models import Group
|
|
from django.views.generic import ListView, DetailView, View, UpdateView
|
|
from django.views.generic.base import TemplateView
|
|
|
|
from .models import User
|
|
|
|
|
|
class UserListView(ListView):
|
|
model = User
|
|
template_name = 'users_list.html'
|
|
context_object_name = 'users'
|
|
|
|
|
|
class UserInfoListView(ListView):
|
|
model = User
|
|
template_name = 'users_info_list.html'
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = super(UserInfoListView, self).get_context_data(**kwargs)
|
|
context['groups'] = Group.objects.all()
|
|
context['performers'] = User.perform_objects.all()
|
|
context['customers'] = User.customers_objects.all()
|
|
return context
|
|
|
|
class UserDetailView(DetailView):
|
|
model = User
|
|
|
|
|
|
|
|
class UserView(View):
|
|
pass
|
|
# template_name = 'contractor.html'
|
|
#
|
|
# def get(self, request, pk):
|
|
# user = User.objects.get(pk=pk)
|
|
# user_group = user.groups.all().first()
|
|
# if 'Заказчики' in user_group.name:
|
|
# self.template_name = 'users/customer.html'
|
|
#
|
|
# return render(request, self.template_name, {'user': user})
|
|
# # import code; code.interact(local=dict(globals(), **locals()))
|
|
|
|
|
|
class UserUpdateView(UpdateView):
|
|
model = User
|
|
|
|
from django.http import Http404
|
|
from django.shortcuts import redirect
|
|
|
|
|
|
class ContractorListView(ListView):
|
|
model = User
|
|
template_name = 'contractor_list.html'
|
|
|
|
class ContractorProfileDetailView(DetailView):
|
|
model = User
|
|
template_name = 'contractor_profile.html'
|
|
|
|
# def get_object(self, queryset=None):
|
|
# object = super().get_object()
|
|
# user_group = object.groups.all().first()
|
|
# if 'Исполнители' not in user_group.name:
|
|
# return redirect('/projects/')
|
|
# return object
|
|
|
|
class ContractorOfficeDetailView(DetailView):
|
|
model = User
|
|
template_name = 'contractor_office.html'
|
|
|
|
|
|
|
|
class CustomerProfileOpenProjectsView(TemplateView):
|
|
model = User
|
|
template_name = 'customer_profile_open_projects.html'
|
|
|
|
|
|
class CustomerProfileTrashedProjectsView(TemplateView):
|
|
model = User
|
|
template_name = 'customer_profile_trashed_projects.html'
|
|
|
|
|
|
class CustomerProfileCurrentProjectsView(TemplateView):
|
|
model = User
|
|
template_name = 'customer_profile_current_projects.html'
|
|
|
|
|
|
class CustomerProfileReviewsView(TemplateView):
|
|
model = User
|
|
template_name = 'customer_profile_reviews.html'
|
|
|