Skip to content

Commit

Permalink
feat: files
Browse files Browse the repository at this point in the history
  • Loading branch information
Shavkatjon-O committed Sep 15, 2024
1 parent 6f3be75 commit 7b8883d
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 2 deletions.
4 changes: 3 additions & 1 deletion apps/common/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from django.contrib import admin
from .models import DesktopDownload, MobileDownload

# Register your models here.
admin.site.register(DesktopDownload)
admin.site.register(MobileDownload)
38 changes: 38 additions & 0 deletions apps/common/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 5.0.7 on 2024-09-15 16:46

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='DesktopDownload',
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='desktop_downloads/')),
],
options={
'abstract': False,
},
),
migrations.CreateModel(
name='MobileDownload',
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='mobile_downloads/')),
],
options={
'abstract': False,
},
),
]
37 changes: 37 additions & 0 deletions apps/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,40 @@ class BaseModel(models.Model):

class Meta:
abstract = True


class DesktopDownload(BaseModel):
file = models.FileField(upload_to="desktop_downloads/")


class MobileDownload(BaseModel):
file = models.FileField(upload_to="mobile_downloads/")


from rest_framework import serializers
from rest_framework.permissions import AllowAny
from rest_framework import generics


class DesktopDownloadSerializer(serializers.ModelSerializer):
class Meta:
model = DesktopDownload
fields = "__all__"


class MobileDownloadSerializer(serializers.ModelSerializer):
class Meta:
model = MobileDownload
fields = "__all__"


class DesktopDownloadDetailView(generics.RetrieveAPIView):
queryset = DesktopDownload.objects.all().first()
serializer_class = DesktopDownloadSerializer
permission_classes = [AllowAny]


class MobileDownloadDetailView(generics.RetrieveAPIView):
queryset = MobileDownload.objects.all().first()
serializer_class = MobileDownloadSerializer
permission_classes = [AllowAny]
7 changes: 7 additions & 0 deletions apps/common/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path
from .models import DesktopDownloadDetailView, MobileDownloadDetailView

urlpatterns = [
path("desktop/", DesktopDownloadDetailView.as_view(), name="desktop-download"),
path("mobile/", MobileDownloadDetailView.as_view(), name="mobile-download"),
]
6 changes: 5 additions & 1 deletion core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ def redirect_base_to_admin(request):
path("api/applications/", include("apps.applications.urls")),
path("api/loans/", include("apps.loans.urls")),
path("api/borrowers/", include("apps.borrowers.urls")),
path("api/assistants/", include("apps.assistants.urls")),
# path("api/assistants/", include("apps.assistants.urls")),
path("api/meetings/", include("apps.meetings.urls")),
path("api/common/", include("apps.common.urls")),
]

if not settings.DEBUG:
urlpatterns += [path("api/assistants/", include("apps.assistants.urls"))]

# Swagger urls
urlpatterns += [
path(
Expand Down

0 comments on commit 7b8883d

Please sign in to comment.