| @@ -1,3 +1,4 @@ | |||||
| from django.contrib import admin | from django.contrib import admin | ||||
| from .models import TaxType, Country, State, City, Client | |||||
| # Register your models here. | |||||
| admin.site.register([TaxType, Country, State, City, Client]) | |||||
| @@ -3,7 +3,7 @@ from django.db import models | |||||
| class TaxType(models.Model): | class TaxType(models.Model): | ||||
| name = models.CharField(max_length=15) | name = models.CharField(max_length=15) | ||||
| percentage = models.DecimalField(max_digits=3, decimal_places=2) | |||||
| percentage = models.DecimalField(max_digits=5, decimal_places=2) | |||||
| def __str__(self): | def __str__(self): | ||||
| return self.name | return self.name | ||||
| @@ -0,0 +1,10 @@ | |||||
| from django.urls import path | |||||
| from . import views | |||||
| urlpatterns = [ | |||||
| path('tax-types/', views.TaxTypeList.as_view()), | |||||
| path('countries/', views.CountryList.as_view()), | |||||
| path('states/', views.StateList.as_view()), | |||||
| path('cities/', views.CityList.as_view()), | |||||
| path('clients/', views.ClientList.as_view()) | |||||
| ] | |||||
| @@ -1,2 +1,40 @@ | |||||
| from django.shortcuts import render | |||||
| from rest_framework.response import Response | |||||
| from rest_framework.views import APIView | |||||
| from .models import TaxType, Country, State, City, Client | |||||
| from .serializers import TaxTypeSerializer, CountrySerializer, StateSerializer, CitySerializer, ClientSerializer | |||||
| class TaxTypeList(APIView): | |||||
| def get(self, request): | |||||
| tax_types = TaxType.objects.all() | |||||
| serializer = TaxTypeSerializer(tax_types, many=True) | |||||
| return Response(serializer.data) | |||||
| class CountryList(APIView): | |||||
| def get(self, request): | |||||
| countries = Country.objects.all() | |||||
| serializer = CountrySerializer(countries, many=True) | |||||
| return Response(serializer.data) | |||||
| class StateList(APIView): | |||||
| def get(self, request): | |||||
| states = State.objects.all() | |||||
| serializer = StateSerializer(states, many=True) | |||||
| return Response(serializer.data) | |||||
| class CityList(APIView): | |||||
| def get(self, request): | |||||
| cities = City.objects.all() | |||||
| serializer = CitySerializer(cities, many=True) | |||||
| return Response(serializer.data) | |||||
| class ClientList(APIView): | |||||
| def get(self, request): | |||||
| clients = Client.objects.all() | |||||
| serializer = ClientSerializer(clients, many=True) | |||||
| return Response(serializer.data) | |||||
| @@ -8,7 +8,7 @@ class Employee(models.Model): | |||||
| user = models.OneToOneField(User, on_delete=models.CASCADE) | user = models.OneToOneField(User, on_delete=models.CASCADE) | ||||
| employee_id = models.CharField(max_length=15) | employee_id = models.CharField(max_length=15) | ||||
| phone = PhoneNumberField() | phone = PhoneNumberField() | ||||
| salary = models.DecimalField(max_digits=10, decimal_places=2) | |||||
| salary = models.DecimalField(max_digits=15, decimal_places=2) | |||||
| start_date = models.DateField() | start_date = models.DateField() | ||||
| end_date = models.DateField(null=True, blank=True) | end_date = models.DateField(null=True, blank=True) | ||||
| projects = models.ManyToManyField(Project) | projects = models.ManyToManyField(Project) | ||||
| @@ -1,10 +1,10 @@ | |||||
| from django.contrib import admin | from django.contrib import admin | ||||
| from django.urls import path, include | from django.urls import path, include | ||||
| from rest_framework import routers | |||||
| from workx_backend.views import UserViewSet, test_mail | |||||
| from rest_framework import permissions | from rest_framework import permissions | ||||
| from drf_yasg.views import get_schema_view | from drf_yasg.views import get_schema_view | ||||
| from drf_yasg import openapi | from drf_yasg import openapi | ||||
| from client import urls as clientUrls | |||||
| schema_view = get_schema_view( | schema_view = get_schema_view( | ||||
| openapi.Info( | openapi.Info( | ||||
| @@ -19,15 +19,15 @@ schema_view = get_schema_view( | |||||
| permission_classes=[permissions.AllowAny], | permission_classes=[permissions.AllowAny], | ||||
| ) | ) | ||||
| router = routers.DefaultRouter() | |||||
| router.register(r'users', UserViewSet) | |||||
| urlpatterns = [ | urlpatterns = [ | ||||
| path('workx/', include([ | path('workx/', include([ | ||||
| path('admin/', admin.site.urls), | |||||
| path('', include('drfpasswordless.urls')), | |||||
| path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), | path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'), | ||||
| path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'), | path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'), | ||||
| path('admin/', admin.site.urls), | |||||
| path('api/', include(router.urls)), | |||||
| path('', include('drfpasswordless.urls')) | |||||
| path('api/', include([ | |||||
| path('', include(clientUrls)) | |||||
| ])) | |||||
| ])), | ])), | ||||
| ] | ] | ||||
| @@ -1,21 +0,0 @@ | |||||
| from django.contrib.auth.models import User | |||||
| from django.core.mail import send_mail | |||||
| from django.http import HttpResponse | |||||
| from rest_framework import viewsets | |||||
| from workx_backend.serializers import UserSerializer | |||||
| class UserViewSet(viewsets.ModelViewSet): | |||||
| queryset = User.objects.all() | |||||
| serializer_class = UserSerializer | |||||
| def test_mail(request, *args, **kwargs): | |||||
| send_mail('This is the title of the email', | |||||
| 'This is the message you want to send', | |||||
| 'nikhilkj24@gmail.com', | |||||
| [ | |||||
| 'nikhilkj.webtrigon@gmail.com', # add more emails to this list of you want to | |||||
| ] | |||||
| ) | |||||
| return HttpResponse('Done') | |||||