diff --git a/fet2020/fet2020/middleware.py b/fet2020/fet2020/middleware.py index 32b32760..60615367 100644 --- a/fet2020/fet2020/middleware.py +++ b/fet2020/fet2020/middleware.py @@ -1,10 +1,5 @@ -# from django.contrib.auth.models import User from django.contrib.auth.middleware import RemoteUserMiddleware -# import django -# import logging -# logger=logging.getLogger("django.request") - class FETHeaderMiddleware(RemoteUserMiddleware): header = "Remote-User" @@ -13,9 +8,9 @@ class FETHeaderMiddleware(RemoteUserMiddleware): request.META[self.header] = request.META.get( self.header, request.headers.get(self.header, None) ) - # logger = logging.getLogger(__name__) + super().process_request(request) - # logger.info('User: ' + str(request.user)) + if request.user.is_authenticated: request.user.is_admin = True request.user.is_superuser = True diff --git a/fet2020/fet2020/settings.py b/fet2020/fet2020/settings.py index 71084d45..146e7da1 100644 --- a/fet2020/fet2020/settings.py +++ b/fet2020/fet2020/settings.py @@ -1,5 +1,5 @@ -import os import environ +import os from urllib.parse import urljoin env = environ.Env( @@ -36,10 +36,6 @@ LOGGING = { # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -# SESSION_COOKIE_DOMAIN = ".2020.fet.at" - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = env("DEBUG") @@ -50,14 +46,13 @@ else: SECRET_KEY = env("SECRET_KEY") +# HOST ALLOWED_HOSTS = ["127.0.0.1", env("HOST_NAME"), "fet.at"] - HOST_NAME = env("HOST_NAME") DATA_UPLOAD_MAX_MEMORY_SIZE = 1024 * 1024 * 1024 -# Application definition -CKEDITOR_UPLOAD_PATH = "upload" + INSTALLED_APPS = [ "django.contrib.admin", @@ -70,6 +65,7 @@ INSTALLED_APPS = [ "django.contrib.sites", "django.contrib.sitemaps", "django.contrib.flatpages", + "taggit", "ckeditor", "ckeditor_uploader", @@ -80,6 +76,7 @@ INSTALLED_APPS = [ "django_filters", "django_static_jquery_ui", "fontawesomefree", + "core.apps.CoreConfig", "posts.apps.PostsConfig", "members.apps.MembersConfig", @@ -126,7 +123,6 @@ WSGI_APPLICATION = "fet2020.wsgi.application" # Database -# https://docs.djangoproject.com/en/3.0/ref/settings/#databases if DEBUG: DATABASES = { "default": { @@ -151,9 +147,8 @@ AUTHENTICATION_BACKENDS = [ "django.contrib.auth.backends.ModelBackend", ] -# Password validation -# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators +# Password validation AUTH_PASSWORD_VALIDATORS = [ { "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", @@ -171,18 +166,11 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization -# https://docs.djangoproject.com/en/3.0/topics/i18n/ - LANGUAGE_CODE = "de-at" - TIME_ZONE = "CET" - USE_I18N = True - USE_L10N = True - USE_TZ = True - LOCALE_PATHS = [os.path.join(BASE_DIR, "locale")] @@ -191,8 +179,6 @@ SITE_ID = 1 # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.0/howto/static-files/ - if DEBUG: STATIC_URL = "/static/" else: @@ -203,8 +189,14 @@ STATIC_ROOT = "assets/" MEDIA_ROOT = os.path.join(BASE_DIR, "files/") MEDIA_URL = "/files/" + +# TAGGIT TAGGIT_FORCE_LOWERCASE = True + +#CKEDITOR +CKEDITOR_UPLOAD_PATH = "upload" + CKEDITOR_CONFIGS = { "default": { "stylesSet": [ @@ -219,23 +211,60 @@ CKEDITOR_CONFIGS = { "attributes": {"class": "code-block"}, }, ], - 'toolbar': 'Custom', - 'toolbar_Custom': [ - {'name': 'styles', 'items': ['Styles', 'Format', 'Font', 'FontSize']}, - {'name': 'tools', 'items': ['Maximize', 'ShowBlocks']}, - {'name': 'document', 'items': ['Source']}, - '/', - {'name': 'basicstyles', - 'items': ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat']}, - {'name': 'paragraph', - 'items': ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', - 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock']}, - {'name': 'links', 'items': ['Link', 'Unlink', 'Anchor']}, - {'name': 'insert', 'items': ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar']}, + "toolbar": "Custom", + "toolbar_Custom": [ + {"name": "styles", "items": ["Styles", "Format", "Font", "FontSize"]}, + {"name": "tools", "items": ["Maximize", "ShowBlocks"]}, + {"name": "document", "items": ["Source"]}, + "/", + { + "name": "basicstyles", + "items": [ + "Bold", + "Italic", + "Underline", + "Strike", + "Subscript", + "Superscript", + "-", + "RemoveFormat", + ], + }, + { + "name": "paragraph", + "items": [ + "NumberedList", + "BulletedList", + "-", + "Outdent", + "Indent", + "-", + "Blockquote", + "CreateDiv", + "-", + "JustifyLeft", + "JustifyCenter", + "JustifyRight", + "JustifyBlock", + ], + }, + {"name": "links", "items": ["Link", "Unlink", "Anchor"]}, + { + "name": "insert", + "items": [ + "Image", + "Flash", + "Table", + "HorizontalRule", + "Smiley", + "SpecialChar", + ], + }, ], } } + # THUMBNAIL THUMBNAIL_ALIASES = { "": { @@ -244,6 +273,9 @@ THUMBNAIL_ALIASES = { "portrait": {"size": (200, 300), "crop": False}, }, } + + +# ETHERPAD HOST ETHERPAD_HOST = env("ETHERPAD_HOST").strip() if not ETHERPAD_HOST or ETHERPAD_HOST == "": ETHERPAD_HOST = urljoin("https://" + env("HOST_NAME"), "etherpad/") @@ -264,6 +296,7 @@ else: "group": env("ETHERPAD_GROUP"), } + # REST FRAMEWORK REST_FRAMEWORK = { "DEFAULT_PERMISSION_CLASSES_CLASSES": [ @@ -272,19 +305,23 @@ REST_FRAMEWORK = { "DEFAULT_AUTHENTICATION_CLASSES": (), } + # DJANGO MAIL EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" EMAIL_HOST = "buran.htu.tuwien.ac.at" EMAIL_PORT = 587 EMAIL_USE_TLS = True + # CRON JOBS CRONJOBS = [ ("0 16 * * *", "posts.cronjobs.check_to_send_agenda_mail"), ] + # AUTHENTICATIONS LOGIN_URL = "/auth/login" + # MIGRATION FROM DJANGO 3.1 TO DJANGO 3.2 -DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' +DEFAULT_AUTO_FIELD = "django.db.models.AutoField" diff --git a/fet2020/fet2020/urls.py b/fet2020/fet2020/urls.py index 9c7018f3..1decfe61 100644 --- a/fet2020/fet2020/urls.py +++ b/fet2020/fet2020/urls.py @@ -1,20 +1,20 @@ +from rest_framework import routers + from django.conf import settings from django.conf.urls.static import static from django.contrib import admin, flatpages from django.contrib.sitemaps.views import sitemap from django.urls import include, path, re_path from django.views.generic import RedirectView -from rest_framework import routers from posts.viewsets import PostViewSet -from members.urls import member_urlpatterns, jobs_urlpatterns +from members.urls import jobs_urlpatterns, member_urlpatterns from members.viewsets import ( MemberViewSet, JobViewSet, JobGroupViewSet, JobMemberViewSet, ) - from . import views from .sitemaps import sitemaps @@ -41,18 +41,34 @@ urlpatterns = [ path("member/", include(member_urlpatterns), name="member"), path("posts/", include("posts.urls")), path("tasks/", include("tasks.urls"), name="tasks"), - path("discord/", RedirectView.as_view(url="https://discord.com/invite/7qRuuMA"), name="discord"), - path("facebook/", RedirectView.as_view(url="https://www.facebook.com/FachschaftET/"), name="facebook"), - path("instagram/", RedirectView.as_view(url="https://www.instagram.com/fet_tuwien/"), name="instagram"), - path("telegram/", RedirectView.as_view(url="https://t.me/FETInfo"), name="telegram"), + path( + "discord/", + RedirectView.as_view(url="https://discord.com/invite/7qRuuMA"), + name="discord", + ), + path( + "facebook/", + RedirectView.as_view(url="https://www.facebook.com/FachschaftET/"), + name="facebook", + ), + path( + "instagram/", + RedirectView.as_view(url="https://www.instagram.com/fet_tuwien/"), + name="instagram", + ), + path( + "telegram/", RedirectView.as_view(url="https://t.me/FETInfo"), name="telegram" + ), path( "sitemap.xml", sitemap, {"sitemaps": sitemaps}, name="django.contrib.sitemaps.views.sitemap", ), - path('pages/', include('django.contrib.flatpages.urls')), - re_path(r'^(?P.*/)$', flatpages.views.flatpage), - path('impressum/', flatpages.views.flatpage, {'url': '/impressum/'}, name='impressum'), - path('kontakt/', flatpages.views.flatpage, {'url': '/kontakt/'}, name='contact'), + path("pages/", include("django.contrib.flatpages.urls")), + re_path(r"^(?P.*/)$", flatpages.views.flatpage), + path( + "impressum/", flatpages.views.flatpage, {"url": "/impressum/"}, name="impressum" + ), + path("kontakt/", flatpages.views.flatpage, {"url": "/kontakt/"}, name="contact"), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/fet2020/fet2020/views.py b/fet2020/fet2020/views.py index 1f806f12..1130474f 100644 --- a/fet2020/fet2020/views.py +++ b/fet2020/fet2020/views.py @@ -1,7 +1,7 @@ +from collections import deque + from django.shortcuts import render -# from django.http import HttpResponse -from collections import deque from posts.models import Post, FetMeeting, Event