Skip to content

Commit

Permalink
bug: Fix #82
Browse files Browse the repository at this point in the history
Context processors prevented an initial server object from being created
  • Loading branch information
nfoert committed Oct 8, 2024
1 parent e1fb8c9 commit 6aac82e
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions cardie/main/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
from django.core.exceptions import ImproperlyConfigured
from django.conf import settings

from .models import Server

def server_context(request):
server_context = Server.objects.first()
if server_context is None:
raise ImproperlyConfigured(
"No Server object found in the database. Tip: please add one."
)
if settings.ADMIN_PATH not in request.path:
if server_context is None:
raise ImproperlyConfigured(
"No Server object found in the database. Tip: please add one."
)

return {
"server": {
"ip": server_context.ip,
"production": server_context.production,
return {
"server": {
"ip": server_context.ip,
"production": server_context.production
}
}

else:
return {
"server": {
"ip": "",
"production": ""
}
}
}

0 comments on commit 6aac82e

Please sign in to comment.