diff --git a/backend/notifications/logic.py b/backend/notifications/logic.py index f7140134..731b4281 100644 --- a/backend/notifications/logic.py +++ b/backend/notifications/logic.py @@ -21,13 +21,9 @@ def get_message_dict(notification: Notification) -> Dict[str, str]: # Call the function after 60 seconds and no more than once in that period def schedule_send_mails(): - print("Hiii") if not cache.get("notifications_send_mails"): - print("Not in cache yet") cache.set("notifications_send_mails", True) _send_mails.apply_async(countdown=60) - else: - print("Already in cache") # Try to send one email and set the result @@ -42,7 +38,6 @@ def _send_mail(mail: mail.EmailMessage, result: List[bool]): # Send all unsent emails @shared_task def _send_mails(): - print("Sending") cache.set("notifications_send_mails", False) notifications = Notification.objects.filter(is_sent=False) diff --git a/backend/notifications/signals.py b/backend/notifications/signals.py index 7a817e5a..24d7ea4e 100644 --- a/backend/notifications/signals.py +++ b/backend/notifications/signals.py @@ -12,7 +12,6 @@ notification_create = Signal() -# TODO: Remove send_mails call @receiver(notification_create) def notification_creation( type: NotificationType, diff --git a/backend/notifications/urls.py b/backend/notifications/urls.py index a9dacf25..23b79d7e 100644 --- a/backend/notifications/urls.py +++ b/backend/notifications/urls.py @@ -1,8 +1,6 @@ from django.urls import path -from notifications.views import NotificationView, TestingView +from notifications.views import NotificationView -# TODO: Remove test urlpatterns = [ path("tmp//", NotificationView.as_view(), name="notification-detail"), - path("test/", TestingView.as_view(), name="notification-test"), ] diff --git a/backend/notifications/views.py b/backend/notifications/views.py index c83d2da8..b5d1f4f6 100644 --- a/backend/notifications/views.py +++ b/backend/notifications/views.py @@ -11,7 +11,6 @@ from rest_framework.views import APIView -# TODO: Give admin access to everything class NotificationPermission(BasePermission): # The user can only access their own notifications # An admin can access all notifications @@ -36,29 +35,3 @@ def post(self, request: Request, user_id: str) -> Response: notifications.update(is_read=True) return Response(status=HTTP_200_OK) - - -# TODO: Remove this view -class TestingView(APIView): - permission_classes = [IsAuthenticated] - - def get(self, request: Request): - from notifications.signals import NotificationType, notification_create - - print("Hi") - - notification_create.send( - sender="", - type=NotificationType.SCORE_ADDED, - user=request.user, - arguments={"score": "10"}, - ) - - return Response(status=HTTP_200_OK) - - def post(self, request: Request): - from notifications.logic import send_mails - - send_mails() - - return Response(status=HTTP_200_OK) diff --git a/backend/ypovoli/celery.py b/backend/ypovoli/celery.py index 4195e638..5f2cac39 100644 --- a/backend/ypovoli/celery.py +++ b/backend/ypovoli/celery.py @@ -15,8 +15,3 @@ # Load task modules from all registered Django apps. app.autodiscover_tasks() - - -@app.task(bind=True, ignore_result=True) -def debug_task(self): - print(f"Request: {self.request!r}") diff --git a/data/nginx/nginx.conf b/data/nginx/nginx.conf index c46ebf37..f6a71bee 100644 --- a/data/nginx/nginx.conf +++ b/data/nginx/nginx.conf @@ -8,7 +8,7 @@ http { } upstream frontend { - server frontend:3000; + server frontend:5173; } server { @@ -28,7 +28,7 @@ http { ssl_certificate_key ssl/private.key; location / { - proxy_pass https://frontend; + proxy_pass http://frontend; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_redirect off; diff --git a/development.yml b/development.yml index 58a532e3..2530320b 100644 --- a/development.yml +++ b/development.yml @@ -75,8 +75,11 @@ services: build: context: $FRONTEND_DIR dockerfile: Dockerfile + command: bash -c "npm install && npm run host" expose: - - 3000 + - 5173 + volumes: + - $FRONTEND_DIR:/app depends_on: - backend diff --git a/frontend/Dockerfile b/frontend/Dockerfile index d3a568de..ec6c3ba7 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,12 +1,22 @@ -FROM node:16 as build-stage +# FROM node:16 as build-stage +# WORKDIR /app +# COPY package*.json ./ +# RUN npm install +# COPY ./ . +# RUN npm run build + +# FROM nginx as development-stage +# EXPOSE 3000 +# RUN mkdir /app +# COPY nginx.conf /etc/nginx/conf.d/default.conf +# COPY --from=build-stage /app/dist /app + +FROM node:16 + WORKDIR /app + COPY package*.json ./ + RUN npm install -COPY ./ . -RUN npm run build - -FROM nginx as development-stage -EXPOSE 3000 -RUN mkdir /app -COPY nginx.conf /etc/nginx/conf.d/default.conf -COPY --from=build-stage /app/dist /app \ No newline at end of file + +COPY . /app/ diff --git a/frontend/package.json b/frontend/package.json index 57fc78e0..60994926 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -5,6 +5,7 @@ "type": "module", "scripts": { "dev": "vite", + "host": "vite --host", "build": "vue-tsc && vite build", "preview": "vite preview" },