Pārlūkot izejas kodu

Initial django-pygal implementation

master
Dirk Alders 4 gadus atpakaļ
vecāks
revīzija
410984d0e2

+ 3
- 0
.gitignore Parādīt failu

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

+ 18
- 0
.gitmodules Parādīt failu

@@ -0,0 +1,18 @@
1
+[submodule "fstools"]
2
+	path = fstools
3
+	url = https://git.mount-mockery.de/pylib/fstools.git
4
+[submodule "geo"]
5
+	path = geo
6
+	url = https://git.mount-mockery.de/pylib/geo.git
7
+[submodule "mycreole"]
8
+	path = mycreole
9
+	url = https://git.mount-mockery.de/django_lib/mycreole.git
10
+[submodule "pygal"]
11
+	path = pygal
12
+	url = https://git.mount-mockery.de/django_lib/pygal.git
13
+[submodule "themes"]
14
+	path = themes
15
+	url = https://git.mount-mockery.de/django_lib/themes.git
16
+[submodule "users"]
17
+	path = users
18
+	url = https://git.mount-mockery.de/django_lib/users.git

+ 17
- 0
.project Parādīt failu

@@ -0,0 +1,17 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<projectDescription>
3
+	<name>django_pygal</name>
4
+	<comment></comment>
5
+	<projects>
6
+	</projects>
7
+	<buildSpec>
8
+		<buildCommand>
9
+			<name>org.python.pydev.PyDevBuilder</name>
10
+			<arguments>
11
+			</arguments>
12
+		</buildCommand>
13
+	</buildSpec>
14
+	<natures>
15
+		<nature>org.python.pydev.pythonNature</nature>
16
+	</natures>
17
+</projectDescription>

+ 8
- 0
.pydevproject Parādīt failu

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+<?eclipse-pydev version="1.0"?><pydev_project>
3
+<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
4
+<path>/${PROJECT_DIR_NAME}</path>
5
+</pydev_pathproperty>
6
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
7
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
8
+</pydev_project>

+ 1
- 0
activate Parādīt failu

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

Binārs
data/example_data/building_scenery/IMG_20160824_113401.jpg Parādīt failu


Binārs
data/example_data/building_scenery/IMG_20160901_162221.jpg Parādīt failu


Binārs
data/example_data/building_scenery/IMG_20180104_213600.jpg Parādīt failu


Binārs
data/example_data/natural_scenery/20141226_135921.jpg Parādīt failu


Binārs
data/example_data/natural_scenery/DSC01058.JPG Parādīt failu


Binārs
data/example_data/natural_scenery/DSC_1150.JPG Parādīt failu


Binārs
data/example_data/natural_scenery/DSC_1163.JPG Parādīt failu


Binārs
data/example_data/natural_scenery/DSC_1167.JPG Parādīt failu


Binārs
data/example_data/natural_scenery/DSC_1864.JPG Parādīt failu


Binārs
data/example_data/natural_scenery/DSC_2573.JPG Parādīt failu


Binārs
data/media/theme/logo.png Parādīt failu


+ 1
- 0
fstools

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

+ 1
- 0
geo

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

+ 0
- 0
main/__init__.py Parādīt failu


+ 253
- 0
main/settings.py Parādīt failu

@@ -0,0 +1,253 @@
1
+"""
2
+Django settings for this project.
3
+
4
+Generated by 'django-admin startproject' using Django 2.2.3.
5
+
6
+For more information on this file, see
7
+https://docs.djangoproject.com/en/2.2/topics/settings/
8
+
9
+For the full list of settings and their values, see
10
+https://docs.djangoproject.com/en/2.2/ref/settings/
11
+"""
12
+
13
+try:
14
+    from config import config
15
+    # required keys: SECRET_KEY
16
+    # optional keys: ALLOWED_HOSTS, DEFAULT_THEME, ITEM_ROOT, THUMBNAIL_SIZES, WEBNAIL_SIZES
17
+except ImportError:
18
+    config = {}
19
+import os
20
+import random
21
+
22
+
23
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
24
+#
25
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
26
+
27
+
28
+# Quick-start development settings - unsuitable for production
29
+# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
30
+
31
+# SECURITY WARNING: keep the secret key used in production secret!
32
+#
33
+try:
34
+    SECRET_KEY = config['SECRET_KEY']
35
+except KeyError:
36
+    chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)'
37
+    s_key = ''.join([random.choice(chars) for n in range(50)])
38
+    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)
39
+    raise KeyError(secret_key_warning)
40
+# SECURITY WARNING: don't run with debug turned on in production!
41
+#
42
+DEBUG = False
43
+
44
+ALLOWED_HOSTS = config.get('ALLOWED_HOSTS', [])
45
+
46
+
47
+# Application definition
48
+#
49
+INSTALLED_APPS = [
50
+    'pygal.apps.PygalConfig',
51
+    'themes.apps.ThemesConfig',
52
+    'users.apps.UsersConfig',
53
+    #
54
+    'django.contrib.admin',
55
+    'django.contrib.auth',
56
+    'django.contrib.contenttypes',
57
+    'django.contrib.sessions',
58
+    'django.contrib.messages',
59
+    'django.contrib.staticfiles',
60
+]
61
+
62
+MIDDLEWARE = [
63
+    'django.middleware.security.SecurityMiddleware',
64
+    'django.contrib.sessions.middleware.SessionMiddleware',
65
+    'django.middleware.locale.LocaleMiddleware',
66
+    'django.middleware.common.CommonMiddleware',
67
+    'django.middleware.csrf.CsrfViewMiddleware',
68
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
69
+    'django.contrib.messages.middleware.MessageMiddleware',
70
+    'django.middleware.clickjacking.XFrameOptionsMiddleware',
71
+    'users.middleware.SettingsMiddleware',
72
+]
73
+
74
+ROOT_URLCONF = 'main.urls'
75
+
76
+TEMPLATES = [
77
+    {
78
+        'BACKEND': 'django.template.backends.django.DjangoTemplates',
79
+        'DIRS': [],
80
+        'APP_DIRS': True,
81
+        'OPTIONS': {
82
+            'context_processors': [
83
+                'django.template.context_processors.debug',
84
+                'django.template.context_processors.request',
85
+                'django.contrib.auth.context_processors.auth',
86
+                'django.contrib.messages.context_processors.messages',
87
+            ],
88
+        },
89
+    },
90
+]
91
+
92
+WSGI_APPLICATION = 'main.wsgi.application'
93
+
94
+
95
+# Database
96
+# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
97
+#
98
+DATABASES = {
99
+    'default': {
100
+        'ENGINE': 'django.db.backends.sqlite3',
101
+        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
102
+    }
103
+}
104
+
105
+
106
+# Password validation
107
+# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
108
+#
109
+AUTH_PASSWORD_VALIDATORS = [
110
+    {
111
+        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
112
+    },
113
+    {
114
+        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
115
+    },
116
+    {
117
+        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
118
+    },
119
+    {
120
+        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
121
+    },
122
+]
123
+
124
+
125
+# Search Engine
126
+#
127
+WHOOSH_PATH = os.path.join(BASE_DIR, 'data', 'whoosh_index')
128
+
129
+
130
+# Internationalization
131
+# https://docs.djangoproject.com/en/2.2/topics/i18n/
132
+#
133
+LANGUAGE_CODE = 'en-us'
134
+LANGUAGES = [
135
+    ('en', 'English'),
136
+    ('de', 'Deutsch'),
137
+]
138
+
139
+TIME_ZONE = 'UTC'
140
+
141
+USE_I18N = True
142
+LOCALE_PATHS = [
143
+    os.path.join(BASE_DIR, 'themes', 'locale'),
144
+    os.path.join(BASE_DIR, 'users', 'locale'),
145
+    os.path.join(BASE_DIR, 'pygal', 'locale'),
146
+]
147
+
148
+USE_L10N = True
149
+
150
+USE_TZ = True
151
+
152
+
153
+# Static files (CSS, JavaScript, Images)
154
+# https://docs.djangoproject.com/en/2.2/howto/static-files/
155
+#
156
+STATIC_ROOT = os.path.join(BASE_DIR, 'data', 'static')
157
+STATIC_URL = '/static/'
158
+
159
+MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media')
160
+MEDIA_URL = '/media/'
161
+
162
+
163
+# Session parameters
164
+#
165
+
166
+SESSION_KEY_THUMBNAIL_SIZE = 'thumbnail_size'
167
+SESSION_KEY_WEBNAIL_SIZE = 'webnail_size'
168
+PERSISTENT_SESSION_VARIABLES = [SESSION_KEY_THUMBNAIL_SIZE, SESSION_KEY_WEBNAIL_SIZE]
169
+
170
+
171
+# Logging Configuration
172
+#
173
+default_handler = ['console_long'] if DEBUG else ['console']
174
+#
175
+LOGGING = {
176
+    'version': 1,
177
+    'disable_existing_loggers': False,
178
+    'formatters': {
179
+        'short': {
180
+            'format': "%(asctime)s \"%(name)s - %(levelname)s - %(message)s\"",
181
+            'datefmt': '[%d/%b/%Y %H:%M:%S]',
182
+        },
183
+        'long': {
184
+            'format': """~~~~(%(levelname)-10s)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
185
+File "%(pathname)s", line %(lineno)d, in %(funcName)s
186
+%(asctime)s: %(name)s - %(message)s
187
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~""",
188
+        },
189
+    },
190
+    'handlers': {
191
+        'console': {
192
+            'level': 'DEBUG',
193
+            'class': 'logging.StreamHandler',
194
+            'formatter': 'short',
195
+        },
196
+        'console_long': {
197
+            'level': 'DEBUG',
198
+            'class': 'logging.StreamHandler',
199
+            'formatter': 'long',
200
+        },
201
+    },
202
+    'loggers': {
203
+        'AUTH': {
204
+            'handlers': default_handler,
205
+            'level': 'INFO',
206
+            'propagate': False,
207
+        },
208
+        'APP': {
209
+            'handlers': default_handler,
210
+            'level': 'INFO',
211
+            'propagate': False,
212
+        },
213
+        'CACHING': {
214
+            'handlers': default_handler,
215
+            'level': 'INFO',
216
+            'propagate': False,
217
+        },
218
+        'WHOOSH': {
219
+            'handlers': default_handler,
220
+            'level': 'INFO',
221
+            'propagate': False,
222
+        },
223
+        'FSTOOLS': {
224
+            'handlers': default_handler,
225
+            'level': 'INFO',
226
+            'propagate': False,
227
+        },
228
+        'GEO': {
229
+            'handlers': default_handler,
230
+            'level': 'INFO',
231
+            'propagate': False,
232
+        },
233
+    },
234
+}
235
+
236
+
237
+# Other Configuration issues
238
+#
239
+
240
+DATA_UPLOAD_MAX_NUMBER_FIELDS = 30000
241
+
242
+LOGIN_URL = 'users-login'
243
+
244
+XNAIL_ROOT = os.path.join(BASE_DIR, 'data', 'xnails')
245
+TEMP_ROOT = os.path.join(BASE_DIR, 'data', 'temp')
246
+
247
+
248
+# App Configuration
249
+#
250
+DEFAULT_THEME = config.get('DEFAULT_THEME', 'clear-red')
251
+ITEM_ROOT = config.get('ITEM_ROOT', os.path.join(BASE_DIR, 'data', 'example_data'))
252
+THUMBNAIL_SIZES = config.get('THUMBNAIL_SIZES', [137, 175, 250])
253
+WEBNAIL_SIZES = config.get('WEBNAIL_SIZES', [450, 1100, 1750])

+ 32
- 0
main/urls.py Parādīt failu

@@ -0,0 +1,32 @@
1
+"""Project URL Configuration
2
+
3
+The `urlpatterns` list routes URLs to views. For more information please see:
4
+    https://docs.djangoproject.com/en/2.2/topics/http/urls/
5
+Examples:
6
+Function views
7
+    1. Add an import:  from my_app import views
8
+    2. Add a URL to urlpatterns:  path('', views.home, name='home')
9
+Class-based views
10
+    1. Add an import:  from other_app.views import Home
11
+    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
12
+Including another URLconf
13
+    1. Import the include() function: from django.urls import include, path
14
+    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
15
+"""
16
+from django.conf import settings
17
+from django.conf.urls.static import static
18
+from django.contrib import admin
19
+from django.shortcuts import redirect
20
+from django.urls import path, include
21
+from django.urls.base import reverse
22
+import pygal
23
+
24
+urlpatterns = [
25
+    path('admin/', admin.site.urls),
26
+    path('pygal/', include('pygal.urls')),
27
+    path('users/', include('users.urls')),
28
+    path('', lambda request: redirect(reverse('pygal-responses', kwargs={'responsetype': pygal.RESP_TYPE_USERVIEW, 'datatype': pygal.DATA_TYPE_ITEM}), permanent=False)),
29
+]
30
+
31
+if settings.DEBUG:
32
+    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

+ 16
- 0
main/wsgi.py Parādīt failu

@@ -0,0 +1,16 @@
1
+"""
2
+WSGI config for this project.
3
+
4
+It exposes the WSGI callable as a module-level variable named ``application``.
5
+
6
+For more information on this file, see
7
+https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
8
+"""
9
+
10
+import os
11
+
12
+from django.core.wsgi import get_wsgi_application
13
+
14
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings')
15
+
16
+application = get_wsgi_application()

+ 21
- 0
manage.py Parādīt failu

@@ -0,0 +1,21 @@
1
+#!/usr/bin/env python
2
+"""Django's command-line utility for administrative tasks."""
3
+import os
4
+import sys
5
+
6
+
7
+def main():
8
+    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings')
9
+    try:
10
+        from django.core.management import execute_from_command_line
11
+    except ImportError as exc:
12
+        raise ImportError(
13
+            "Couldn't import Django. Are you sure it's installed and "
14
+            "available on your PYTHONPATH environment variable? Did you "
15
+            "forget to activate a virtual environment?"
16
+        ) from exc
17
+    execute_from_command_line(sys.argv)
18
+
19
+
20
+if __name__ == '__main__':
21
+    main()

+ 1
- 0
mycreole

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

+ 1
- 0
pygal

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

+ 18
- 0
readme.txt Parādīt failu

@@ -0,0 +1,18 @@
1
+1. Setupt venev
2
+  * virtualenv -p /usr/bin/python3 pygal-venv
3
+  * ln -s pygal-venv/bin/activate
4
+  * source activate
5
+  * Sometimes upgrades are needed: pip list --outdated | cut -d ' ' -f 1 | xargs pip install $1 --upgrade
6
+  * pip install -r requirements.txt
7
+2. python manage.py migrate
8
+3. python manage.py createsuperuser
9
+4. Set SECRET:KEY in config.py
10
+5. Set ITEM_ROOT in config.py to your item target path, otherwise the example_data is used
11
+6. python manage.py collectstatic
12
+7. chgrp www-data . && chmod 770 .
13
+8. chgrp www-data db.sqlite3 && chmod 664 db.sqlite3
14
+9. chgrp www-data -R data
15
+9.1. find data -type d -exec chmod 775 "{}" \;
16
+9.2. find data -type f -exec chmod 664 "{}" \;
17
+
18
+x. Run server by command "python manage.py runserver 0.0.0.0:8000" or add App to apache

+ 4
- 0
requirements.txt Parādīt failu

@@ -0,0 +1,4 @@
1
+Django>=2.0.5,<3.0
2
+Pillow>=5.4.1
3
+python-creole>=1.0.0
4
+Whoosh>=2.4.0

+ 1
- 0
themes

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

+ 1
- 0
users

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

Notiek ielāde…
Atcelt
Saglabāt