From 0425560b9a94107df24e3dfae46d2994f061a2e0 Mon Sep 17 00:00:00 2001 From: AndiEcker Date: Sun, 29 Jan 2023 16:30:34 +0000 Subject: [PATCH] V0.3.80: associate new member to members group and refreshed requirements M dev_requirements.txt M docs/administrator_manual.rst M docs/programmer_manual.rst M kairos/__init__.py M kairos/settings.py M kairos/views.py M requirements.txt M requirements_221211.txt A requirements_230130.txt A var_www_kairosgomera_eu_pythonanywhere_com_wsgi.py --- dev_requirements.txt | 2 +- docs/administrator_manual.rst | 27 +++++++----- docs/programmer_manual.rst | 26 +++++++++-- kairos/__init__.py | 2 +- kairos/settings.py | 7 ++- kairos/views.py | 2 + requirements.txt | 5 +-- requirements_221211.txt | 2 +- requirements_230130.txt | 44 +++++++++++++++++++ ...kairosgomera_eu_pythonanywhere_com_wsgi.py | 14 ++++++ 10 files changed, 110 insertions(+), 21 deletions(-) create mode 100644 requirements_230130.txt create mode 100644 var_www_kairosgomera_eu_pythonanywhere_com_wsgi.py diff --git a/dev_requirements.txt b/dev_requirements.txt index 8c77a22..0314a64 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,2 +1,2 @@ -# THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.tpl_project V0.3.21 aedev_tpl_project +beautifulsoup4 # needed for _members_and_announcements_data_loader.py diff --git a/docs/administrator_manual.rst b/docs/administrator_manual.rst index a034a3e..e2ebfd0 100644 --- a/docs/administrator_manual.rst +++ b/docs/administrator_manual.rst @@ -2,17 +2,21 @@ administrator manual ******************** -website administrators are members with additional rights granted to maintain: +administrators are members with additional rights granted to maintain: - * members data * pages content, menus and tooltips + * members data * announcement categories, actions and any requests/offers * member messages * member meetings + * initial fee collection in the built-in member registration process + +most of these tasks can only be done by page content administrators, whereas the last two tasks can be done +by members with individual additional rights granted (see further down in the :ref:`member permissions` section). -as an administrators you are using an extra account to sign-in to get access to the -`Django admin toolbar and menus `_. the ``admin toolbar`` gets -then displayed at the top of your browser window as a fixed overlay: +as a page content administrator you are using an extra account to sign-in to get access to the +`Django admin toolbar and menus `_. +the ``admin toolbar`` gets then displayed at the top of your browser window as a fixed overlay: .. figure:: img/admin_toolbar.png :alt: configure administrator language @@ -51,11 +55,8 @@ see the :ref:`programmer manual` on how to bulk load member data into your websi member permissions ------------------ -a separate user account has to be created for members with an admin role, to manage the website pages and their content. -only these admin accounts should have the `is_staff` field of the user record set to True. the username field should -contain the first name of the member (instead of a member id). - -adding a member to the `members` user group results in the following permissions: +the built-in user registration process and bulk load process are adding a member automatically to the `members` +user group, which results in the following member permissions: * `perms.mbr_announcements.add_memberannouncement`: add an announcement. * `perms.mbr_announcements.change_memberannouncement`: edit an announcement. @@ -71,6 +72,12 @@ individual member accounts can have the following additional admin permissions: shown by the ``members meeting box`` plugin regarding the next association meeting. +a second/separate user account has to be created for members with an admin role, to manage the website pages and their +content. only these admin accounts should have the `is_staff` field of the user record set to True. in contrary to +"normal" members the username field of a page content admin account should contain the first name of the member +(instead of a member id). + + page content administration =========================== diff --git a/docs/programmer_manual.rst b/docs/programmer_manual.rst index f60470d..aecebac 100644 --- a/docs/programmer_manual.rst +++ b/docs/programmer_manual.rst @@ -218,12 +218,18 @@ the deployment of this website differs on the used hosting service company. initial deployment on pythonanywhere ------------------------------------ +the following steps are explained in more detail in the django tutorials of pythonanywhere, which are available +as a `guided tour (the eu version) +`_ as well as in a +`separate web-page `_: + * add static and media folders to repo by running locally: .. code-block:: shell git add -f media git add -f static + git add -f project.db (if you see warning on CRLF/LF conversions then correct them conversion e.g. with: :code:`git add -f -u --renormalize static`) @@ -235,7 +241,8 @@ initial deployment on pythonanywhere git clone https://gitlab.com/ae-group/kairos cd kairos mkvirtualenv --python=/usr/bin/python3.9 kairos-web39 - pip install -r requirements_221211.txt + pip install -r requirements.txt + pip freeze > requirements_yymmdd.txt * create new app and WSGI file (see "Setting up your Web app and WSGI file" in https://help.pythonanywhere.com/pages/DeployExistingDjangoProject/) @@ -269,8 +276,8 @@ initial deployment on pythonanywhere HISTFILESIZE=6000 -deployment of update from version Vx.x.xx to Vx.x.yy on pythonanywhere ----------------------------------------------------------------------- +update from version Vx.x.xx to Vx.x.yy on pythonanywhere +-------------------------------------------------------- * update develop branch on github by running: @@ -295,9 +302,22 @@ deployment of update from version Vx.x.xx to Vx.x.yy on pythonanywhere git clone https://gitlab.com/ae-group/kairos cp kairos_Vx.x.yy/project.db kairos + .. hint:: ``x.x.xx`` is the penultimate and ``x.x.yy`` is the ultimate/last version. + * go to the Web tab in pythonanywhere and reload the app (especially if you updated the gettext translation .mo files). +backup database, static and media files +--------------------------------------- + +to backup the resources of this web project, open a shell on your host, change into the root folder of this project, +and run the following command: + + .. code-block:: shell + + zip -r project.db media_ini media static + + configure or switch domain from siteground to pythonanywhere host ----------------------------------------------------------------- diff --git a/kairos/__init__.py b/kairos/__init__.py index 965ec25..8ecd353 100644 --- a/kairos/__init__.py +++ b/kairos/__init__.py @@ -63,4 +63,4 @@ TODO: """ -__version__ = '0.3.79' +__version__ = '0.3.80' diff --git a/kairos/settings.py b/kairos/settings.py index 0637b42..75c99bd 100644 --- a/kairos/settings.py +++ b/kairos/settings.py @@ -25,11 +25,12 @@ SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', 'f!toczfj-qv(60j0nn-n7-ok@@zl7q THUMBNAIL_DEBUG = DEBUG = os.environ.get('DJANGO_DEBUG', '') != 'False' -ALLOWED_HOSTS = ['127.0.0.1', +ALLOWED_HOSTS = ['kairos-gomera.org', + 'kairosgomera.eu.pythonanywhere.com', 'pythonanywhere.com', + '127.0.0.1', '127.0.1.1', '192.168.1.12', - 'kairos-gomera.org', 'aus', 'kairos-gomera.wooo.com'] @@ -72,9 +73,11 @@ MEDIA_ROOT = os.path.join(DATA_DIR, 'media') # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.1/howto/static-files/ STATIC_URL = '/static/' +# noinspection PyUnresolvedReferences STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'kairos', 'static'), ] +# noinspection PyUnresolvedReferences STATIC_ROOT = os.path.join(DATA_DIR, 'static') SITE_ID = 1 diff --git a/kairos/views.py b/kairos/views.py index 2c84945..5fb617c 100644 --- a/kairos/views.py +++ b/kairos/views.py @@ -4,6 +4,7 @@ from typing import Any, Optional from django.contrib import messages # type: ignore from django.contrib.auth import get_user_model # type: ignore +from django.contrib.auth.models import Group # type: ignore # noqa: E402 from django.contrib.auth.tokens import PasswordResetTokenGenerator # type: ignore from django.contrib.auth.views import LoginView # type: ignore from django.db.models import IntegerField, Q # type: ignore @@ -84,6 +85,7 @@ def _activate_member(member_pk: int, request, token: Optional[str] = None): elif not _dup_member_messages(dup_members, request, msg_prefix, username, member_rec.last_name, member_rec.email): member_rec.is_active = True member_rec.username = username + member_rec.groups.add(Group.objects.get(name='members')) member_rec.save() # pylint: disable-next=no-member # false positive on .objects diff --git a/requirements.txt b/requirements.txt index bf2cc17..c697f03 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ ae_django_utils ae_notify -beautifulsoup4 django-cms>=3.8,<3.9 djangocms-admin-style>=2.0,<3.0 django-treebeard>=4.0,<4.5 # 4.5 raises exception on publish (see kairos/__init__.py) @@ -13,13 +12,13 @@ djangocms-video>=3.0,<4.0 djangocms-file>=3.0,<4.0 djangocms-picture>=3.0,<4.0 djangocms-bootstrap4>=2.0,<3.0 -easy_thumbnails django-filer>=1.3 Django<3.2 django-classy-tags>=2.0 django-sekizai>=2.0 django-mptt>0.9 -django-crispy-forms +django-crispy-forms<2.0 # bootstrap 4 will get removed in 2.0 +easy_thumbnails html5lib>=1.0.1 Pillow>=3.0 python-dotenv diff --git a/requirements_221211.txt b/requirements_221211.txt index 9a8f4c6..ff65aed 100644 --- a/requirements_221211.txt +++ b/requirements_221211.txt @@ -3,7 +3,7 @@ ae-console==0.3.63 ae-core==0.3.54 ae-django-utils==0.3.1 ae-files==0.3.19 -ae-inspector==0.3.13 +ae-dynamicod==0.3.14 ae-literal==0.3.32 ae-notify==0.3.1 ae-parse-date==0.3.4 diff --git a/requirements_230130.txt b/requirements_230130.txt new file mode 100644 index 0000000..876feee --- /dev/null +++ b/requirements_230130.txt @@ -0,0 +1,44 @@ +ae-django-utils==0.3.1 +ae-notify==0.3.1 +asgiref==3.6.0 +certifi==2022.12.7 +charset-normalizer==3.0.1 +cssselect2==0.7.0 +Django==3.1.14 +django-classy-tags==3.0.1 +django-cms==3.8.0 +django-crispy-forms==1.14.0 +django-filer==2.2.4 +django-formtools==2.4 +django-js-asset==2.0.0 +django-mptt==0.14.0 +django-polymorphic==3.1.0 +django-sekizai==3.0.1 +django-treebeard==4.4 +djangocms-admin-style==2.0.2 +djangocms-attributes-field==2.1.0 +djangocms-bootstrap4==2.0.0 +djangocms-file==3.0.0 +djangocms-googlemap==2.0.0 +djangocms-icon==2.0.0 +djangocms-link==3.1.0 +djangocms-picture==3.0.0 +djangocms-style==3.0.0 +djangocms-text-ckeditor==4.0.0 +djangocms-video==3.0.0 +easy-thumbnails==2.8.5 +html5lib==1.1 +idna==3.4 +lxml==4.9.2 +Pillow==9.4.0 +python-dotenv==0.21.1 +pytz==2022.7.1 +reportlab==3.6.12 +requests==2.28.2 +six==1.16.0 +sqlparse==0.4.3 +svglib==1.5.1 +tinycss2==1.2.1 +Unidecode==1.1.2 +urllib3==1.26.14 +webencodings==0.5.1 diff --git a/var_www_kairosgomera_eu_pythonanywhere_com_wsgi.py b/var_www_kairosgomera_eu_pythonanywhere_com_wsgi.py new file mode 100644 index 0000000..dc145e6 --- /dev/null +++ b/var_www_kairosgomera_eu_pythonanywhere_com_wsgi.py @@ -0,0 +1,14 @@ +import os +import sys +from dotenv import load_dotenv + +path = '/home/kairosgomera/kairos' +if path not in sys.path: + sys.path.append(path) + +load_dotenv() + +os.environ['DJANGO_SETTINGS_MODULE'] = 'kairos.settings' + +from django.core.wsgi import get_wsgi_application +application = get_wsgi_application() -- GitLab