diff --git a/_deploy/debian_server b/_deploy/debian_server deleted file mode 100644 index 3c5293e..0000000 --- a/_deploy/debian_server +++ /dev/null @@ -1,160 +0,0 @@ -import os -import sys -import urllib.parse -from pathlib import Path - -"""Settings for a troggle installation which may vary among different -installations: for development or deployment, in a docker image or -python virtual environment (venv), on ubuntu, debian or in Windows -System for Linux (WSL), on the main server or in the potato hut, -using SQLite or mariaDB. - -It sets the directory locations for the major parts of the system so -that e.g. expofiles can be on a different filesystem. - -This file is included at the end of the main troggle/settings.py file so that -it overwrites defaults in that file. - -NOTE this file is vastly out of sync with troggle/_deploy/wsl/localsettings.py -which is the most recent version used in active maintenance. There should be -essential differences, but there and many, many non-essential differences which -should be eliminated for clarity and to use modern idioms. 8 March 2023. -""" - -print(" * importing troggle/localsettings.py") - -# DO NOT check this file into the git repo - it contains real passwords. - -EXPOFILESREMOTE = False # if True, then re-routes urls in expofiles to remote sever -#SECURE_SSL_REDIRECT = True # breaks 7 tests in test suite 301 not 200 (or 302) and runserver fails completely - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', # 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. - 'NAME' : 'troggle', # Or path to database file if using sqlite3. - 'USER' : 'expo', # Not used with sqlite3. - 'PASSWORD' : 'uFqP56B4XleeyIW', # Not used with sqlite3. - 'HOST' : '', # Set to empty string for localhost. Not used with sqlite3. - 'PORT' : '', # Set to empty string for default. Not used with sqlite3. - } -} - - -EXPOUSER = 'expo' -EXPOUSERPASS = '161:gosser' -EXPOADMINUSER = 'expoadmin' -EXPOADMINUSERPASS = 'gosser:161' -EXPOUSER_EMAIL = 'wookey@wookware.org' -EXPOADMINUSER_EMAIL = 'wookey@wookware.org' - -REPOS_ROOT_PATH = '/home/expo/' -sys.path.append(REPOS_ROOT_PATH) -sys.path.append(REPOS_ROOT_PATH + 'troggle') -# Define the path to the django app (troggle in this case) -PYTHON_PATH = REPOS_ROOT_PATH + 'troggle/' - - -PHOTOS_YEAR = "2023" -# add in 358 when they don't make it crash horribly -NOTABLECAVESHREFS = [ "290", "291", "359", "264", "258", "204", "76", "107"] - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [ - PYTHON_PATH + "templates" - ], - 'OPTIONS': { - 'debug': 'DEBUG', - 'context_processors': [ - # django.template.context_processors.csrf, # is always enabled and cannot be removed, sets csrf_token - 'django.contrib.auth.context_processors.auth', # knowledge of logged-on user & permissions - 'core.context.troggle_context', # in core/troggle.py - 'django.template.context_processors.debug', - #'django.template.context_processors.request', # copy of current request, added in trying to make csrf work - 'django.template.context_processors.i18n', - 'django.template.context_processors.media', # includes a variable MEDIA_URL - 'django.template.context_processors.static', # includes a variable STATIC_URL - 'django.template.context_processors.tz', - 'django.contrib.messages.context_processors.messages', - ], - 'loaders': [ - 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', #For each app, inc admin, in INSTALLED_APPS, loader looks for /templates - # insert your own TEMPLATE_LOADERS here - ] - }, - }, -] - -PUBLIC_SITE = True - -# This should be False for normal running -DEBUG = True -CACHEDPAGES = True # experimental page cache for a handful of page types - - -# executables: -CAVERN = 'cavern' # for parsing .svx files and producing .2d files -SURVEXPORT = 'survexport' # for parsing .3d files and producing .pos files - -PV = "python" + str(sys.version_info.major) + "." + str(sys.version_info.minor) -LIBDIR = Path(REPOS_ROOT_PATH) / 'lib' / PV - -EXPOWEB = Path(REPOS_ROOT_PATH + 'expoweb/') -SURVEYS = REPOS_ROOT_PATH -SURVEY_SCANS = REPOS_ROOT_PATH + 'expofiles/surveyscans/' -FILES = REPOS_ROOT_PATH + 'expofiles' -PHOTOS_ROOT = REPOS_ROOT_PATH + 'expofiles/photos/' - -TROGGLE_PATH = Path(__file__).parent -TEMPLATE_PATH = TROGGLE_PATH / 'templates' -MEDIA_ROOT = TROGGLE_PATH / 'media' -JSLIB_ROOT = TROGGLE_PATH / 'media' / 'jslib' # used for CaveViewer JS utility - - -CAVEDESCRIPTIONS = EXPOWEB / "cave_data" -ENTRANCEDESCRIPTIONS = EXPOWEB / "entrance_data" - - -PYTHON_PATH = REPOS_ROOT_PATH + 'troggle/' - - -#URL_ROOT = 'http://expo.survex.com/' -URL_ROOT = '/' -DIR_ROOT = Path("") #this should end in / if a value is given -EXPOWEB_URL = '/' -SURVEYS_URL = '/survey_scans/' - -REPOS_ROOT_PATH = Path(REPOS_ROOT_PATH) - -SURVEX_DATA = REPOS_ROOT_PATH / "loser" -DRAWINGS_DATA = REPOS_ROOT_PATH / "drawings" - - -EXPOFILES = REPOS_ROOT_PATH / "expofiles" -SCANS_ROOT = EXPOFILES / "surveyscans" -PHOTOS_ROOT = EXPOFILES / "photos" - -#EXPOFILES = urllib.parse.urljoin(REPOS_ROOT_PATH, 'expofiles/') -PHOTOS_URL = urllib.parse.urljoin(URL_ROOT, '/photos/') - -# MEDIA_URL is used by urls.py in a regex. See urls.py & core/views_surveys.py -MEDIA_URL = '/site_media/' - - -STATIC_URL = urllib.parse.urljoin(URL_ROOT , '/static/') # used by Django admin pages. Do not delete. -JSLIB_URL = urllib.parse.urljoin(URL_ROOT , '/javascript/') # always fails, try to revive it ? -# STATIC_ROOT removed after merging content into MEDIA_ROOT. See urls.py & core/views/surveys.py - -#TINY_MCE_MEDIA_ROOT = STATIC_ROOT + '/tiny_mce/' # not needed while TinyMCE not installed -#TINY_MCE_MEDIA_URL = STATIC_URL + '/tiny_mce/' # not needed while TinyMCE not installed - -LOGFILE = '/var/log/troggle/troggle.log' -IMPORTLOGFILE = '/var/log/troggle/import.log' - -# Sanitise these to be strings as Django seems to be particularly sensitive to crashing if they aren't -STATIC_URL = str(STATIC_URL) + "/" -MEDIA_URL = str(MEDIA_URL) + "/" - -print(" + finished importing troggle/localsettings.py") diff --git a/core/models/troggle.py b/core/models/troggle.py index 6155347..62fe9c1 100644 --- a/core/models/troggle.py +++ b/core/models/troggle.py @@ -78,7 +78,12 @@ class Expedition(TroggleModel): return reverse("expedition", args=[self.year]) class Person(TroggleModel): - """single Person, can go on many years""" + """single Person, can go on expo many years + + Note that the class "User" and the class "Group + are standrd Django classes + definied in django.contrib.auth.models + """ first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) @@ -100,8 +105,7 @@ class Person(TroggleModel): def get_absolute_url(self): # we do not use URL_ROOT any more. return reverse("person", kwargs={"slug": self.slug}) - return reverse("person", kwargs={"first_name": self.first_name, "last_name": self.last_name}) - + class Meta: verbose_name_plural = "People" ordering = ("orderref",) # "Wookey" makes too complex for: ('last_name', 'first_name') diff --git a/core/utils.py b/core/utils.py index 33872b3..d88f39f 100644 --- a/core/utils.py +++ b/core/utils.py @@ -157,6 +157,25 @@ def current_expo(): else: return settings.EPOCH.year # this is 1970 +def is_identified_user(user): + if user.is_anonymous: + return False + if user.username in ["expo", "expoadmin"]: + return False + return True + +def get_git_string(user): + if not is_identified_user(user): + return None + else: + people = Person.objects.filter(user=user) + if len(people) != 1: + # someone like "fluffy-bunny" not associated with a Person + return None + person = people[0] + return f"{person.fullname} <{user.email}>" + + def parse_aliases(aliasfile): """Reads a long text string containing pairs of strings: (alias, target) diff --git a/core/views/expo.py b/core/views/expo.py index 89215a4..63f1d33 100644 --- a/core/views/expo.py +++ b/core/views/expo.py @@ -19,7 +19,9 @@ from troggle.core.utils import ( current_expo, get_cookie, git_string, + get_git_string, write_and_commit, + is_identified_user ) from troggle.core.views.editor_helpers import HTMLarea from troggle.core.views.uploads import edittxtpage @@ -455,15 +457,17 @@ def editexpopage(request, path): print("### File not found ### ", filepath) filefound = False - editor = get_cookie(request) - + current_user = request.user + if identified_login := is_identified_user(current_user): + editor = get_git_string(current_user) + else: + editor = get_cookie(request) + if request.method == "POST": # If the form has been submitted... pageform = ExpoPageForm(request.POST) # A form bound to the POST data if pageform.is_valid(): # Form valid therefore write file editor = pageform.cleaned_data["who_are_you"] editor = git_string(editor) - # print("### \n", str(pageform)[0:300]) - # print("### \n csrfmiddlewaretoken: ",request.POST['csrfmiddlewaretoken']) if filefound: headmatch = re.match(r"(.*)
Submitting this form will subscribe you to the expo mailing list if you are not already subscribed.
- {% if personal_login %} + {% if identified_login %} {% else %}