Initial commit

This commit is contained in:
Kumi 2023-07-07 16:51:24 +02:00
commit ac0fd97d46
Signed by: kumi
GPG key ID: ECBCC9082395383F
10 changed files with 321 additions and 0 deletions

11
.gitignore vendored Normal file
View file

@ -0,0 +1,11 @@
venv/
*.pyc
__pycache__/
static/
settings.ini
db.sqlite3
db.sqlite3-journal

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "frontend"]
path = frontend
url = git@kumig.it:kumisystems/website-frontend.git

1
frontend Submodule

@ -0,0 +1 @@
Subproject commit 33a412cb95d970720ccf5238cecf8af823b2c9ea

0
kumisystems/__init__.py Normal file
View file

16
kumisystems/asgi.py Normal file
View file

@ -0,0 +1,16 @@
"""
ASGI config for kumisystems 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/4.2/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "kumisystems.settings")
application = get_asgi_application()

216
kumisystems/settings.py Normal file
View file

@ -0,0 +1,216 @@
from pathlib import Path
from autosecretkey import AutoSecretKey
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
ASK = AutoSecretKey(BASE_DIR / 'settings.ini')
SECRET_KEY = ASK.secret_key
CONFIG = ASK.config
DEBUG = CONFIG.get('KumiSystems', 'Debug', fallback=False)
HOST = CONFIG.get('KumiSystems', 'Host', fallback='localhost')
ALLOWED_HOSTS = [HOST]
CSRF_TRUSTED_ORIGINS = [f"https://{HOST}"]
SITE_ID = CONFIG.getint('KumiSystems', 'SiteID', fallback=1)
# Application definition
INSTALLED_APPS = [
'djangocms_admin_style', # Must be listed before 'django.contrib.admin'
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# Required for Django CMS:
# https://docs.django-cms.org/en/latest/how_to/install.html#installed-apps
'django.contrib.sites',
'cms',
'menus',
'treebeard',
'sekizai',
'filer',
'easy_thumbnails',
'mptt',
'djangocms_text_ckeditor',
'djangocms_link',
'djangocms_file',
'djangocms_picture',
'djangocms_video',
'djangocms_snippet',
'djangocms_style',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'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',
# Required for Django CMS:
# https://docs.django-cms.org/en/latest/how_to/install.html#middleware
'django.middleware.locale.LocaleMiddleware',
'cms.middleware.utils.ApphookReloadMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware',
]
ROOT_URLCONF = 'kumisystems.urls'
WSGI_APPLICATION = 'kumisystems.wsgi.application'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'frontend/templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
# Required for Django CMS:
# https://docs.django-cms.org/en/latest/how_to/install.html#sekizai
# https://docs.django-cms.org/en/latest/how_to/install.html#context-processors
'django.template.context_processors.i18n',
'sekizai.context_processors.sekizai',
'cms.context_processors.cms_settings',
],
},
},
]
CMS_TEMPLATES = [
('home.html', 'Home page template'),
]
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
if "MySQL" in CONFIG:
DATABASES = {
'default': {
'ENGINE': 'mysql.connector.django',
'NAME': CONFIG.get("MySQL", "Database"),
'USER': CONFIG.get("MySQL", "Username"),
'PASSWORD': CONFIG.get("MySQL", "Password"),
'HOST': CONFIG.get("MySQL", "Host", fallback="localhost"),
'PORT': CONFIG.getint("MySQL", "Port", fallback=3306),
'OPTIONS': {
'charset': 'utf8mb4',
'sql_mode': 'traditional',
}
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/4.2/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/4.2/topics/i18n/
# https://docs.django-cms.org/en/latest/how_to/install.html#language-settings
LANGUAGE_CODE = 'en'
LANGUAGES = [
('en', 'English'),
('de', 'German'),
]
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images) and media files (user uploads)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
# https://docs.djangoproject.com/en/4.2/topics/files/
STATIC_URL = 'static/'
STATIC_ROOT = CONFIG.get(
"KumiSystems", "StaticRoot", fallback=BASE_DIR / "static")
STATICFILES_DIRS = [
BASE_DIR / "frontend/static",
]
MEDIA_URL = 'media/'
MEDIA_ROOT = CONFIG.get(
"KumiSystems", "MediaRoot", fallback=BASE_DIR / "media")
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = "/"
if "S3" in CONFIG:
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3StaticStorage'
AWS_ACCESS_KEY_ID = CONFIG.get("S3", "AccessKey")
AWS_SECRET_ACCESS_KEY = CONFIG.get("S3", "SecretKey")
AWS_STORAGE_BUCKET_NAME = CONFIG.get("S3", "Bucket")
AWS_S3_ENDPOINT_URL = CONFIG.get("S3", "Endpoint")
# Easy Thumbnails settings
THUMBNAIL_HIGH_RESOLUTION = True
THUMBNAIL_PROCESSORS = (
'easy_thumbnails.processors.colorspace',
'easy_thumbnails.processors.autocrop',
'filer.thumbnail_processors.scale_and_crop_with_subject_location',
'easy_thumbnails.processors.filters'
)
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# Django CMS settings
X_FRAME_OPTIONS = 'SAMEORIGIN'

22
kumisystems/urls.py Normal file
View file

@ -0,0 +1,22 @@
"""
URL configuration for kumisystems project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
urlpatterns = [
path("admin/", admin.site.urls),
]

16
kumisystems/wsgi.py Normal file
View file

@ -0,0 +1,16 @@
"""
WSGI config for kumisystems 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/4.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "kumisystems.settings")
application = get_wsgi_application()

22
manage.py Executable file
View file

@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "kumisystems.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == "__main__":
main()

14
requirements.txt Normal file
View file

@ -0,0 +1,14 @@
Django
django-cms
mysql-connector-python
django-autosecretkey
django-storages
botocore
django-filer
djangocms-text-ckeditor
djangocms-link
djangocms-file
djangocms-picture
djangocms-video
djangocms-snippet
djangocms-style