Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more logging #141

Merged
merged 4 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions backend/donations/views/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from django.views.decorators.csrf import csrf_exempt
from django.utils.decorators import method_decorator

from .base import BaseHandler, AccountHandler


Expand All @@ -20,10 +23,16 @@ def get(self, request, *args, **kwargs):
raise NotImplementedError("GetNgoForms not implemented yet")


@method_decorator(csrf_exempt, name="dispatch")
class GetUploadUrl(AccountHandler):
def get(self, request, *args, **kwargs):
raise NotImplementedError("GetUploadUrl not implemented yet")

def post(self, request, *args, **kwargs):
# logo_file = request.FILES.get("files")
# print(logo_file)
raise NotImplementedError("GetUploadUrl not implemented yet")


class Webhook(BaseHandler):
def get(self, request, *args, **kwargs):
Expand Down
8 changes: 8 additions & 0 deletions backend/partners/middleware.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import logging

from django.conf import settings
from django.http import Http404

from .models import Partner


logger = logging.getLogger(__name__)


class InvalidSubdomain(Exception):
pass

Expand Down Expand Up @@ -40,11 +45,13 @@ def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):
logger.debug("Request host %s", request.get_host())
try:
subdomain = PartnerDomainMiddleware.extract_subdomain(request.get_host(), settings.APEX_DOMAIN)
except InvalidSubdomain:
raise Http404

logger.debug("Subdomain %s", subdomain or "None")
if not subdomain:
partner = None
else:
Expand All @@ -54,6 +61,7 @@ def __call__(self, request):
partner = None

request.partner = partner
logger.debug("Request partner %s", request.partner or "None")

# Code to be executed for each request before
# the view (and later middleware) are called.
Expand Down