diff --git a/.gitignore b/.gitignore index 4cc39e5..80cc11d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ __pycache__ clubhaus/static/**/* .DS_Store +django.log # Created by https://www.toptal.com/developers/gitignore/api/jetbrains # Edit at https://www.toptal.com/developers/gitignore?templates=jetbrains diff --git a/clubhaus/clubhaus/settings.py b/clubhaus/clubhaus/settings.py index b3dea6f..4f40e2e 100644 --- a/clubhaus/clubhaus/settings.py +++ b/clubhaus/clubhaus/settings.py @@ -139,4 +139,39 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' IP_RATE_LIMIT_TIME = int(os.getenv("IP_RATE_LIMIT_TIME", "3600")) IP_RATE_LIMIT_COUNT = int(os.getenv("IP_RATE_LIMIT_COUNT", "2")) +# LOGGING +LOGGING = { + "version": 1, + # The version number of our log + "disable_existing_loggers": False, + "formatters": { + "simple": { + "format": "[{levelname}][{asctime}][{funcName}]: {message}", + "style": "{", + }, + }, + # django uses some of its own loggers for internal operations. + # In case you want to disable them just replace the False above with true. + # A handler for WARNING. It is basically writing the WARNING messages into a file called WARNING.log + "handlers": { + "file": { + "level": "WARNING", + "class": "logging.handlers.RotatingFileHandler", + "maxBytes": 1024 * 1024 * 5, # 5 MB + "backupCount": 5, + "filename": BASE_DIR / "django.log", + "formatter": "simple", + }, + }, + # A logger for WARNING which has a handler called 'file'. A logger can have multiple handler + "loggers": { + # notice the blank '', Usually you would put built in loggers like django or root here based on your needs + "": { + "handlers": ["file"], # notice how file variable is called in handler which has been defined above + "level": "WARNING", + "propagate": True, + }, + }, +} + # TODO: delete devserver port forward in windows firewall in hammerhead diff --git a/clubhaus/clubhaus/urls.py b/clubhaus/clubhaus/urls.py index dd19822..c5ba218 100644 --- a/clubhaus/clubhaus/urls.py +++ b/clubhaus/clubhaus/urls.py @@ -16,11 +16,15 @@ Including another URLconf from django.conf import settings from django.conf.urls.static import static from django.contrib import admin -from django.urls import path, include +from django.urls import path, include, re_path +from django.views.generic import RedirectView + +favicon_view = RedirectView.as_view(url='/static/favicon.ico', permanent=True) urlpatterns = [ path('', include('homepage.urls')), path('admin/', admin.site.urls), + re_path(r'^favicon\.ico$', favicon_view), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) handler400 = "homepage.views.bad_request" diff --git a/clubhaus/homepage/exceptions.py b/clubhaus/homepage/exceptions.py index a8bc423..8aa3618 100644 --- a/clubhaus/homepage/exceptions.py +++ b/clubhaus/homepage/exceptions.py @@ -2,16 +2,16 @@ from django.core import exceptions class RateLimitHit(exceptions.SuspiciousOperation): - def __init__(self): - self.text = "You made to many request in a short period of time! Please try again later" + def __init__(self, ip: str): + self.text = f"You made to many request in a short period of time! Please try again later. Your IP: {ip}" def __str__(self): return f"{self.__class__.__name__}: {self.text}" class ProxyUsageDetected(exceptions.SuspiciousOperation): - def __init__(self): - self.text = "It appears you are using a proxy! We don't want you to do that!" + def __init__(self, proxy: str): + self.text = f"It appears you are using a proxy! We don't want you to do that! Your Proxy IP: {proxy}" def __str__(self): return f"{self.__class__.__name__}: {self.text}" diff --git a/clubhaus/homepage/static/favicon.ico b/clubhaus/homepage/static/favicon.ico new file mode 100644 index 0000000..92a8f65 Binary files /dev/null and b/clubhaus/homepage/static/favicon.ico differ diff --git a/clubhaus/homepage/static/homepage/web-party.jpg b/clubhaus/homepage/static/homepage/web-party.jpg deleted file mode 100644 index d2774fa..0000000 Binary files a/clubhaus/homepage/static/homepage/web-party.jpg and /dev/null differ diff --git a/clubhaus/homepage/templates/homepage/base.html b/clubhaus/homepage/templates/homepage/base.html index 9f33590..eee2741 100644 --- a/clubhaus/homepage/templates/homepage/base.html +++ b/clubhaus/homepage/templates/homepage/base.html @@ -11,12 +11,12 @@ + content="https://{{ request.get_host }}{% static 'homepage/logo-with-text.svg' %}"> - +
- {{ next_event.date|date:"d.m.Y" }}
-
- ab {{ next_event.date|date:"H:i" }} Uhr
-
+ {{ next_event.date|date:"d.m.Y" }}
+
+ ab {{ next_event.date|date:"H:i" }} Uhr
+
+ coming
+
+ soon
+