From acfbc6c960121dad691058aceda2e23413434ff3 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Sun, 31 Jan 2021 01:09:52 +0100 Subject: [PATCH] Experimenting with django-cms --- .../__init__.py | 0 aplikacjawww_djangocms/asgi.py | 16 + {wwwapp => aplikacjawww_djangocms}/auth.py | 0 .../migrations/0001_do_stuff.py | 88 +++++ aplikacjawww_djangocms/migrations/__init__.py | 0 .../settings_common.py | 339 +++++++++++++----- aplikacjawww_djangocms/settings_debug.py | 15 + .../settings_prod.py | 2 +- .../static}/django_select2/django_select2.js | 0 .../static}/django_tinymce/init_tinymce.js | 0 .../static}/images/favicon-16x16.png | Bin .../static}/images/favicon-180x180.png | Bin .../static}/images/favicon-192x192.png | Bin .../static}/images/favicon-32x32.png | Bin .../static}/images/favicon-512x512.png | Bin .../static}/images/favicon.ico | Bin .../static}/images/favicon.png | Bin .../static}/images/fb_image-cut.jpg | Bin .../static}/images/fb_image.jpg | Bin .../static}/images/graph_black.png | Bin .../static}/images/login_buttons/facebook.svg | 0 .../images/login_buttons/google-oauth2.svg | 0 .../static}/images/logo_transparent.png | Bin .../static}/images/logo_transparent.svg | 0 .../static}/images/logo_transparent_black.svg | 0 .../static}/images/logo_w.png | Bin .../static}/images/logo_w.svg | 0 .../templates}/_analytics.html | 0 aplikacjawww_djangocms/templates/base.html | 80 +++++ aplikacjawww_djangocms/templates/menu.html | 19 + .../templates/page_basic.html | 20 ++ .../templates/page_index.html | 32 ++ aplikacjawww_djangocms/urls.py | 42 +++ aplikacjawww_djangocms/views.py | 5 + {wwwapp => aplikacjawww_djangocms}/wsgi.py | 8 +- manage.py | 2 +- requirements.txt | 28 +- templates/base.html | 200 ----------- webpack.config.js | 2 +- wwwapp/cms_menus.py | 170 +++++++++ wwwapp/settings_debug.py | 33 -- .../templates}/_pastParticipation.html | 0 .../templates}/_programworkshop.html | 0 .../templates}/_qualificationsTable.html | 0 .../templates}/_socialButton.html | 0 .../templates}/_statusLabel.html | 0 .../templates}/_workshopStatusTable.html | 0 {templates => wwwapp/templates}/article.html | 2 +- .../templates}/articleedit.html | 2 +- .../templates}/filteredEmails.html | 2 +- {templates => wwwapp/templates}/form.html | 2 +- {templates => wwwapp/templates}/formlist.html | 2 +- .../templates}/formresults.html | 2 +- .../templates}/lecturers.html | 2 +- .../templates}/listworkshop.html | 2 +- {templates => wwwapp/templates}/login.html | 2 +- .../templates}/loginMerge.html | 2 +- .../templates}/mydata_base.html | 2 +- .../templates}/mydata_coverletter.html | 0 .../templates}/mydata_forms.html | 0 .../templates}/mydata_profile.html | 0 .../templates}/mydata_profilepage.html | 0 .../templates}/mydata_status.html | 0 .../templates}/participants.html | 2 +- {templates => wwwapp/templates}/profile.html | 2 +- {templates => wwwapp/templates}/program.html | 2 +- .../templates}/workshopbase.html | 2 +- .../templates}/workshopedit.html | 0 .../templates}/workshoppage.html | 0 .../templates}/workshopparticipants.html | 0 .../templates}/workshopsolution.html | 0 wwwapp/templates/wwwapp_base.html | 48 +++ wwwapp/urls.py | 24 -- wwwapp/views.py | 13 - 74 files changed, 834 insertions(+), 382 deletions(-) rename templates/robots.txt => aplikacjawww_djangocms/__init__.py (100%) create mode 100644 aplikacjawww_djangocms/asgi.py rename {wwwapp => aplikacjawww_djangocms}/auth.py (100%) create mode 100644 aplikacjawww_djangocms/migrations/0001_do_stuff.py create mode 100644 aplikacjawww_djangocms/migrations/__init__.py rename {wwwapp => aplikacjawww_djangocms}/settings_common.py (59%) create mode 100644 aplikacjawww_djangocms/settings_debug.py rename {wwwapp => aplikacjawww_djangocms}/settings_prod.py (95%) rename {static => aplikacjawww_djangocms/static}/django_select2/django_select2.js (100%) rename {static => aplikacjawww_djangocms/static}/django_tinymce/init_tinymce.js (100%) rename {static => aplikacjawww_djangocms/static}/images/favicon-16x16.png (100%) rename {static => aplikacjawww_djangocms/static}/images/favicon-180x180.png (100%) rename {static => aplikacjawww_djangocms/static}/images/favicon-192x192.png (100%) rename {static => aplikacjawww_djangocms/static}/images/favicon-32x32.png (100%) rename {static => aplikacjawww_djangocms/static}/images/favicon-512x512.png (100%) rename {static => aplikacjawww_djangocms/static}/images/favicon.ico (100%) rename {static => aplikacjawww_djangocms/static}/images/favicon.png (100%) rename {static => aplikacjawww_djangocms/static}/images/fb_image-cut.jpg (100%) rename {static => aplikacjawww_djangocms/static}/images/fb_image.jpg (100%) rename {static => aplikacjawww_djangocms/static}/images/graph_black.png (100%) rename {static => aplikacjawww_djangocms/static}/images/login_buttons/facebook.svg (100%) rename {static => aplikacjawww_djangocms/static}/images/login_buttons/google-oauth2.svg (100%) rename {static => aplikacjawww_djangocms/static}/images/logo_transparent.png (100%) rename {static => aplikacjawww_djangocms/static}/images/logo_transparent.svg (100%) rename {static => aplikacjawww_djangocms/static}/images/logo_transparent_black.svg (100%) rename {static => aplikacjawww_djangocms/static}/images/logo_w.png (100%) rename {static => aplikacjawww_djangocms/static}/images/logo_w.svg (100%) rename {templates => aplikacjawww_djangocms/templates}/_analytics.html (100%) create mode 100644 aplikacjawww_djangocms/templates/base.html create mode 100644 aplikacjawww_djangocms/templates/menu.html create mode 100644 aplikacjawww_djangocms/templates/page_basic.html create mode 100644 aplikacjawww_djangocms/templates/page_index.html create mode 100644 aplikacjawww_djangocms/urls.py create mode 100644 aplikacjawww_djangocms/views.py rename {wwwapp => aplikacjawww_djangocms}/wsgi.py (53%) delete mode 100644 templates/base.html create mode 100644 wwwapp/cms_menus.py delete mode 100644 wwwapp/settings_debug.py rename {templates => wwwapp/templates}/_pastParticipation.html (100%) rename {templates => wwwapp/templates}/_programworkshop.html (100%) rename {templates => wwwapp/templates}/_qualificationsTable.html (100%) rename {templates => wwwapp/templates}/_socialButton.html (100%) rename {templates => wwwapp/templates}/_statusLabel.html (100%) rename {templates => wwwapp/templates}/_workshopStatusTable.html (100%) rename {templates => wwwapp/templates}/article.html (95%) rename {templates => wwwapp/templates}/articleedit.html (93%) rename {templates => wwwapp/templates}/filteredEmails.html (94%) rename {templates => wwwapp/templates}/form.html (88%) rename {templates => wwwapp/templates}/formlist.html (97%) rename {templates => wwwapp/templates}/formresults.html (98%) rename {templates => wwwapp/templates}/lecturers.html (98%) rename {templates => wwwapp/templates}/listworkshop.html (99%) rename {templates => wwwapp/templates}/login.html (97%) rename {templates => wwwapp/templates}/loginMerge.html (97%) rename {templates => wwwapp/templates}/mydata_base.html (97%) rename {templates => wwwapp/templates}/mydata_coverletter.html (100%) rename {templates => wwwapp/templates}/mydata_forms.html (100%) rename {templates => wwwapp/templates}/mydata_profile.html (100%) rename {templates => wwwapp/templates}/mydata_profilepage.html (100%) rename {templates => wwwapp/templates}/mydata_status.html (100%) rename {templates => wwwapp/templates}/participants.html (99%) rename {templates => wwwapp/templates}/profile.html (99%) rename {templates => wwwapp/templates}/program.html (98%) rename {templates => wwwapp/templates}/workshopbase.html (98%) rename {templates => wwwapp/templates}/workshopedit.html (100%) rename {templates => wwwapp/templates}/workshoppage.html (100%) rename {templates => wwwapp/templates}/workshopparticipants.html (100%) rename {templates => wwwapp/templates}/workshopsolution.html (100%) create mode 100644 wwwapp/templates/wwwapp_base.html diff --git a/templates/robots.txt b/aplikacjawww_djangocms/__init__.py similarity index 100% rename from templates/robots.txt rename to aplikacjawww_djangocms/__init__.py diff --git a/aplikacjawww_djangocms/asgi.py b/aplikacjawww_djangocms/asgi.py new file mode 100644 index 00000000..6cf81e63 --- /dev/null +++ b/aplikacjawww_djangocms/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for aplikacjawww_djangocms project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'aplikacjawww_djangocms.settings_prod') + +application = get_asgi_application() diff --git a/wwwapp/auth.py b/aplikacjawww_djangocms/auth.py similarity index 100% rename from wwwapp/auth.py rename to aplikacjawww_djangocms/auth.py diff --git a/aplikacjawww_djangocms/migrations/0001_do_stuff.py b/aplikacjawww_djangocms/migrations/0001_do_stuff.py new file mode 100644 index 00000000..9f3cbccc --- /dev/null +++ b/aplikacjawww_djangocms/migrations/0001_do_stuff.py @@ -0,0 +1,88 @@ +# Generated by Django 3.1.5 on 2021-01-30 23:19 + +from django.db import migrations + + +def forwards_func(apps, schema_editor): + from cms.api import create_page, add_plugin, publish_page + Article = apps.get_model('wwwapp', 'Article') + + Site = apps.get_model('sites', 'Site') + Site.objects.create(domain='warsztatywww.pl', name='Wakacyjne Warsztaty Wielodyscyplinarne') + + index_article = Article.objects.get(name='index') + index_page = create_page(title='Strona główna', template='page_index.html', language='pl', slug='index', in_navigation=True) + add_plugin(index_page.placeholders.get(slot='header_image'), 'Bootstrap4PicturePlugin', 'pl', external_picture='https://warsztatywww.pl/media/images/articles/index/64f5e2127a13b64d5624058ee812904d297e8e15d81a449dafda59563a18ed64.jpg') + add_plugin(index_page.placeholders.get(slot='left_of_facebook_embed'), 'TextPlugin', 'pl', body=''' +

16. Wakacyjne Warsztaty Wielodyscyplinarne odbyły się 3-17 lipca 2020 roku.

+ +

Chętnych do poprowadzenia zajęć zapraszamy do działu dla prowadzących. Chętnych do wzięcia udziału w kolejnej edycji kierujemy do działu dla uczestników.

+ +

Program

+ +

 

+ +

Terminy WWW16 (2020)

+ + + + + + + + + + + + + + + + + + + + +
Do 1 kwietniaPojawiają się strony warsztatów i zadania kwalifikacyjne
1 kwietnia - 17 maja 20 majaCzas na rozwiązywanie zadań kwalifikacyjnych przez uczestników
4 czerwcaInformacja o kwalifikacji uczestników
3 - 17 lipcaZdalne warsztaty
+''') + add_plugin(index_page.placeholders.get(slot='content'), 'TextPlugin', 'pl', body=''' +

O Warsztatach

+ +

Wakacyjne Warsztaty Wielodyscyplinarne to coroczne wydarzenie przeznaczone dla licealistów zainteresowanych matematyką, informatyką, fizyką, astronomią lub biologią. Zajęcia prowadzi grupa zaprzyjaźnionych studentów z całej polski pod patronatem Społeczności MIMUW, Miasta Zabrze i Uniwersytetu Warszawskiego.

+ +

Każdy uczestnik Warsztatów może wybrać kilka spośród kilkunastu propozycji kilkudniowych bloków zajęć. Zajęcia odbywają się w małych grupach i mają charakter warsztatowy. Obok wykładów bardzo istotna jest część praktyczna – rozwiązywanie zadań, pisanie programów. Wieczorami można uczestniczyć w "luźnych" wykładach i prezentacjach, niezwiązanych z żadnym blokiem zajęć, i poruszających różne ciekawe tematy z, ale również spoza, zakresu nauk ścisłych – lub samemu wygłosić taki wykład! A pozanaukowo – integracja, gry i zabawy; dla chętnych przeprowadzamy przyspieszony kurs brydża i go, bardziej zaawansowani gracze mogą spróbować swoich sił w turnieju, a każdy może zagrać w seta, rpg, planszówki, czy pośpiewać ogniskowe piosenki.

+ +

W związku z Warsztatami powstał Drogowskaz Pasjonata – poradnik dla młodych zdolnych licealistów, którzy chcą rozwijać swoje talenty (niezależnie czy byli/będą na WWW czy nie). Tekst polecamy zarówno powyższym, jak i osobom, które mają z nimi styczność (rodzice, nauczyciele, tutorzy).

+ +

Zachęcamy do lektury: An independent camp for high school geeks – tekst po angielsku o tym, co to są Wakacyjne Warsztaty Wielodyscyplinarne, co jest w nich szczególnego i jak tę wiedzę można wykorzystać.

+ +

Chętnych do prowadzenia zajęć zachęcamy do zapoznania się z informacjami dla prowadzących.

+ +

Zobacz też program poprzednich warsztatów i zdjęcia z poprzednich edycji.

+''') + index_page.set_as_homepage() + index_page.publish('pl') + + for article in Article.objects.exclude(name__in=['index', 'template_for_workshop_page']).all(): + page = create_page(title=article.title, template='page_basic.html', language='pl', slug=article.name, in_navigation=article.on_menubar) + add_plugin(page.placeholders.get(slot='content'), 'TextPlugin', 'pl', body=article.content) + page.publish('pl') + + Article.objects.exclude(name='template_for_workshop_page').delete() + + +class Migration(migrations.Migration): + + dependencies = [ + ('wwwapp', '0072_change_upload_storage'), + ('menus', '0001_initial'), + ('sites', '0002_alter_domain_unique'), + ('cms', '0022_auto_20180620_1551'), + ('djangocms_text_ckeditor', '0004_auto_20160706_1339'), + ('djangocms_picture', '0011_auto_20190314_1536'), + ('bootstrap4_picture', '0004_auto_20190703_0831'), + ] + + operations = [ + migrations.RunPython(forwards_func) + ] diff --git a/aplikacjawww_djangocms/migrations/__init__.py b/aplikacjawww_djangocms/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/wwwapp/settings_common.py b/aplikacjawww_djangocms/settings_common.py similarity index 59% rename from wwwapp/settings_common.py rename to aplikacjawww_djangocms/settings_common.py index 608c3604..da0b6d10 100644 --- a/wwwapp/settings_common.py +++ b/aplikacjawww_djangocms/settings_common.py @@ -1,31 +1,192 @@ -import os -import datetime +import os # isort:skip +gettext = lambda s: s +DATA_DIR = os.path.dirname(os.path.dirname(__file__)) +""" +Django settings for aplikacjawww_djangocms project. + +Generated by 'django-admin startproject' using Django 3.1.5. + +For more information on this file, see +https://docs.djangoproject.com/en/3.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.1/ref/settings/ +""" from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve(strict=True).parent.parent +BASE_DIR = Path(__file__).resolve().parent.parent -# E-mail settings -ADMINS = (('Sebastian Jaszczur', 'sebastian.jaszczur+aplikacjawww@gmail.com'), - ('Marcin Wrochna', 'mwrochna+django@gmail.com'), - ('Michał Zieliński', 'michal@zielinscy.org.pl'), - ('Artur Puzio', 'wwwdjango@puzio.waw.pl'), - ('Krzysztof Haładyn', 'krzys_h@interia.pl'), - ) +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'f$4ijluexy!08mdu()p0ccg#b@k+z+i-oo$+mgva@!ebx$u&yt' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] -MANAGERS = ADMINS # Application definition -INSTALLED_APPS = ( - 'django.contrib.admin', + + + + +ROOT_URLCONF = 'aplikacjawww_djangocms.urls' + + + +WSGI_APPLICATION = 'aplikacjawww_djangocms.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.1/ref/settings/#databases + + + + +# Password validation +# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/3.1/topics/i18n/ + +LANGUAGE_CODE = 'pl' + +TIME_ZONE = 'Europe/Warsaw' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/3.1/howto/static-files/ + +STATIC_URL = '/static/' +MEDIA_URL = '/media/' +SENDFILE_URL = '/uploads/' +MEDIA_ROOT = os.path.join(DATA_DIR, 'media') +STATIC_ROOT = os.path.join(DATA_DIR, 'static') +SENDFILE_ROOT = os.path.join(DATA_DIR, 'uploads') + +SENDFILE_BACKEND = 'django_sendfile.backends.development' + +STATICFILES_DIRS = ( + os.path.join(BASE_DIR, 'aplikacjawww_djangocms', 'static'), +) +SITE_ID = 1 + + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR, 'aplikacjawww_djangocms', 'templates'),], + 'OPTIONS': { + 'context_processors': [ + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + 'django.template.context_processors.i18n', + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.template.context_processors.media', + 'django.template.context_processors.csrf', + 'django.template.context_processors.tz', + 'sekizai.context_processors.sekizai', + 'django.template.context_processors.static', + 'cms.context_processors.cms_settings', + 'social_django.context_processors.backends', + 'social_django.context_processors.login_redirect', + 'wwwapp.views.get_context', + ], + 'loaders': [ + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader' + ], + }, + }, +] + + +MIDDLEWARE = [ + 'cms.middleware.utils.ApphookReloadMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.locale.LocaleMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'cms.middleware.user.CurrentUserMiddleware', + 'cms.middleware.page.CurrentPageMiddleware', + 'cms.middleware.toolbar.ToolbarMiddleware', + 'cms.middleware.language.LanguageCookieMiddleware', + 'aplikacjawww_djangocms.auth.CustomSocialAuthExceptionMiddleware', + 'wwwapp.models.cache_latest_camp_middleware', +] + +INSTALLED_APPS = [ + 'djangocms_admin_style', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', - 'django.contrib.messages', + 'django.contrib.admin', + 'django.contrib.sites', + 'django.contrib.sitemaps', 'django.contrib.staticfiles', + 'django.contrib.messages', + 'cms', + 'menus', + 'sekizai', + 'treebeard', + 'djangocms_text_ckeditor', + 'filer', + 'easy_thumbnails', + 'djangocms_bootstrap4', + 'djangocms_bootstrap4.contrib.bootstrap4_alerts', + 'djangocms_bootstrap4.contrib.bootstrap4_badge', + 'djangocms_bootstrap4.contrib.bootstrap4_card', + 'djangocms_bootstrap4.contrib.bootstrap4_carousel', + 'djangocms_bootstrap4.contrib.bootstrap4_collapse', + 'djangocms_bootstrap4.contrib.bootstrap4_content', + 'djangocms_bootstrap4.contrib.bootstrap4_grid', + 'djangocms_bootstrap4.contrib.bootstrap4_jumbotron', + 'djangocms_bootstrap4.contrib.bootstrap4_link', + 'djangocms_bootstrap4.contrib.bootstrap4_listgroup', + 'djangocms_bootstrap4.contrib.bootstrap4_media', + 'djangocms_bootstrap4.contrib.bootstrap4_picture', + 'djangocms_bootstrap4.contrib.bootstrap4_tabs', + 'djangocms_bootstrap4.contrib.bootstrap4_utilities', + 'djangocms_file', + 'djangocms_icon', + 'djangocms_link', + 'djangocms_picture', + 'djangocms_style', + 'djangocms_googlemap', + 'djangocms_video', 'social_django', 'crispy_forms', 'django_select2', @@ -37,26 +198,88 @@ 'django_cleanup', 'imagekit', 'gallery', + 'aplikacjawww_djangocms' +] + +LANGUAGES = ( + # ('en', gettext('en')), + ('pl', gettext('pl')), ) -SOCIAL_AUTH_POSTGRES_JSONFIELD = True +CMS_LANGUAGES = { + 1: [ + # { + # 'code': 'en', + # 'name': gettext('en'), + # 'redirect_on_fallback': True, + # 'public': True, + # 'hide_untranslated': False, + # }, + { + 'code': 'pl', + 'name': gettext('pl'), + 'redirect_on_fallback': True, + 'public': True, + 'hide_untranslated': False, + }, + ], + 'default': { + 'redirect_on_fallback': True, + 'public': True, + 'hide_untranslated': False, + }, +} +CMS_TEMPLATES = ( + ('page_basic.html', 'Page'), + ('page_index.html', 'Main page'), +) -MIDDLEWARE = ( - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'django.middleware.security.SecurityMiddleware', - 'wwwapp.auth.CustomSocialAuthExceptionMiddleware', - 'wwwapp.models.cache_latest_camp_middleware', +X_FRAME_OPTIONS = 'DENY' + +INTERNAL_IPS = ['127.0.0.1'] + +CMS_PERMISSION = True + +CMS_PLACEHOLDER_CONF = {} + +DATABASES = { + 'default': { + 'CONN_MAX_AGE': 0, + 'ENGINE': 'django.db.backends.sqlite3', + 'HOST': 'localhost', + 'NAME': 'database.sqlite3', + 'PASSWORD': '', + 'PORT': '', + 'USER': '' + } +} + +THUMBNAIL_PROCESSORS = ( + 'easy_thumbnails.processors.colorspace', + 'easy_thumbnails.processors.autocrop', + 'filer.thumbnail_processors.scale_and_crop_with_subject_location', + 'easy_thumbnails.processors.filters' ) -ROOT_URLCONF = 'wwwapp.urls' -WSGI_APPLICATION = 'wwwapp.wsgi.application' + + + + + +# E-mail settings + +ADMINS = (('Sebastian Jaszczur', 'sebastian.jaszczur+aplikacjawww@gmail.com'), + ('Marcin Wrochna', 'mwrochna+django@gmail.com'), + ('Michał Zieliński', 'michal@zielinscy.org.pl'), + ('Artur Puzio', 'wwwdjango@puzio.waw.pl'), + ('Krzysztof Haładyn', 'krzys_h@interia.pl'), + ) + +MANAGERS = ADMINS + +SOCIAL_AUTH_POSTGRES_JSONFIELD = True # Set cripsy forms template pack CRISPY_TEMPLATE_PACK = 'bootstrap4' @@ -135,60 +358,6 @@ SOCIAL_AUTH_FACEBOOK_KEY = os.getenv('SOCIAL_AUTH_FACEBOOK_KEY') SOCIAL_AUTH_FACEBOOK_SECRET = os.getenv('SOCIAL_AUTH_FACEBOOK_SECRET') -# Internationalization -# https://docs.djangoproject.com/en/3.1/topics/i18n/ - -LANGUAGE_CODE = 'pl' - -TIME_ZONE = 'Europe/Warsaw' - -USE_I18N = True - -USE_L10N = True - -USE_TZ = True - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.1/howto/static-files/ -STATICFILES_DIRS = ( - # Put strings here, like "/home/html/static" or "C:/www/django/static". - # Always use forward slashes, even on Windows. - # Don't forget to use absolute paths, not relative paths. - os.path.join(BASE_DIR, 'static'), -) -STATIC_ROOT = os.path.join(BASE_DIR, os.pardir, 'static') -STATIC_URL = '/static/' - -STATICFILES_FINDERS = ( - 'django.contrib.staticfiles.finders.FileSystemFinder', - 'django.contrib.staticfiles.finders.AppDirectoriesFinder', -) - -MEDIA_URL = '/media/' -SENDFILE_URL = '/uploads/' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': ['templates'], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - 'django.template.context_processors.request', - 'django.template.context_processors.debug', - 'django.template.context_processors.media', - 'django.template.context_processors.i18n', - 'django.template.context_processors.static', - 'social_django.context_processors.backends', - 'social_django.context_processors.login_redirect', - 'wwwapp.views.get_context', - ], - }, - }, -] - SELECT2_JS = '' SELECT2_CSS = '' @@ -219,10 +388,6 @@ 'file_picker_callback': 'tinymce_local_file_picker', } -INTERNAL_IPS = [ - '127.0.0.1', -] - # Max amount of points that a participant can get during qualification (relative to configured max_points for a given workshop) # This allows to give some people bonus points above 100% # Note that this is not a hard limit for values that can be entered by lecturers, excessive values will just be clamped for percentage calculation @@ -231,6 +396,4 @@ GALLERY_LOGO_PATH = 'images/logo_transparent.png' GALLERY_TITLE = 'Galeria WWW' GALLERY_FOOTER_INFO = 'Wakacyjne Warsztaty Wielodyscyplinarne' -GALLERY_FOOTER_EMAIL = '' - -X_FRAME_OPTIONS = 'DENY' +GALLERY_FOOTER_EMAIL = '' \ No newline at end of file diff --git a/aplikacjawww_djangocms/settings_debug.py b/aplikacjawww_djangocms/settings_debug.py new file mode 100644 index 00000000..30f8638d --- /dev/null +++ b/aplikacjawww_djangocms/settings_debug.py @@ -0,0 +1,15 @@ +from aplikacjawww_djangocms.settings_common import * + +SECRET_KEY = ')_7av^!cy(wfx=k#3*7x+(=j^fzv+ot^1@sh9s9t=8$bu@r(z$' + +DEBUG = True +TEMPLATES[0]['OPTIONS']['debug'] = DEBUG +ALLOWED_HOSTS = ["*"] + +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + +INSTALLED_APPS = INSTALLED_APPS + ['debug_toolbar'] + +MIDDLEWARE = ['debug_toolbar.middleware.DebugToolbarMiddleware'] + MIDDLEWARE + +GOOGLE_ANALYTICS_KEY = None diff --git a/wwwapp/settings_prod.py b/aplikacjawww_djangocms/settings_prod.py similarity index 95% rename from wwwapp/settings_prod.py rename to aplikacjawww_djangocms/settings_prod.py index 88a3da6c..9e1b3166 100644 --- a/wwwapp/settings_prod.py +++ b/aplikacjawww_djangocms/settings_prod.py @@ -1,4 +1,4 @@ -from .settings_common import * +from aplikacjawww_djangocms.settings_common import * SECRET_KEY = None # set in local_settings diff --git a/static/django_select2/django_select2.js b/aplikacjawww_djangocms/static/django_select2/django_select2.js similarity index 100% rename from static/django_select2/django_select2.js rename to aplikacjawww_djangocms/static/django_select2/django_select2.js diff --git a/static/django_tinymce/init_tinymce.js b/aplikacjawww_djangocms/static/django_tinymce/init_tinymce.js similarity index 100% rename from static/django_tinymce/init_tinymce.js rename to aplikacjawww_djangocms/static/django_tinymce/init_tinymce.js diff --git a/static/images/favicon-16x16.png b/aplikacjawww_djangocms/static/images/favicon-16x16.png similarity index 100% rename from static/images/favicon-16x16.png rename to aplikacjawww_djangocms/static/images/favicon-16x16.png diff --git a/static/images/favicon-180x180.png b/aplikacjawww_djangocms/static/images/favicon-180x180.png similarity index 100% rename from static/images/favicon-180x180.png rename to aplikacjawww_djangocms/static/images/favicon-180x180.png diff --git a/static/images/favicon-192x192.png b/aplikacjawww_djangocms/static/images/favicon-192x192.png similarity index 100% rename from static/images/favicon-192x192.png rename to aplikacjawww_djangocms/static/images/favicon-192x192.png diff --git a/static/images/favicon-32x32.png b/aplikacjawww_djangocms/static/images/favicon-32x32.png similarity index 100% rename from static/images/favicon-32x32.png rename to aplikacjawww_djangocms/static/images/favicon-32x32.png diff --git a/static/images/favicon-512x512.png b/aplikacjawww_djangocms/static/images/favicon-512x512.png similarity index 100% rename from static/images/favicon-512x512.png rename to aplikacjawww_djangocms/static/images/favicon-512x512.png diff --git a/static/images/favicon.ico b/aplikacjawww_djangocms/static/images/favicon.ico similarity index 100% rename from static/images/favicon.ico rename to aplikacjawww_djangocms/static/images/favicon.ico diff --git a/static/images/favicon.png b/aplikacjawww_djangocms/static/images/favicon.png similarity index 100% rename from static/images/favicon.png rename to aplikacjawww_djangocms/static/images/favicon.png diff --git a/static/images/fb_image-cut.jpg b/aplikacjawww_djangocms/static/images/fb_image-cut.jpg similarity index 100% rename from static/images/fb_image-cut.jpg rename to aplikacjawww_djangocms/static/images/fb_image-cut.jpg diff --git a/static/images/fb_image.jpg b/aplikacjawww_djangocms/static/images/fb_image.jpg similarity index 100% rename from static/images/fb_image.jpg rename to aplikacjawww_djangocms/static/images/fb_image.jpg diff --git a/static/images/graph_black.png b/aplikacjawww_djangocms/static/images/graph_black.png similarity index 100% rename from static/images/graph_black.png rename to aplikacjawww_djangocms/static/images/graph_black.png diff --git a/static/images/login_buttons/facebook.svg b/aplikacjawww_djangocms/static/images/login_buttons/facebook.svg similarity index 100% rename from static/images/login_buttons/facebook.svg rename to aplikacjawww_djangocms/static/images/login_buttons/facebook.svg diff --git a/static/images/login_buttons/google-oauth2.svg b/aplikacjawww_djangocms/static/images/login_buttons/google-oauth2.svg similarity index 100% rename from static/images/login_buttons/google-oauth2.svg rename to aplikacjawww_djangocms/static/images/login_buttons/google-oauth2.svg diff --git a/static/images/logo_transparent.png b/aplikacjawww_djangocms/static/images/logo_transparent.png similarity index 100% rename from static/images/logo_transparent.png rename to aplikacjawww_djangocms/static/images/logo_transparent.png diff --git a/static/images/logo_transparent.svg b/aplikacjawww_djangocms/static/images/logo_transparent.svg similarity index 100% rename from static/images/logo_transparent.svg rename to aplikacjawww_djangocms/static/images/logo_transparent.svg diff --git a/static/images/logo_transparent_black.svg b/aplikacjawww_djangocms/static/images/logo_transparent_black.svg similarity index 100% rename from static/images/logo_transparent_black.svg rename to aplikacjawww_djangocms/static/images/logo_transparent_black.svg diff --git a/static/images/logo_w.png b/aplikacjawww_djangocms/static/images/logo_w.png similarity index 100% rename from static/images/logo_w.png rename to aplikacjawww_djangocms/static/images/logo_w.png diff --git a/static/images/logo_w.svg b/aplikacjawww_djangocms/static/images/logo_w.svg similarity index 100% rename from static/images/logo_w.svg rename to aplikacjawww_djangocms/static/images/logo_w.svg diff --git a/templates/_analytics.html b/aplikacjawww_djangocms/templates/_analytics.html similarity index 100% rename from templates/_analytics.html rename to aplikacjawww_djangocms/templates/_analytics.html diff --git a/aplikacjawww_djangocms/templates/base.html b/aplikacjawww_djangocms/templates/base.html new file mode 100644 index 00000000..9c5f6f6f --- /dev/null +++ b/aplikacjawww_djangocms/templates/base.html @@ -0,0 +1,80 @@ +{% load cms_tags static sekizai_tags menu_tags %} + + + + + + + + + + + + + + + + {% if title %} + {{ title }} - WWW + + {% else %} + Wakacyjne Warsztaty Wielodyscyplinarne + + {% endif %} + + + + + + + + + + + {% render_block "css" %} + {% block styles %}{% endblock %} + + + + {% cms_toolbar %} + + + {% block main %}{% endblock %} + + + + {% include "_analytics.html" %} + + + {% render_block "js" %} + {% block script %}{% endblock %} + + diff --git a/aplikacjawww_djangocms/templates/menu.html b/aplikacjawww_djangocms/templates/menu.html new file mode 100644 index 00000000..34233cc5 --- /dev/null +++ b/aplikacjawww_djangocms/templates/menu.html @@ -0,0 +1,19 @@ +{% load i18n menu_tags cache %} + +{% for child in children %} + + {% if class and forloop.last and not forloop.parentloop %}{% endif %} +{% endfor %} diff --git a/aplikacjawww_djangocms/templates/page_basic.html b/aplikacjawww_djangocms/templates/page_basic.html new file mode 100644 index 00000000..e9b46bc4 --- /dev/null +++ b/aplikacjawww_djangocms/templates/page_basic.html @@ -0,0 +1,20 @@ +{% extends "base.html" %} +{% load cms_tags %} + +{% block title %}{% page_attribute "page_title" %}{% endblock title %} + +{% block main %} +
+

+ {% page_attribute "page_title" %} + + {% if has_change_permissions and not current_page.publisher_is_draft %} + + Edytuj + + {% endif %} +

+ + {% placeholder "content" %} +
+{% endblock main %} diff --git a/aplikacjawww_djangocms/templates/page_index.html b/aplikacjawww_djangocms/templates/page_index.html new file mode 100644 index 00000000..402d45fa --- /dev/null +++ b/aplikacjawww_djangocms/templates/page_index.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} +{% load cms_tags %} + +{% block main %} +
+
+ {% placeholder "header_image" %} +
+
+
+ {% placeholder "left_of_facebook_embed" %} +
+
+ +
+
+
+ +
+ {% placeholder "content" %} + + {% if has_change_permissions and not current_page.publisher_is_draft %} + + Edytuj + + {% endif %} +
+{% endblock main %} diff --git a/aplikacjawww_djangocms/urls.py b/aplikacjawww_djangocms/urls.py new file mode 100644 index 00000000..97d1c1f8 --- /dev/null +++ b/aplikacjawww_djangocms/urls.py @@ -0,0 +1,42 @@ +from cms.sitemaps import CMSSitemap +from django.conf import settings +from django.conf.urls.static import static +from django.contrib import admin +from django.contrib.auth.views import logout_then_login +from django.contrib.sitemaps.views import sitemap +from django.contrib.staticfiles.storage import staticfiles_storage +from django.urls import include, path +from django.views.generic import RedirectView + +import wwwapp.urls +from aplikacjawww_djangocms import auth, views + +admin.autodiscover() + +urlpatterns = [ + path("sitemap.xml", sitemap, {"sitemaps": {"cmspages": CMSSitemap}}), + path( + 'favicon.ico', + RedirectView.as_view( + url=staticfiles_storage.url('images/favicon.ico'), + permanent=False), + name="favicon" + ), + path('tinymce/', include('tinymce.urls')), + path('gallery/', include('gallery.urls')), + path('admin/', admin.site.urls), + path('accounts/logout/', logout_then_login, name='logout'), + path('accounts/login/', auth.login_view, name='login'), + path('accounts/', include('social_django.urls', namespace='social')), + path('accounts/verified/', auth.finish_merge_verification, name='finish_merge_verification') +] +urlpatterns += wwwapp.urls.urlpatterns +urlpatterns += [ + path('article//', views.legacy_article_url_redirect, name='article'), + path('', include('cms.urls')) +] + +# This is only needed when using runserver. +if settings.DEBUG: + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) diff --git a/aplikacjawww_djangocms/views.py b/aplikacjawww_djangocms/views.py new file mode 100644 index 00000000..c8448f4a --- /dev/null +++ b/aplikacjawww_djangocms/views.py @@ -0,0 +1,5 @@ +from django.shortcuts import redirect + + +def legacy_article_url_redirect(request, name): + return redirect('/{}'.format(name)) diff --git a/wwwapp/wsgi.py b/aplikacjawww_djangocms/wsgi.py similarity index 53% rename from wwwapp/wsgi.py rename to aplikacjawww_djangocms/wsgi.py index 910602c9..fd1254e6 100644 --- a/wwwapp/wsgi.py +++ b/aplikacjawww_djangocms/wsgi.py @@ -1,14 +1,16 @@ """ -WSGI config for wwwapp project. +WSGI config for aplikacjawww_djangocms project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see -https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/ """ import os -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "wwwapp.settings_prod") from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'aplikacjawww_djangocms.settings_prod') + application = get_wsgi_application() diff --git a/manage.py b/manage.py index 28824715..849d6a35 100755 --- a/manage.py +++ b/manage.py @@ -6,7 +6,7 @@ def main(): """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wwwapp.settings_debug') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'aplikacjawww_djangocms.settings_debug') try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/requirements.txt b/requirements.txt index 80d6d83b..d8737598 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,27 @@ -Django==3.1.7 +django-cms>=3.8,<3.9 +djangocms-admin-style>=2.0,<3.0 +django-treebeard>=4.0,<5.0 + +djangocms-text-ckeditor>=4.0,<5.0 +djangocms-link>=3.0,<4.0 +djangocms-icon>=2.0,<3.0 +djangocms-style>=3.0,<4.0 +djangocms-googlemap>=2.0,<3.0 +djangocms-video>=3.0,<4.0 +djangocms-file>=3.0,<4.0 +djangocms-picture>=3.0,<4.0 +djangocms-bootstrap4>=2.0,<3.0 +easy_thumbnails +django-filer>=1.3 +Django<3.2 +django-classy-tags>=2.0 +django-sekizai>=2.0 +django-mptt>0.9 +html5lib>=1.0.1 +Pillow>=3.0 +six +pytz + django-crispy-forms==1.11.0 django-tinymce==3.2.0 django-bleach==0.6.1 @@ -9,7 +32,6 @@ django-select2==7.6.1 social-auth-app-django==4.0.0 django-admin-sortable2==0.7.8 django-imagekit==4.0.2 -Pillow==8.1.0 python-dateutil==2.8.1 Faker==6.1.1 psycopg2==2.8.6 @@ -20,4 +42,4 @@ coverage==5.4 django-coverage-plugin==1.8.0 mypy==0.800 -django-stubs==1.7.0 +django-stubs==1.7.0 \ No newline at end of file diff --git a/templates/base.html b/templates/base.html deleted file mode 100644 index 0ece6318..00000000 --- a/templates/base.html +++ /dev/null @@ -1,200 +0,0 @@ - - - {% load static %} - {% load wwwtags %} - - - - - - - - - - - - - - - {% if title %} - {{ title }} - WWW - - {% else %} - Wakacyjne Warsztaty Wielodyscyplinarne - - {% endif %} - - - - - - - - - - - {% block styles %}{% endblock %} - - - - - -
- {% if messages %} - {% for message in messages %} -
- - {{ message }} -
- {% endfor %} - {% endif %} - - {% block content %}{% endblock %} -
- - {% if selected_year %} - - {% endif %} - - - - {% include "_analytics.html" %} - - - - {% block script %}{% endblock %} - - diff --git a/webpack.config.js b/webpack.config.js index cd008d30..325cecd9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -21,7 +21,7 @@ module.exports = { output: { filename: "[name].js", // No filename hashing, Django takes care of this chunkFilename: "[id]-[chunkhash].js", // Per advice from blog (see link above) - path: path.resolve(__dirname, './static/dist'), + path: path.resolve(__dirname, './aplikacjawww_djangocms/static/dist'), }, devServer: { writeToDisk: true, // Write files to disk in dev mode, so Django can serve the assets diff --git a/wwwapp/cms_menus.py b/wwwapp/cms_menus.py new file mode 100644 index 00000000..2096ed5a --- /dev/null +++ b/wwwapp/cms_menus.py @@ -0,0 +1,170 @@ +from django.urls import reverse +from django.utils.safestring import mark_safe +from menus.base import Menu, NavigationNode, Modifier +from menus.menu_pool import menu_pool + +from wwwapp.models import Camp, ResourceYearPermission, UserProfile + + +class WWWProgramMenu(Menu): + def get_nodes(self, request): + current_year = Camp.current() + return [ + NavigationNode( + title='Program', + url=reverse('program', args=[current_year.pk]), + id='wwwapp_program', + ), + ] + + +class WWWInternetyMenu(Menu): + def get_nodes(self, request): + visible_resources = [] + if request.user.is_authenticated: + resources = ResourceYearPermission.objects.exclude(access_url__exact="") + if request.user.has_perm('wwwapp.access_all_resources'): + visible_resources = resources.all() + else: + try: + user_profile = UserProfile.objects.get(user=request.user) + visible_resources = resources.filter(year__in=user_profile.all_participation_years()) + except UserProfile.DoesNotExist: + pass + + if not visible_resources: + return [] + + nodes = [ + NavigationNode( + title='Internety', + url=None, + id='internety', + ), + ] + for resource in visible_resources: + nodes.append( + NavigationNode( + title=resource.display_name, + url=resource.access_url, + id='internety_{}'.format(resource.pk), + parent_id='internety', + ) + ) + return nodes + + +class WWWAdminMenu(Menu): + def get_nodes(self, request): + current_year = Camp.current() + if (not request.user.is_staff and + not request.user.has_perm('wwwapp.see_all_users') and + not request.user.has_perm('wwwapp.see_all_workshops') and + not request.user.has_perm('wwwforms.see_form_results') and + not request.user.has_perm('wwwapp.export_workshop_registration')): + return [] + nodes = [ + NavigationNode( + title='Admin', + url=None, + id='wwwapp_admin', + ), + ] + if request.user.has_perm('perms.wwwapp.see_all_users'): + nodes.extend([ + NavigationNode( + title='Uczestnicy', + url=reverse('participants', args=[current_year.pk]), + id='participants', + parent_id='wwwapp_admin', + ), + NavigationNode( + title='Prowadzący', + url=reverse('lecturers', args=[current_year.pk]), + id='lecturers', + parent_id='wwwapp_admin', + ), + ]) + if request.user.has_perm('perms.wwwapp.see_all_workshops'): + nodes.extend([ + NavigationNode( + title='Warsztaty', + url=reverse('workshops', args=[current_year.pk]), + id='workshops', + parent_id='wwwapp_admin', + ), + ]) + if request.user.has_perm('perms.wwwapp.see_form_results'): + nodes.extend([ + NavigationNode( + title='Formularze', + url=reverse('form_list'), + id='forms', + parent_id='wwwapp_admin', + ), + ]) + if request.user.has_perm('perms.wwwapp.see_all_users'): + nodes.extend([ + NavigationNode( + title='Wszyscy ludzie', + url=reverse('all_people'), + id='all_people', + parent_id='wwwapp_admin', + ), + NavigationNode( + title='Adresy email', + url=reverse('emails', args=[current_year.pk]), + id='emails', + parent_id='wwwapp_admin', + ), + ]) + return nodes + + +class WWWQualificationMenu(Menu): + def get_nodes(self, request): + return [ + NavigationNode( + title='Kwalifikacja', + url=reverse('mydata_status'), + id='wwwapp_qualification', + ), + ] + + +class WWWArticlesMenu(Menu): + def get_nodes(self, request): + return [ + NavigationNode( + title='Artykuły', + url=None, + id='wwwapp_articles', + ), + ] + + +class WWWArticlesModifier(Modifier): + def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb): + articles = next(filter(lambda x: x.id == 'wwwapp_articles', nodes), None) + if not articles: + return nodes + + for node in nodes: + if not node.parent and node.attr.get('is_page', False) and not node.attr.get('is_home', False): + node.parent = articles + node.parent_id = articles.id + articles.children.append(node) + if node.attr.get('is_home', False): + node.title = mark_safe('Strona główna') + + if len(articles.children) == 0: + nodes.remove(articles) + return nodes + + +menu_pool.register_menu(WWWProgramMenu) +menu_pool.register_menu(WWWInternetyMenu) +menu_pool.register_menu(WWWAdminMenu) +menu_pool.register_menu(WWWArticlesMenu) +menu_pool.register_menu(WWWQualificationMenu) +menu_pool.register_modifier(WWWArticlesModifier) diff --git a/wwwapp/settings_debug.py b/wwwapp/settings_debug.py deleted file mode 100644 index 56f6ca3e..00000000 --- a/wwwapp/settings_debug.py +++ /dev/null @@ -1,33 +0,0 @@ -from .settings_common import * - -SECRET_KEY = ')_7av^!cy(wfx=k#3*7x+(=j^fzv+ot^1@sh9s9t=8$bu@r(z$' - -DEBUG = True -TEMPLATES[0]['OPTIONS']['debug'] = DEBUG -ALLOWED_HOSTS = ["*"] - -EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' - -INSTALLED_APPS = INSTALLED_APPS + ('debug_toolbar',) - -MIDDLEWARE = ('debug_toolbar.middleware.DebugToolbarMiddleware',) + MIDDLEWARE - -ROOT_URLCONF = 'wwwapp.urls' - -WSGI_APPLICATION = 'wwwapp.wsgi.application' - -# Database -# https://docs.djangoproject.com/en/3.1/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'database.sqlite3', - } -} - -MEDIA_ROOT = os.path.join(BASE_DIR, *MEDIA_URL.strip("/").split("/")) -SENDFILE_ROOT = os.path.join(BASE_DIR, *SENDFILE_URL.strip("/").split("/")) -SENDFILE_BACKEND = 'django_sendfile.backends.development' - -GOOGLE_ANALYTICS_KEY = None diff --git a/templates/_pastParticipation.html b/wwwapp/templates/_pastParticipation.html similarity index 100% rename from templates/_pastParticipation.html rename to wwwapp/templates/_pastParticipation.html diff --git a/templates/_programworkshop.html b/wwwapp/templates/_programworkshop.html similarity index 100% rename from templates/_programworkshop.html rename to wwwapp/templates/_programworkshop.html diff --git a/templates/_qualificationsTable.html b/wwwapp/templates/_qualificationsTable.html similarity index 100% rename from templates/_qualificationsTable.html rename to wwwapp/templates/_qualificationsTable.html diff --git a/templates/_socialButton.html b/wwwapp/templates/_socialButton.html similarity index 100% rename from templates/_socialButton.html rename to wwwapp/templates/_socialButton.html diff --git a/templates/_statusLabel.html b/wwwapp/templates/_statusLabel.html similarity index 100% rename from templates/_statusLabel.html rename to wwwapp/templates/_statusLabel.html diff --git a/templates/_workshopStatusTable.html b/wwwapp/templates/_workshopStatusTable.html similarity index 100% rename from templates/_workshopStatusTable.html rename to wwwapp/templates/_workshopStatusTable.html diff --git a/templates/article.html b/wwwapp/templates/article.html similarity index 95% rename from templates/article.html rename to wwwapp/templates/article.html index b59cf8f2..a225ce3b 100644 --- a/templates/article.html +++ b/wwwapp/templates/article.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "wwwapp_base.html" %} {% load bleach_tags %} diff --git a/templates/articleedit.html b/wwwapp/templates/articleedit.html similarity index 93% rename from templates/articleedit.html rename to wwwapp/templates/articleedit.html index 0591d85f..d2c23233 100644 --- a/templates/articleedit.html +++ b/wwwapp/templates/articleedit.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "wwwapp_base.html" %} {% load static %} {% load crispy_forms_tags %} diff --git a/templates/filteredEmails.html b/wwwapp/templates/filteredEmails.html similarity index 94% rename from templates/filteredEmails.html rename to wwwapp/templates/filteredEmails.html index 76eda62f..159803c1 100644 --- a/templates/filteredEmails.html +++ b/wwwapp/templates/filteredEmails.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "wwwapp_base.html" %} {% load crispy_forms_tags %} {% block content %} diff --git a/templates/form.html b/wwwapp/templates/form.html similarity index 88% rename from templates/form.html rename to wwwapp/templates/form.html index d772b17f..4b1bdf15 100644 --- a/templates/form.html +++ b/wwwapp/templates/form.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "wwwapp_base.html" %} {% load crispy_forms_tags %} {% block content %} diff --git a/templates/formlist.html b/wwwapp/templates/formlist.html similarity index 97% rename from templates/formlist.html rename to wwwapp/templates/formlist.html index 253bab5e..423272ca 100644 --- a/templates/formlist.html +++ b/wwwapp/templates/formlist.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "wwwapp_base.html" %} {% block content %}
diff --git a/templates/formresults.html b/wwwapp/templates/formresults.html similarity index 98% rename from templates/formresults.html rename to wwwapp/templates/formresults.html index adb61a9a..1b7d41c8 100644 --- a/templates/formresults.html +++ b/wwwapp/templates/formresults.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "wwwapp_base.html" %} {% load static %} {% load wwwtags %} diff --git a/templates/lecturers.html b/wwwapp/templates/lecturers.html similarity index 98% rename from templates/lecturers.html rename to wwwapp/templates/lecturers.html index 529a25fe..cea407c6 100644 --- a/templates/lecturers.html +++ b/wwwapp/templates/lecturers.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "wwwapp_base.html" %} {% load static %} {% load wwwtags %} diff --git a/templates/listworkshop.html b/wwwapp/templates/listworkshop.html similarity index 99% rename from templates/listworkshop.html rename to wwwapp/templates/listworkshop.html index 2b4dc8d4..04f7d5f7 100644 --- a/templates/listworkshop.html +++ b/wwwapp/templates/listworkshop.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "wwwapp_base.html" %} {% load static %} {% load wwwtags %} diff --git a/templates/login.html b/wwwapp/templates/login.html similarity index 97% rename from templates/login.html rename to wwwapp/templates/login.html index 8c008b0f..21d11d1a 100644 --- a/templates/login.html +++ b/wwwapp/templates/login.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "wwwapp_base.html" %} {% load wwwtags %} {% block content %} diff --git a/templates/loginMerge.html b/wwwapp/templates/loginMerge.html similarity index 97% rename from templates/loginMerge.html rename to wwwapp/templates/loginMerge.html index 1bdcf1f9..53441eac 100644 --- a/templates/loginMerge.html +++ b/wwwapp/templates/loginMerge.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "wwwapp_base.html" %} {% load wwwtags %} {% block content %} diff --git a/templates/mydata_base.html b/wwwapp/templates/mydata_base.html similarity index 97% rename from templates/mydata_base.html rename to wwwapp/templates/mydata_base.html index af2d834d..80645784 100644 --- a/templates/mydata_base.html +++ b/wwwapp/templates/mydata_base.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "wwwapp_base.html" %} {% block content %}

{{ title }}

diff --git a/templates/mydata_coverletter.html b/wwwapp/templates/mydata_coverletter.html similarity index 100% rename from templates/mydata_coverletter.html rename to wwwapp/templates/mydata_coverletter.html diff --git a/templates/mydata_forms.html b/wwwapp/templates/mydata_forms.html similarity index 100% rename from templates/mydata_forms.html rename to wwwapp/templates/mydata_forms.html diff --git a/templates/mydata_profile.html b/wwwapp/templates/mydata_profile.html similarity index 100% rename from templates/mydata_profile.html rename to wwwapp/templates/mydata_profile.html diff --git a/templates/mydata_profilepage.html b/wwwapp/templates/mydata_profilepage.html similarity index 100% rename from templates/mydata_profilepage.html rename to wwwapp/templates/mydata_profilepage.html diff --git a/templates/mydata_status.html b/wwwapp/templates/mydata_status.html similarity index 100% rename from templates/mydata_status.html rename to wwwapp/templates/mydata_status.html diff --git a/templates/participants.html b/wwwapp/templates/participants.html similarity index 99% rename from templates/participants.html rename to wwwapp/templates/participants.html index 181fb634..5ce8729b 100644 --- a/templates/participants.html +++ b/wwwapp/templates/participants.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "wwwapp_base.html" %} {% load static %} {% load wwwtags %} diff --git a/templates/profile.html b/wwwapp/templates/profile.html similarity index 99% rename from templates/profile.html rename to wwwapp/templates/profile.html index 151b2d82..63514a5b 100644 --- a/templates/profile.html +++ b/wwwapp/templates/profile.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "wwwapp_base.html" %} {% load bleach_tags %} {% block content %} diff --git a/templates/program.html b/wwwapp/templates/program.html similarity index 98% rename from templates/program.html rename to wwwapp/templates/program.html index 1eea9e8d..ec89ba3c 100644 --- a/templates/program.html +++ b/wwwapp/templates/program.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "wwwapp_base.html" %} {% load static %} {% load wwwtags %} diff --git a/templates/workshopbase.html b/wwwapp/templates/workshopbase.html similarity index 98% rename from templates/workshopbase.html rename to wwwapp/templates/workshopbase.html index 1087b613..e51d5b0a 100644 --- a/templates/workshopbase.html +++ b/wwwapp/templates/workshopbase.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "wwwapp_base.html" %} {% block content %}
diff --git a/templates/workshopedit.html b/wwwapp/templates/workshopedit.html similarity index 100% rename from templates/workshopedit.html rename to wwwapp/templates/workshopedit.html diff --git a/templates/workshoppage.html b/wwwapp/templates/workshoppage.html similarity index 100% rename from templates/workshoppage.html rename to wwwapp/templates/workshoppage.html diff --git a/templates/workshopparticipants.html b/wwwapp/templates/workshopparticipants.html similarity index 100% rename from templates/workshopparticipants.html rename to wwwapp/templates/workshopparticipants.html diff --git a/templates/workshopsolution.html b/wwwapp/templates/workshopsolution.html similarity index 100% rename from templates/workshopsolution.html rename to wwwapp/templates/workshopsolution.html diff --git a/wwwapp/templates/wwwapp_base.html b/wwwapp/templates/wwwapp_base.html new file mode 100644 index 00000000..d3d651e2 --- /dev/null +++ b/wwwapp/templates/wwwapp_base.html @@ -0,0 +1,48 @@ +{% extends "base.html" %} +{% load wwwtags %} + +{% block main %} +
+ {% if messages %} + {% for message in messages %} +
+ + {{ message }} +
+ {% endfor %} + {% endif %} + + {% block content %}{% endblock %} +
+ +{% if selected_year %} + +{% endif %} +{% endblock main %} \ No newline at end of file diff --git a/wwwapp/urls.py b/wwwapp/urls.py index f02a3922..7fd13cda 100644 --- a/wwwapp/urls.py +++ b/wwwapp/urls.py @@ -1,30 +1,11 @@ from django.urls import path, include from django.conf.urls.static import static -from django.contrib import admin -from django.contrib.auth.views import logout_then_login -from django.contrib.staticfiles.storage import staticfiles_storage -from django.views.generic import RedirectView, TemplateView from django.conf import settings from . import views, mail_views -from .auth import login_view, finish_merge_verification import wwwforms.views as wwwforms_views urlpatterns = [ - path( - 'favicon.ico', - RedirectView.as_view( - url=staticfiles_storage.url('images/favicon.ico'), - permanent=False), - name="favicon" - ), - path('tinymce/', include('tinymce.urls')), - path('admin/', admin.site.urls), - path('gallery/', include('gallery.urls')), - path('accounts/logout/', logout_then_login, name='logout'), - path('accounts/login/', login_view, name='login'), - path('accounts/', include('social_django.urls', namespace='social')), - path('accounts/verified/', finish_merge_verification, name='finish_merge_verification'), path('profile//', views.profile_view, name='profile'), path('me/profile/', views.mydata_profile_view, name='mydata_profile'), path('me/profile_page/', views.mydata_profile_page_view, name='mydata_profile_page'), @@ -34,9 +15,6 @@ path('forms/', wwwforms_views.form_list_view, name='form_list'), path('forms//', wwwforms_views.form_view, name='form'), path('forms//results/', wwwforms_views.form_results_view, name='form_results'), - path('article//', views.article_view, name='article'), - path('article//edit/', views.article_edit_view, name='article_edit'), - path('article//edit/upload/', views.article_edit_upload_file, name='article_edit_upload'), path('addArticle/', views.article_edit_view, name='article_add'), path('articleNameList/', views.article_name_list_view, name='articleNameList'), path('workshop//', views.legacy_workshop_redirect_view), @@ -64,8 +42,6 @@ path('program/', views.program_view, name='latest_program'), path('/program/', views.program_view, name='program'), path('resource_auth/', views.resource_auth_view, name='resource_auth'), - path('robots.txt', TemplateView.as_view(template_name='robots.txt', content_type='text/plain')), - path('', views.index_view, name='index'), ] if settings.DEBUG: diff --git a/wwwapp/views.py b/wwwapp/views.py index 6dae9b8a..b0998bd4 100644 --- a/wwwapp/views.py +++ b/wwwapp/views.py @@ -43,19 +43,7 @@ def get_context(request): context = {} - if request.user.is_authenticated: - visible_resources = ResourceYearPermission.objects.exclude(access_url__exact="") - if request.user.has_perm('wwwapp.access_all_resources'): - context['resources'] = visible_resources - else: - try: - user_profile = UserProfile.objects.get(user=request.user) - context['resources'] = visible_resources.filter(year__in=user_profile.all_participation_years()) - except UserProfile.DoesNotExist: - context['resources'] = [] - context['google_analytics_key'] = settings.GOOGLE_ANALYTICS_KEY - context['articles_on_menubar'] = Article.objects.filter(on_menubar=True).all() context['years'] = Camp.objects.all() context['current_year'] = Camp.current() @@ -958,7 +946,6 @@ def page(request): return page -index_view = as_article("index") template_for_workshop_page_view = as_article("template_for_workshop_page")