Browse Source

Initial django-patt implementation

master
Dirk Alders 4 years ago
parent
commit
7b8c7820af
16 changed files with 361 additions and 0 deletions
  1. 2
    0
      .gitignore
  2. 15
    0
      .gitmodules
  3. 1
    0
      activate
  4. BIN
      data/media/theme/logo.png
  5. 1
    0
      fstools
  6. 0
    0
      main/__init__.py
  7. 247
    0
      main/settings.py
  8. 32
    0
      main/urls.py
  9. 16
    0
      main/wsgi.py
  10. 21
    0
      manage.py
  11. 1
    0
      mycreole
  12. 1
    0
      patt
  13. 17
    0
      readme.txt
  14. 5
    0
      requirements.txt
  15. 1
    0
      themes
  16. 1
    0
      users

+ 2
- 0
.gitignore View File

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

+ 15
- 0
.gitmodules View File

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

+ 1
- 0
activate View File

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

BIN
data/media/theme/logo.png View File


+ 1
- 0
fstools

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

+ 0
- 0
main/__init__.py View File


+ 247
- 0
main/settings.py View File

@@ -0,0 +1,247 @@
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
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 = True
43
+
44
+ALLOWED_HOSTS = config.get('ALLOWED_HOSTS', [])
45
+
46
+
47
+# Application definition
48
+#
49
+INSTALLED_APPS = [
50
+    'patt.apps.PattConfig',
51
+    'themes.apps.ThemesConfig',
52
+    'users.apps.UsersConfig',
53
+    'mycreole.apps.MycreoleConfig',
54
+    #
55
+    'django.contrib.admin',
56
+    'django.contrib.auth',
57
+    'django.contrib.contenttypes',
58
+    'django.contrib.sessions',
59
+    'django.contrib.messages',
60
+    'django.contrib.staticfiles',
61
+    'simple_history',
62
+]
63
+
64
+MIDDLEWARE = [
65
+    'django.middleware.security.SecurityMiddleware',
66
+    'django.contrib.sessions.middleware.SessionMiddleware',
67
+    'django.middleware.locale.LocaleMiddleware',
68
+    'django.middleware.common.CommonMiddleware',
69
+    'django.middleware.csrf.CsrfViewMiddleware',
70
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
71
+    'django.contrib.messages.middleware.MessageMiddleware',
72
+    'django.middleware.clickjacking.XFrameOptionsMiddleware',
73
+    'simple_history.middleware.HistoryRequestMiddleware',
74
+    'users.middleware.SettingsMiddleware',
75
+]
76
+
77
+ROOT_URLCONF = 'main.urls'
78
+
79
+TEMPLATES = [
80
+    {
81
+        'BACKEND': 'django.template.backends.django.DjangoTemplates',
82
+        'DIRS': [],
83
+        'APP_DIRS': True,
84
+        'OPTIONS': {
85
+            'context_processors': [
86
+                'django.template.context_processors.debug',
87
+                'django.template.context_processors.request',
88
+                'django.contrib.auth.context_processors.auth',
89
+                'django.contrib.messages.context_processors.messages',
90
+            ],
91
+        },
92
+    },
93
+]
94
+
95
+WSGI_APPLICATION = 'main.wsgi.application'
96
+
97
+
98
+# Database
99
+# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
100
+#
101
+DATABASES = {
102
+    'default': {
103
+        'ENGINE': 'django.db.backends.sqlite3',
104
+        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
105
+    }
106
+}
107
+
108
+
109
+# Password validation
110
+# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
111
+#
112
+AUTH_PASSWORD_VALIDATORS = [
113
+    {
114
+        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
115
+    },
116
+    {
117
+        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
118
+    },
119
+    {
120
+        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
121
+    },
122
+    {
123
+        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
124
+    },
125
+]
126
+
127
+# Search Engine
128
+#
129
+WHOOSH_PATH = os.path.join(BASE_DIR, 'data', 'whoosh_index')
130
+
131
+
132
+# Internationalization
133
+# https://docs.djangoproject.com/en/2.2/topics/i18n/
134
+#
135
+LANGUAGE_CODE = 'en-us'
136
+LANGUAGES = [
137
+    ('en', 'English'),
138
+    ('de', 'Deutsch'),
139
+]
140
+
141
+TIME_ZONE = 'UTC'
142
+
143
+USE_I18N = True
144
+LOCALE_PATHS = [
145
+    os.path.join(BASE_DIR, 'themes', 'locale'),
146
+    os.path.join(BASE_DIR, 'users', 'locale'),
147
+    os.path.join(BASE_DIR, 'patt', 'locale'),
148
+]
149
+
150
+USE_L10N = True
151
+
152
+USE_TZ = True
153
+
154
+
155
+# Static files (CSS, JavaScript, Images)
156
+# https://docs.djangoproject.com/en/2.2/howto/static-files/
157
+#
158
+STATIC_ROOT = os.path.join(BASE_DIR, 'data', 'static')
159
+STATIC_URL = '/static/'
160
+
161
+MEDIA_ROOT = os.path.join(BASE_DIR, 'data', 'media')
162
+MEDIA_URL = '/media/'
163
+
164
+MYCREOLE_ROOT = os.path.join(BASE_DIR, 'data', 'mycreole')
165
+MYCREOLE_ATTACHMENT_ACCESS = {
166
+    'read': 'patt.access.read_attachment',
167
+    'modify': 'patt.access.modify_attachment',
168
+}
169
+MYCREOLE_EXT_FILTERS = [
170
+    'patt.creole.task_link_filter',
171
+    'patt.creole.tasklist_link_filter',
172
+]
173
+
174
+# Session parameters
175
+#
176
+PERSISTENT_SESSION_VARIABLES = []
177
+
178
+
179
+# Logging Configuration
180
+#
181
+debug_handler = 'console'
182
+default_handler = [debug_handler] if DEBUG else ['console']
183
+#
184
+LOGGING = {
185
+    'version': 1,
186
+    'disable_existing_loggers': False,
187
+    'formatters': {
188
+        'short': {
189
+            'format': "%(asctime)s \"%(name)s - %(levelname)s - %(message)s\"",
190
+            'datefmt': '[%d/%b/%Y %H:%M:%S]',
191
+        },
192
+        'long': {
193
+            'format': """~~~~(%(levelname)-10s)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
194
+File "%(pathname)s", line %(lineno)d, in %(funcName)s
195
+%(asctime)s: %(name)s - %(message)s
196
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~""",
197
+        },
198
+    },
199
+    'handlers': {
200
+        'console': {
201
+            'level': 'DEBUG',
202
+            'class': 'logging.StreamHandler',
203
+            'formatter': 'short',
204
+        },
205
+        'console_long': {
206
+            'level': 'DEBUG',
207
+            'class': 'logging.StreamHandler',
208
+            'formatter': 'long',
209
+        },
210
+    },
211
+    'loggers': {
212
+        'AUTH': {
213
+            'handlers': default_handler,
214
+            'level': 'INFO',
215
+            'propagate': False,
216
+        },
217
+        'ACC': {
218
+            'handlers': default_handler,
219
+            'level': 'INFO',
220
+            'propagate': False,
221
+        },
222
+        'APP': {
223
+            'handlers': default_handler,
224
+            'level': 'INFO',
225
+            'propagate': False,
226
+        },
227
+        'WHOOSH': {
228
+            'handlers': default_handler,
229
+            'level': 'INFO',
230
+            'propagate': False,
231
+        },
232
+        'FSTOOLS': {
233
+            'handlers': default_handler,
234
+            'level': 'INFO',
235
+            'propagate': False,
236
+        },
237
+    },
238
+}
239
+
240
+
241
+# Other Configuration issues
242
+#
243
+LOGIN_URL = 'users-login'
244
+
245
+# App Configuration
246
+#
247
+DEFAULT_THEME = config.get('DEFAULT_THEME', 'clear-green')

+ 32
- 0
main/urls.py View File

@@ -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
+
22
+
23
+urlpatterns = [
24
+    path('admin/', admin.site.urls),
25
+    path('patt/', include('patt.urls')),
26
+    path('users/', include('users.urls')),
27
+    path('mycreole/', include('mycreole.urls')),
28
+    path('', lambda request: redirect('patt/', permanent=False)),
29
+]
30
+
31
+if settings.DEBUG:
32
+    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

+ 16
- 0
main/wsgi.py View File

@@ -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 View File

@@ -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
patt

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

+ 17
- 0
readme.txt View File

@@ -0,0 +1,17 @@
1
+1. Setupt venev
2
+  * virtualenv -p /usr/bin/python3 patt-venv
3
+  * ln -s patt-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. Set SECRET:KEY in config.py
8
+3. python manage.py migrate
9
+4. python manage.py createsuperuser
10
+5. python manage.py collectstatic
11
+6. chgrp www-data . && chmod 770 .
12
+7. chgrp www-data db.sqlite3 && chmod 664 db.sqlite3
13
+8. chgrp www-data -R data
14
+8.1. find data -type d -exec chmod 775 "{}" \;
15
+8.2. find data -type f -exec chmod 664 "{}" \;
16
+
17
+x. Run server by command "python manage.py runserver 0.0.0.0:8000" or add App to apache

+ 5
- 0
requirements.txt View File

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

+ 1
- 0
themes

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

+ 1
- 0
users

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

Loading…
Cancel
Save