Skip to content

Commit

Permalink
Quality of code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
tudoramariei committed Oct 2, 2024
1 parent 09b4821 commit 88fc612
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion backend/donations/views/ngo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.shortcuts import redirect, render
from django.urls import reverse
from django.utils import timezone
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView
from ipware import get_client_ip

Expand Down
19 changes: 11 additions & 8 deletions backend/redirectioneaza/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import environ
import sentry_sdk
from cryptography.fernet import Fernet
from django.urls import reverse_lazy
from django.templatetags.static import static
from django.urls import reverse_lazy
from django.utils import timezone
from localflavor.ro.ro_counties import COUNTIES_CHOICES

Expand Down Expand Up @@ -189,18 +189,20 @@
# some settings will be different if it's not running in a container (e.g., locally, on a Mac)
IS_CONTAINERIZED = env.bool("IS_CONTAINERIZED")

DEFAULT_REVISION_STRING = "dev"

VERSION = env.str("VERSION", "edge")
REVISION = env.str("REVISION", "develop")
REVISION = env.str("REVISION", DEFAULT_REVISION_STRING)
REVISION = REVISION[:7]

if IS_CONTAINERIZED and VERSION == "edge" and REVISION == "develop":
if IS_CONTAINERIZED and VERSION == "edge" and REVISION == DEFAULT_REVISION_STRING:
version_file = "/var/www/redirect/.version"
if os.path.exists(version_file):
with open(version_file) as f:
VERSION, REVISION = f.read().strip().split("+")

REVISION = REVISION[:7]

VERSION_SUFFIX = f"redirect@{VERSION}+{REVISION}"
VERSION_SUFFIX = f"{VERSION}+{REVISION}"
VERSION_LABEL = f"redirect@{VERSION_SUFFIX}"


# Sentry
Expand All @@ -216,7 +218,7 @@
# We recommend adjusting this value in production.
profiles_sample_rate=env.float("SENTRY_PROFILES_SAMPLE_RATE"),
environment=ENVIRONMENT,
release=VERSION_SUFFIX,
release=VERSION_LABEL,
)


Expand Down Expand Up @@ -612,9 +614,10 @@
CONTACT_EMAIL_ADDRESS = env.str("CONTACT_EMAIL_ADDRESS")

# Unfold Admin settings
# https://unfoldadmin.com/docs/configuration/settings/
# Supported icon set: https://fonts.google.com/icons
UNFOLD = {
"SITE_TITLE": TITLE,
"SITE_HEADER": f"Admin | {VERSION_SUFFIX}",
"SITE_ICON": lambda request: static("images/logo-smaller.png"),
"SITE_LOGO": lambda request: static("images/logo-smaller.png"),
"SITE_FAVICONS": [
Expand Down
2 changes: 1 addition & 1 deletion backend/redirectioneaza/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
)
from redirectioneaza.views import StaticPageView

admin.site.site_header = f"Admin | {settings.VERSION_SUFFIX}"
admin.site.site_header = f"Admin | {settings.VERSION_LABEL}"


urlpatterns = (
Expand Down

0 comments on commit 88fc612

Please sign in to comment.