Переглянути джерело

Authentication added for the client views

master
kj1352 3 роки тому
джерело
коміт
36c80c8d1e
2 змінених файлів з 18 додано та 1 видалено
  1. +17
    -1
      client/views.py
  2. +1
    -0
      workx_backend/settings/base.py

+ 17
- 1
client/views.py Переглянути файл

@@ -1,11 +1,15 @@
from rest_framework.response import Response
from rest_framework.views import APIView

from rest_framework.authentication import TokenAuthentication
from rest_framework.permissions import IsAuthenticated
from .models import TaxType, Country, State, City, Client
from .serializers import TaxTypeSerializer, CountrySerializer, StateSerializer, CitySerializer, ClientSerializer


class TaxTypeList(APIView):
authentication_classes = [TokenAuthentication]
permission_classes = [IsAuthenticated]

def get(self, request):
tax_types = TaxType.objects.all()
serializer = TaxTypeSerializer(tax_types, many=True)
@@ -13,6 +17,9 @@ class TaxTypeList(APIView):


class CountryList(APIView):
authentication_classes = [TokenAuthentication]
permission_classes = [IsAuthenticated]

def get(self, request):
countries = Country.objects.all()
serializer = CountrySerializer(countries, many=True)
@@ -20,6 +27,9 @@ class CountryList(APIView):


class StateList(APIView):
authentication_classes = [TokenAuthentication]
permission_classes = [IsAuthenticated]

def get(self, request):
states = State.objects.all()
serializer = StateSerializer(states, many=True)
@@ -27,6 +37,9 @@ class StateList(APIView):


class CityList(APIView):
authentication_classes = [TokenAuthentication]
permission_classes = [IsAuthenticated]

def get(self, request):
cities = City.objects.all()
serializer = CitySerializer(cities, many=True)
@@ -34,6 +47,9 @@ class CityList(APIView):


class ClientList(APIView):
authentication_classes = [TokenAuthentication]
permission_classes = [IsAuthenticated]

def get(self, request):
clients = Client.objects.all()
serializer = ClientSerializer(clients, many=True)


+ 1
- 0
workx_backend/settings/base.py Переглянути файл

@@ -35,6 +35,7 @@ INSTALLED_APPS = [
PASSWORDLESS_AUTH = {
'PASSWORDLESS_AUTH_TYPES': ['EMAIL'],
'PASSWORDLESS_EMAIL_NOREPLY_ADDRESS': 'kj@webtrigon.com',
'PASSWORDLESS_REGISTER_NEW_USERS': False,
}

MIDDLEWARE = [