Skip to content

Commit dbec00b

Browse files
Merge pull request #65 from druling/dev
Release 11-02-2025
2 parents 580234e + 0aa3736 commit dbec00b

Some content is hidden

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

87 files changed

+962
-381
lines changed

.env.example

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PORT=3000
2-
ENV=dev
2+
ENV=
33
DEBUG=True
44
ALLOWED_HOSTS=localhost,127.0.0.1,
55

@@ -24,6 +24,11 @@ ACCESS_TOKEN_LIFETIME=3600
2424

2525
# AWS Credentials
2626
AWS_DEFAULT_REGION=ap-south-1
27+
AWS_ACCESS_KEY_ID=test
28+
AWS_SECRET_ACCESS_KEY=test
2729

2830
# AWS Credentials for Localstack
29-
LOCALSTACK_PORT=4566
31+
LOCALSTACK_HOST=localhost
32+
LOCALSTACK_PORT=4566
33+
34+
INTERNAL_API_TOKEN='druldruldrul'

.github/workflows/build.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ name: Build, Push, and Deploy
33
on:
44
push:
55
branches:
6-
- handle_bounce_email
6+
- dev
7+
- master
8+
- gamma
79

810
jobs:
911
build-and-push:
1012
name: Build and Push
1113
runs-on: ubuntu-latest
12-
environment: dev
14+
environment: ${{ github.ref == 'refs/heads/master' && 'prod' || (github.ref == 'refs/heads/dev' && 'dev' || 'staging') }}
1315

1416
permissions:
1517
id-token: write

build/stack/web/Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ ENV PYTHONUNBUFFERED 1 # Force the stdout and stderr streams to be unbuff
77

88
# Install system dependencies
99
RUN apt-get update && apt-get install -y --no-install-recommends \
10-
postgresql-client \
11-
supervisor && \
10+
postgresql-client && \
1211
apt-get clean && rm -rf /var/lib/apt/lists/*
1312

1413
# Set the working directory in the container

commons/enums/BaseResourceEnum.py

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

88
class BaseResourceEnum(Enum):
99
def __str__(self):
10-
return f"{env}-{self.value}"
10+
base = f"{env}-" if env else ""
11+
return f"{base}{self.value}"
1112

1213
@property
1314
def value(self) -> str:
14-
return f"{env}-{super().value}"
15+
base = f"{env}-" if env else ""
16+
return f"{base}{super().value}"
1517

1618
@classmethod
1719
def choices(cls):

commons/middleware/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from .internal_auth import InternalTokenAuthentication, IsInternalRequest
2+
from .api_handler import api_handler
3+
from .api_validation import validate
4+
from .api_exception_handler import handle_exceptions
5+
6+
__all__ = [
7+
InternalTokenAuthentication,
8+
IsInternalRequest,
9+
api_handler,
10+
validate,
11+
handle_exceptions,
12+
]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from rest_framework.authentication import BaseAuthentication
2+
from rest_framework.exceptions import AuthenticationFailed
3+
from django.conf import settings
4+
from rest_framework.permissions import BasePermission
5+
6+
7+
class InternalTokenAuthentication(BaseAuthentication):
8+
def authenticate(self, request):
9+
token = request.headers.get("Internal-Token")
10+
if not token:
11+
return None
12+
13+
if token != settings.INTERNAL_API_TOKEN:
14+
raise AuthenticationFailed("Invalid token")
15+
16+
return None, None
17+
18+
19+
class IsInternalRequest(BasePermission):
20+
def has_permission(self, request, view):
21+
return request.auth is None and request.user is None

commons/service/BaseService.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ class BaseService:
1111
def __init__(self, model):
1212
self.model = model
1313

14-
def get_by_id(self, id):
14+
def get_by_id(self, id, filters=None):
1515
try:
16-
return self.model.objects.get(id=id)
16+
query = self.model.objects.filter(id=id)
17+
if filters:
18+
query = query.filter(**filters)
19+
return query.get()
1720
except self.model.DoesNotExist:
1821
logger.error(f"{self.model.__name__} with ID {id} does not exist.")
1922
raise ObjectDoesNotExist(
2023
f"{self.model.__name__} with ID {id} does not exist."
2124
)
22-
2325
except Exception as e:
2426
logger.error(
2527
f"An error occurred while fetching the {self.model.__name__}: {str(e)}",

constants/promotions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from plan.enum import Product, PlanType
2+
3+
4+
class Promotions:
5+
NEW_USER = [{"product": Product.MENU, "plan": PlanType.BASIC}]

0 commit comments

Comments
 (0)