Initial django-patt implementation

This commit is contained in:
Dirk Alders 2020-01-26 21:05:24 +01:00
parent 3d44a41d24
commit 7b8c7820af
16 changed files with 361 additions and 0 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
config.py
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/

15
.gitmodules vendored Normal file
View File

@ -0,0 +1,15 @@
[submodule "fstools"]
path = fstools
url = https://git.mount-mockery.de/pylib/fstools.git
[submodule "mycreole"]
path = mycreole
url = https://git.mount-mockery.de/django_lib/mycreole.git
[submodule "patt"]
path = patt
url = https://git.mount-mockery.de/django_lib/patt.git
[submodule "themes"]
path = themes
url = https://git.mount-mockery.de/django_lib/themes.git
[submodule "users"]
path = users
url = https://git.mount-mockery.de/django_lib/users.git

1
activate Symbolic link
View File

@ -0,0 +1 @@
venv/bin/activate

BIN
data/media/theme/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

1
fstools Submodule

@ -0,0 +1 @@
Subproject commit ada1f74d4c05a35bad9d2b258f3d0b4ccdfd1653

0
main/__init__.py Normal file
View File

247
main/settings.py Normal file
View File

@ -0,0 +1,247 @@
"""
Django settings for this project.
Generated by 'django-admin startproject' using Django 2.2.3.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
try:
from config import config
# required keys: SECRET_KEY
# optional keys: ALLOWED_HOSTS, DEFAULT_THEME
except ImportError:
config = {}
import os
import random
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
#
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
#
try:
SECRET_KEY = config['SECRET_KEY']
except KeyError:
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
s_key = ''.join([random.choice(chars) for n in range(50)])
secret_key_warning = "You need to create a config.py file including a variable config which is a dict with at least a SECRET_KEY definition (e.g.: %s)." % repr(s_key)
raise KeyError(secret_key_warning)
# SECURITY WARNING: don't run with debug turned on in production!
#
DEBUG = True
ALLOWED_HOSTS = config.get('ALLOWED_HOSTS', [])
# Application definition
#
INSTALLED_APPS = [
'patt.apps.PattConfig',
'themes.apps.ThemesConfig',
'users.apps.UsersConfig',
'mycreole.apps.MycreoleConfig',
#
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'simple_history',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'simple_history.middleware.HistoryRequestMiddleware',
'users.middleware.SettingsMiddleware',
]
ROOT_URLCONF = 'main.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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',
],
},
},
]
WSGI_APPLICATION = 'main.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
#
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.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',
},
]
# Search Engine
#
WHOOSH_PATH = os.path.join(BASE_DIR, 'data', 'whoosh_index')
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
#
LANGUAGE_CODE = 'en-us'
LANGUAGES = [
('en', 'English'),
('de', 'Deutsch'),
]
TIME_ZONE = 'UTC'
USE_I18N = True
LOCALE_PATHS = [
os.path.join(BASE_DIR, 'themes', 'locale'),
os.path.join(BASE_DIR, 'users', 'locale'),
os.path.join(BASE_DIR, 'patt', 'locale'),
]
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
#
STATIC_ROOT = os.path.join(BASE_DIR, 'data', 'static')
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media')
MEDIA_URL = '/media/'
MYCREOLE_ROOT = os.path.join(BASE_DIR, 'data', 'mycreole')
MYCREOLE_ATTACHMENT_ACCESS = {
'read': 'patt.access.read_attachment',
'modify': 'patt.access.modify_attachment',
}
MYCREOLE_EXT_FILTERS = [
'patt.creole.task_link_filter',
'patt.creole.tasklist_link_filter',
]
# Session parameters
#
PERSISTENT_SESSION_VARIABLES = []
# Logging Configuration
#
debug_handler = 'console'
default_handler = [debug_handler] if DEBUG else ['console']
#
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'short': {
'format': "%(asctime)s \"%(name)s - %(levelname)s - %(message)s\"",
'datefmt': '[%d/%b/%Y %H:%M:%S]',
},
'long': {
'format': """~~~~(%(levelname)-10s)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
File "%(pathname)s", line %(lineno)d, in %(funcName)s
%(asctime)s: %(name)s - %(message)s
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~""",
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'short',
},
'console_long': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'long',
},
},
'loggers': {
'AUTH': {
'handlers': default_handler,
'level': 'INFO',
'propagate': False,
},
'ACC': {
'handlers': default_handler,
'level': 'INFO',
'propagate': False,
},
'APP': {
'handlers': default_handler,
'level': 'INFO',
'propagate': False,
},
'WHOOSH': {
'handlers': default_handler,
'level': 'INFO',
'propagate': False,
},
'FSTOOLS': {
'handlers': default_handler,
'level': 'INFO',
'propagate': False,
},
},
}
# Other Configuration issues
#
LOGIN_URL = 'users-login'
# App Configuration
#
DEFAULT_THEME = config.get('DEFAULT_THEME', 'clear-green')

32
main/urls.py Normal file
View File

@ -0,0 +1,32 @@
"""Project URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.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.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.shortcuts import redirect
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('patt/', include('patt.urls')),
path('users/', include('users.urls')),
path('mycreole/', include('mycreole.urls')),
path('', lambda request: redirect('patt/', permanent=False)),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

16
main/wsgi.py Normal file
View File

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

21
manage.py Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.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()

1
mycreole Submodule

@ -0,0 +1 @@
Subproject commit dd0edc2d56c2c234be32fa76e3bd5b6b4f38a69f

1
patt Submodule

@ -0,0 +1 @@
Subproject commit c834976e79f98f6c59cf6fb33b0f5850b008281b

17
readme.txt Normal file
View File

@ -0,0 +1,17 @@
1. Setupt venev
* virtualenv -p /usr/bin/python3 patt-venv
* ln -s patt-venv/bin/activate
* source activate
* Sometimes upgrades are needed: pip list --outdated | cut -d ' ' -f 1 | xargs pip install $1 --upgrade
* pip install -r requirements.txt
2. Set SECRET:KEY in config.py
3. python manage.py migrate
4. python manage.py createsuperuser
5. python manage.py collectstatic
6. chgrp www-data . && chmod 770 .
7. chgrp www-data db.sqlite3 && chmod 664 db.sqlite3
8. chgrp www-data -R data
8.1. find data -type d -exec chmod 775 "{}" \;
8.2. find data -type f -exec chmod 664 "{}" \;
x. Run server by command "python manage.py runserver 0.0.0.0:8000" or add App to apache

5
requirements.txt Normal file
View File

@ -0,0 +1,5 @@
Django>=2.0.5,<3.0
Pillow>=5.4.1
python-creole>=1.0.0
Whoosh>=2.4.0
django-simple-history>=2.7.3

1
themes Submodule

@ -0,0 +1 @@
Subproject commit a24e772083b27e9ab413d137005dbc9e8325dbc4

1
users Submodule

@ -0,0 +1 @@
Subproject commit 277352fe9bbf0e67b52bdb19a5ba7fa6281dad6e