from django.shortcuts import render

from django_filters.rest_framework import FilterSet
from django_filters import DateRangeFilter, DateFilter, CharFilter

from django.views.generic import TemplateView

from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin

from rest_framework import viewsets, filters
from rest_framework.permissions import IsAuthenticated

from django.db.models import Q

from .models import CraiglistInventory
from .serializers import CraigListSerializer


class CraigslistView(LoginRequiredMixin, TemplateView):
    template_name = 'craigslist/craigslist_view.html'


class CraigslistAddView(LoginRequiredMixin, TemplateView):
    template_name = 'craigslist/craigslist_add.html'


class CraigslistFilter(FilterSet):
    date = DateFilter(field_name='date', lookup_expr='icontains')
    client_name = CharFilter(field_name='client_name_company_name__full_name', lookup_expr='icontains')
    cl_admin_support = CharFilter(field_name='cl_admin_support__full_name', lookup_expr='icontains')

    class Meta:
        model = CraiglistInventory
        fields = ('date', 'client_name', 'cl_admin_support')


class CraigListViewSet(viewsets.ModelViewSet):
    permission_class = [IsAuthenticated]
    serializer_class = CraigListSerializer
    filter_class = (CraigslistFilter)

    def get_queryset(self):
        is_staff = self.request.user.is_staff
        is_client = self.request.user.is_client
        craigslist = CraiglistInventory.objects.all()
        if is_client:
            qs = craigslist.filter(Q(client_name_company_name__full_name=self.request.user.clients))
            return qs
        elif is_staff:
            qs = craigslist.filter(Q(cl_admin_support__full_name=self.request.user.staffs.full_name))
            return qs
    
    def perform_create(self, serializer):
        is_staff = self.request.user.is_staff
        is_client = self.request.user.is_client
        if is_staff:
            return serializer.save(cl_admin_support=self.request.user.staffs)
        elif is_client:
            return serializer.save(client_name_company_name=self.request.user.clients)


3bc5957b794c1874638b06356ade0bb37d1b759a
<mask token>


class CraigslistFilter(FilterSet):
    <mask token>
    <mask token>
    <mask token>


    class Meta:
        model = CraiglistInventory
        fields = 'date', 'client_name', 'cl_admin_support'


class CraigListViewSet(viewsets.ModelViewSet):
    permission_class = [IsAuthenticated]
    serializer_class = CraigListSerializer
    filter_class = CraigslistFilter

    def get_queryset(self):
        is_staff = self.request.user.is_staff
        is_client = self.request.user.is_client
        craigslist = CraiglistInventory.objects.all()
        if is_client:
            qs = craigslist.filter(Q(client_name_company_name__full_name=
                self.request.user.clients))
            return qs
        elif is_staff:
            qs = craigslist.filter(Q(cl_admin_support__full_name=self.
                request.user.staffs.full_name))
            return qs

    def perform_create(self, serializer):
        is_staff = self.request.user.is_staff
        is_client = self.request.user.is_client
        if is_staff:
            return serializer.save(cl_admin_support=self.request.user.staffs)
        elif is_client:
            return serializer.save(client_name_company_name=self.request.
                user.clients)

<mask token>


class CraigslistAddView(LoginRequiredMixin, TemplateView):
    <mask token>


class CraigslistFilter(FilterSet):
    date = DateFilter(field_name='date', lookup_expr='icontains')
    client_name = CharFilter(field_name=
        'client_name_company_name__full_name', lookup_expr='icontains')
    cl_admin_support = CharFilter(field_name='cl_admin_support__full_name',
        lookup_expr='icontains')


    class Meta:
        model = CraiglistInventory
        fields = 'date', 'client_name', 'cl_admin_support'


class CraigListViewSet(viewsets.ModelViewSet):
    permission_class = [IsAuthenticated]
    serializer_class = CraigListSerializer
    filter_class = CraigslistFilter

    def get_queryset(self):
        is_staff = self.request.user.is_staff
        is_client = self.request.user.is_client
        craigslist = CraiglistInventory.objects.all()
        if is_client:
            qs = craigslist.filter(Q(client_name_company_name__full_name=
                self.request.user.clients))
            return qs
        elif is_staff:
            qs = craigslist.filter(Q(cl_admin_support__full_name=self.
                request.user.staffs.full_name))
            return qs

    def perform_create(self, serializer):
        is_staff = self.request.user.is_staff
        is_client = self.request.user.is_client
        if is_staff:
            return serializer.save(cl_admin_support=self.request.user.staffs)
        elif is_client:
            return serializer.save(client_name_company_name=self.request.
                user.clients)

<mask token>


class CraigslistAddView(LoginRequiredMixin, TemplateView):
    template_name = 'craigslist/craigslist_add.html'


class CraigslistFilter(FilterSet):
    date = DateFilter(field_name='date', lookup_expr='icontains')
    client_name = CharFilter(field_name=
        'client_name_company_name__full_name', lookup_expr='icontains')
    cl_admin_support = CharFilter(field_name='cl_admin_support__full_name',
        lookup_expr='icontains')


    class Meta:
        model = CraiglistInventory
        fields = 'date', 'client_name', 'cl_admin_support'


class CraigListViewSet(viewsets.ModelViewSet):
    permission_class = [IsAuthenticated]
    serializer_class = CraigListSerializer
    filter_class = CraigslistFilter

    def get_queryset(self):
        is_staff = self.request.user.is_staff
        is_client = self.request.user.is_client
        craigslist = CraiglistInventory.objects.all()
        if is_client:
            qs = craigslist.filter(Q(client_name_company_name__full_name=
                self.request.user.clients))
            return qs
        elif is_staff:
            qs = craigslist.filter(Q(cl_admin_support__full_name=self.
                request.user.staffs.full_name))
            return qs

    def perform_create(self, serializer):
        is_staff = self.request.user.is_staff
        is_client = self.request.user.is_client
        if is_staff:
            return serializer.save(cl_admin_support=self.request.user.staffs)
        elif is_client:
            return serializer.save(client_name_company_name=self.request.
                user.clients)

from django.shortcuts import render
from django_filters.rest_framework import FilterSet
from django_filters import DateRangeFilter, DateFilter, CharFilter
from django.views.generic import TemplateView
from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin
from rest_framework import viewsets, filters
from rest_framework.permissions import IsAuthenticated
from django.db.models import Q
from .models import CraiglistInventory
from .serializers import CraigListSerializer


class CraigslistView(LoginRequiredMixin, TemplateView):
    template_name = 'craigslist/craigslist_view.html'


class CraigslistAddView(LoginRequiredMixin, TemplateView):
    template_name = 'craigslist/craigslist_add.html'


class CraigslistFilter(FilterSet):
    date = DateFilter(field_name='date', lookup_expr='icontains')
    client_name = CharFilter(field_name=
        'client_name_company_name__full_name', lookup_expr='icontains')
    cl_admin_support = CharFilter(field_name='cl_admin_support__full_name',
        lookup_expr='icontains')


    class Meta:
        model = CraiglistInventory
        fields = 'date', 'client_name', 'cl_admin_support'


class CraigListViewSet(viewsets.ModelViewSet):
    permission_class = [IsAuthenticated]
    serializer_class = CraigListSerializer
    filter_class = CraigslistFilter

    def get_queryset(self):
        is_staff = self.request.user.is_staff
        is_client = self.request.user.is_client
        craigslist = CraiglistInventory.objects.all()
        if is_client:
            qs = craigslist.filter(Q(client_name_company_name__full_name=
                self.request.user.clients))
            return qs
        elif is_staff:
            qs = craigslist.filter(Q(cl_admin_support__full_name=self.
                request.user.staffs.full_name))
            return qs

    def perform_create(self, serializer):
        is_staff = self.request.user.is_staff
        is_client = self.request.user.is_client
        if is_staff:
            return serializer.save(cl_admin_support=self.request.user.staffs)
        elif is_client:
            return serializer.save(client_name_company_name=self.request.
                user.clients)

from django.shortcuts import render

from django_filters.rest_framework import FilterSet
from django_filters import DateRangeFilter, DateFilter, CharFilter

from django.views.generic import TemplateView

from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin

from rest_framework import viewsets, filters
from rest_framework.permissions import IsAuthenticated

from django.db.models import Q

from .models import CraiglistInventory
from .serializers import CraigListSerializer


class CraigslistView(LoginRequiredMixin, TemplateView):
    template_name = 'craigslist/craigslist_view.html'


class CraigslistAddView(LoginRequiredMixin, TemplateView):
    template_name = 'craigslist/craigslist_add.html'


class CraigslistFilter(FilterSet):
    date = DateFilter(field_name='date', lookup_expr='icontains')
    client_name = CharFilter(field_name='client_name_company_name__full_name', lookup_expr='icontains')
    cl_admin_support = CharFilter(field_name='cl_admin_support__full_name', lookup_expr='icontains')

    class Meta:
        model = CraiglistInventory
        fields = ('date', 'client_name', 'cl_admin_support')


class CraigListViewSet(viewsets.ModelViewSet):
    permission_class = [IsAuthenticated]
    serializer_class = CraigListSerializer
    filter_class = (CraigslistFilter)

    def get_queryset(self):
        is_staff = self.request.user.is_staff
        is_client = self.request.user.is_client
        craigslist = CraiglistInventory.objects.all()
        if is_client:
            qs = craigslist.filter(Q(client_name_company_name__full_name=self.request.user.clients))
            return qs
        elif is_staff:
            qs = craigslist.filter(Q(cl_admin_support__full_name=self.request.user.staffs.full_name))
            return qs
    
    def perform_create(self, serializer):
        is_staff = self.request.user.is_staff
        is_client = self.request.user.is_client
        if is_staff:
            return serializer.save(cl_admin_support=self.request.user.staffs)
        elif is_client:
            return serializer.save(client_name_company_name=self.request.user.clients)

