Skip to content

Commit f4d348e

Browse files
OsamaRagab520rootoyasr
authored
First release (#33)
Co-authored-by: root <root@Legion.localdomain> Co-authored-by: Osama Yasser <osamayasserr@gmail.com>
1 parent 7f6c4ab commit f4d348e

File tree

114 files changed

+5348
-500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+5348
-500
lines changed

.envs/.local/.django

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# ------------------------------------------------------------------------------
33
USE_DOCKER=yes
44
IPYTHONDIR=/app/.ipython
5+
56
# Redis
67
# ------------------------------------------------------------------------------
78
REDIS_URL=redis://redis:6379/0
@@ -12,3 +13,11 @@ REDIS_URL=redis://redis:6379/0
1213
# Flower
1314
CELERY_FLOWER_USER=debug
1415
CELERY_FLOWER_PASSWORD=debug
16+
17+
# Files
18+
# ------------------------------------------------------------------------------
19+
FILE_UPLOAD_STORAGE=local
20+
21+
# Firebase
22+
# ------------------------------------------------------------------------------
23+
GOOGLE_APPLICATION_CREDENTIALS=/home/$USER/google-services.json

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ env:
77

88
on:
99
pull_request:
10-
branches: [ "master", "main" ]
10+
branches: [ "master", "main", "dev"]
1111
paths-ignore: [ "docs/**" ]
1212

1313
push:
14-
branches: [ "master", "main" ]
14+
branches: [ "master", "main", "dev"]
1515
paths-ignore: [ "docs/**" ]
1616

1717
concurrency:

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,3 +277,9 @@ api/media/
277277
.env
278278
.envs/*
279279
!.envs/.local/
280+
281+
# VScode
282+
.vscode
283+
284+
# Media files
285+
media

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ destroy:
5353

5454

5555
rm_pyc:
56-
find . -name '__pycache__' -name '*.pyc' | xargs rm -rf
56+
find . -name '__pycache__' -name '*.pyc' | xargs rm -rf

api/apis/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Init

api/apis/apps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class ApisConfig(AppConfig):
5+
default_auto_field = "django.db.models.BigAutoField"
6+
name = "api.apis"

api/apis/migrations/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Init

api/apis/pagination.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from collections import OrderedDict
2+
3+
from rest_framework.pagination import LimitOffsetPagination as _LimitOffsetPagination
4+
from rest_framework.response import Response
5+
6+
7+
def get_paginated_response(
8+
*, pagination_class, serializer_class, queryset, request, view
9+
):
10+
paginator = pagination_class()
11+
12+
page = paginator.paginate_queryset(queryset, request, view=view)
13+
14+
if page is not None:
15+
serializer = serializer_class(page, many=True)
16+
return paginator.get_paginated_response(serializer.data)
17+
18+
serializer = serializer_class(queryset, many=True)
19+
20+
return Response(data=serializer.data)
21+
22+
23+
class LimitOffsetPagination(_LimitOffsetPagination):
24+
default_limit = 10
25+
max_limit = 50
26+
27+
def get_paginated_data(self, data):
28+
return OrderedDict(
29+
[
30+
("limit", self.limit),
31+
("offset", self.offset),
32+
("count", self.count),
33+
("next", self.get_next_link()),
34+
("previous", self.get_previous_link()),
35+
("results", data),
36+
]
37+
)
38+
39+
def get_paginated_response(self, data):
40+
"""
41+
We redefine this method in order to return `limit` and `offset`.
42+
This is used by the frontend to construct the pagination itself.
43+
"""
44+
return Response(
45+
OrderedDict(
46+
[
47+
("limit", self.limit),
48+
("offset", self.offset),
49+
("count", self.count),
50+
("next", self.get_next_link()),
51+
("previous", self.get_previous_link()),
52+
("results", data),
53+
]
54+
)
55+
)

api/apis/tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Tests

api/apis/urls.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django.urls import include, path
2+
3+
app_name = "apis"
4+
urlpatterns = [
5+
path("auth/", include("api.authentication.urls", "authentication")),
6+
path("users/", include("api.users.urls", "users")),
7+
path("cases/", include("api.cases.urls", "cases")),
8+
path("files/", include("api.files.urls", "files")),
9+
path("notifications/", include("api.notifications.urls", "notifications")),
10+
path("locations/", include("api.locations.urls", "locations")),
11+
]

0 commit comments

Comments
 (0)