Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Shavkatjon-O committed Sep 13, 2024
1 parent 2e5d97f commit 31f8b01
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 3 deletions.
4 changes: 3 additions & 1 deletion apps/clients/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from django.contrib import admin
from apps.clients.models import Client
from apps.clients.models import Client, Document

admin.site.register(Client)

admin.site.register(Document)
25 changes: 25 additions & 0 deletions apps/clients/migrations/0002_document.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.0.7 on 2024-09-13 07:43

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('clients', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Document',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('file', models.FileField(upload_to='clients/documents')),
],
options={
'abstract': False,
},
),
]
4 changes: 4 additions & 0 deletions apps/clients/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ def __str__(self):
class Meta:
verbose_name = "Client"
verbose_name_plural = "Clients"


class Document(BaseModel):
file = models.FileField(upload_to="clients/documents")
11 changes: 11 additions & 0 deletions apps/clients/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from rest_framework import serializers
from .models import Document


class DocumentSerializer(serializers.ModelSerializer):
class Meta:
model = Document
fields = (
"id",
"file",
)
3 changes: 3 additions & 0 deletions apps/clients/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
from apps.clients.api.ClientsUpdate.views import ClientsUpdateAPIView
from apps.clients.api.ClientsDelete.views import ClientsDeleteAPIView

from .views import DocumentGetAPIView

urlpatterns = [
path("", ClientsListAPIView.as_view(), name="clients-list"),
path("create/", ClientsCreateAPIView.as_view(), name="clients-create"),
path("<int:pk>/", ClientsDetailAPIView.as_view(), name="clients-detail"),
path("<int:pk>/update/", ClientsUpdateAPIView.as_view(), name="clients-update"),
path("<int:pk>/delete/", ClientsDeleteAPIView.as_view(), name="clients-delete"),
path("document/", DocumentGetAPIView.as_view(), name="document-get"),
]
12 changes: 10 additions & 2 deletions apps/clients/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
from django.shortcuts import render
from rest_framework.generics import RetrieveAPIView
from rest_framework.permissions import AllowAny

# Create your views here.
from .serializers import DocumentSerializer
from .models import Document


class DocumentGetAPIView(RetrieveAPIView):
queryset = Document.objects.all()
permission_classes = [AllowAny]
serializer_class = DocumentSerializer

0 comments on commit 31f8b01

Please sign in to comment.