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