Initial django-pygal implementation
3
.gitignore
vendored
@ -1,3 +1,6 @@
|
||||
config.py
|
||||
data/
|
||||
|
||||
# ---> Python
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
|
18
.gitmodules
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
[submodule "fstools"]
|
||||
path = fstools
|
||||
url = https://git.mount-mockery.de/pylib/fstools.git
|
||||
[submodule "geo"]
|
||||
path = geo
|
||||
url = https://git.mount-mockery.de/pylib/geo.git
|
||||
[submodule "mycreole"]
|
||||
path = mycreole
|
||||
url = https://git.mount-mockery.de/django_lib/mycreole.git
|
||||
[submodule "pygal"]
|
||||
path = pygal
|
||||
url = https://git.mount-mockery.de/django_lib/pygal.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
|
17
.project
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>django_pygal</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.python.pydev.PyDevBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.python.pydev.pythonNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
8
.pydevproject
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?eclipse-pydev version="1.0"?><pydev_project>
|
||||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||
<path>/${PROJECT_DIR_NAME}</path>
|
||||
</pydev_pathproperty>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||
</pydev_project>
|
BIN
data/example_data/building_scenery/IMG_20160824_113401.jpg
Normal file
After Width: | Height: | Size: 4.4 MiB |
BIN
data/example_data/building_scenery/IMG_20160901_162221.jpg
Normal file
After Width: | Height: | Size: 3.8 MiB |
BIN
data/example_data/building_scenery/IMG_20180104_213600.jpg
Normal file
After Width: | Height: | Size: 2.6 MiB |
BIN
data/example_data/natural_scenery/20141226_135921.jpg
Normal file
After Width: | Height: | Size: 3.9 MiB |
BIN
data/example_data/natural_scenery/DSC01058.JPG
Normal file
After Width: | Height: | Size: 2.4 MiB |
BIN
data/example_data/natural_scenery/DSC_1150.JPG
Normal file
After Width: | Height: | Size: 3.0 MiB |
BIN
data/example_data/natural_scenery/DSC_1163.JPG
Normal file
After Width: | Height: | Size: 3.0 MiB |
BIN
data/example_data/natural_scenery/DSC_1167.JPG
Normal file
After Width: | Height: | Size: 3.0 MiB |
BIN
data/example_data/natural_scenery/DSC_1864.JPG
Normal file
After Width: | Height: | Size: 3.0 MiB |
BIN
data/example_data/natural_scenery/DSC_2573.JPG
Normal file
After Width: | Height: | Size: 3.1 MiB |
BIN
data/media/theme/logo.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
1
fstools
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit ada1f74d4c05a35bad9d2b258f3d0b4ccdfd1653
|
1
geo
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit f59b19ed1fd2a64735ca477fdb1fba24681e8879
|
0
main/__init__.py
Normal file
253
main/settings.py
Normal file
@ -0,0 +1,253 @@
|
||||
"""
|
||||
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, ITEM_ROOT, THUMBNAIL_SIZES, WEBNAIL_SIZES
|
||||
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 = False
|
||||
|
||||
ALLOWED_HOSTS = config.get('ALLOWED_HOSTS', [])
|
||||
|
||||
|
||||
# Application definition
|
||||
#
|
||||
INSTALLED_APPS = [
|
||||
'pygal.apps.PygalConfig',
|
||||
'themes.apps.ThemesConfig',
|
||||
'users.apps.UsersConfig',
|
||||
#
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
]
|
||||
|
||||
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',
|
||||
'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, 'pygal', '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/'
|
||||
|
||||
|
||||
# Session parameters
|
||||
#
|
||||
|
||||
SESSION_KEY_THUMBNAIL_SIZE = 'thumbnail_size'
|
||||
SESSION_KEY_WEBNAIL_SIZE = 'webnail_size'
|
||||
PERSISTENT_SESSION_VARIABLES = [SESSION_KEY_THUMBNAIL_SIZE, SESSION_KEY_WEBNAIL_SIZE]
|
||||
|
||||
|
||||
# Logging Configuration
|
||||
#
|
||||
default_handler = ['console_long'] 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,
|
||||
},
|
||||
'APP': {
|
||||
'handlers': default_handler,
|
||||
'level': 'INFO',
|
||||
'propagate': False,
|
||||
},
|
||||
'CACHING': {
|
||||
'handlers': default_handler,
|
||||
'level': 'INFO',
|
||||
'propagate': False,
|
||||
},
|
||||
'WHOOSH': {
|
||||
'handlers': default_handler,
|
||||
'level': 'INFO',
|
||||
'propagate': False,
|
||||
},
|
||||
'FSTOOLS': {
|
||||
'handlers': default_handler,
|
||||
'level': 'INFO',
|
||||
'propagate': False,
|
||||
},
|
||||
'GEO': {
|
||||
'handlers': default_handler,
|
||||
'level': 'INFO',
|
||||
'propagate': False,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
# Other Configuration issues
|
||||
#
|
||||
|
||||
DATA_UPLOAD_MAX_NUMBER_FIELDS = 30000
|
||||
|
||||
LOGIN_URL = 'users-login'
|
||||
|
||||
XNAIL_ROOT = os.path.join(BASE_DIR, 'data', 'xnails')
|
||||
TEMP_ROOT = os.path.join(BASE_DIR, 'data', 'temp')
|
||||
|
||||
|
||||
# App Configuration
|
||||
#
|
||||
DEFAULT_THEME = config.get('DEFAULT_THEME', 'clear-red')
|
||||
ITEM_ROOT = config.get('ITEM_ROOT', os.path.join(BASE_DIR, 'data', 'example_data'))
|
||||
THUMBNAIL_SIZES = config.get('THUMBNAIL_SIZES', [137, 175, 250])
|
||||
WEBNAIL_SIZES = config.get('WEBNAIL_SIZES', [450, 1100, 1750])
|
32
main/urls.py
Normal 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
|
||||
from django.urls.base import reverse
|
||||
import pygal
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('pygal/', include('pygal.urls')),
|
||||
path('users/', include('users.urls')),
|
||||
path('', lambda request: redirect(reverse('pygal-responses', kwargs={'responsetype': pygal.RESP_TYPE_USERVIEW, 'datatype': pygal.DATA_TYPE_ITEM}), permanent=False)),
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
16
main/wsgi.py
Normal 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
@ -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
pygal
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit d73c7363b7340163c02277750258a46ea2a00d20
|
18
readme.txt
Normal file
@ -0,0 +1,18 @@
|
||||
1. Setupt venev
|
||||
* virtualenv -p /usr/bin/python3 pygal-venv
|
||||
* ln -s pygal-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. python manage.py migrate
|
||||
3. python manage.py createsuperuser
|
||||
4. Set SECRET:KEY in config.py
|
||||
5. Set ITEM_ROOT in config.py to your item target path, otherwise the example_data is used
|
||||
6. python manage.py collectstatic
|
||||
7. chgrp www-data . && chmod 770 .
|
||||
8. chgrp www-data db.sqlite3 && chmod 664 db.sqlite3
|
||||
9. chgrp www-data -R data
|
||||
9.1. find data -type d -exec chmod 775 "{}" \;
|
||||
9.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
|
4
requirements.txt
Normal file
@ -0,0 +1,4 @@
|
||||
Django>=2.0.5,<3.0
|
||||
Pillow>=5.4.1
|
||||
python-creole>=1.0.0
|
||||
Whoosh>=2.4.0
|
1
themes
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit a24e772083b27e9ab413d137005dbc9e8325dbc4
|
1
users
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 277352fe9bbf0e67b52bdb19a5ba7fa6281dad6e
|