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.
 
 
 
 
 
 

73 lines
2.2 KiB

from django.shortcuts import render, get_object_or_404
from django.contrib.auth.models import Group
from django.views.generic import ListView, DetailView, View, UpdateView
from django.views.generic.base import TemplateView
from archilance.mixins import BaseMixin
from .models import User
class UserListView(ListView):
model = User
template_name = 'users_list.html'
context_object_name = 'users'
class ContractorListView(ListView):
model = User
template_name = 'contractor_list.html'
context_object_name = 'contractor'
class ContractorProfileDetailView(DetailView):
model = User
template_name = 'contractor_profile.html'
context_object_name = 'contractor'
class ContractorOfficeDetailView(DetailView):
model = User
template_name = 'contractor_office.html'
context_object_name = 'contractor'
class CustomerProfileOpenProjectsView(BaseMixin, DetailView):
model = User
template_name = 'customer_profile_open_projects.html'
context_object_name = 'customer'
def get_context_data(self, **kwargs):
c = super().get_context_data(**kwargs)
c['projects'] = self.object.projects.filter(state='active')
return c
class CustomerProfileTrashedProjectsView(BaseMixin, DetailView):
model = User
template_name = 'customer_profile_trashed_projects.html'
context_object_name = 'customer'
def get_context_data(self, **kwargs):
c = super().get_context_data(**kwargs)
c['projects'] = self.object.projects.filter(state='trashed')
return c
class CustomerProfileCurrentProjectsView(BaseMixin, DetailView):
model = User
template_name = 'customer_profile_current_projects.html'
context_object_name = 'customer'
class CustomerProfileReviewsView(BaseMixin, DetailView):
model = User
template_name = 'customer_profile_reviews.html'
context_object_name = 'customer'
class ContractorProfileEditView(BaseMixin, View):
template_name = 'contractor_profile_edit.html'
def get(self, request, *args, **kwargs):
contractor = get_object_or_404(User, pk=kwargs.get('pk'))
return render(request, self.template_name, {'contractor': contractor})