mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-04-02 21:30:59 +01:00
apparently all working
This commit is contained in:
@@ -307,6 +307,7 @@ def logbookedit(request, year=None, slug=None):
|
|||||||
if json_entries_dir.is_dir(): # only 2025 currently, or the current expo
|
if json_entries_dir.is_dir(): # only 2025 currently, or the current expo
|
||||||
print(f"- Rewriting JUST this edited logbook entry to a JSON file. ")
|
print(f"- Rewriting JUST this edited logbook entry to a JSON file. ")
|
||||||
this_entry = LogbookEntry.objects.get(slug=slug)
|
this_entry = LogbookEntry.objects.get(slug=slug)
|
||||||
|
|
||||||
write_entries_json([this_entry], year, editor)
|
write_entries_json([this_entry], year, editor)
|
||||||
else:
|
else:
|
||||||
print(f"- Rewriting the entire {year} logbook to disc ")
|
print(f"- Rewriting the entire {year} logbook to disc ")
|
||||||
@@ -329,22 +330,22 @@ def logbookedit(request, year=None, slug=None):
|
|||||||
commit_msg = f"Online edit of logbookentry {slug}"
|
commit_msg = f"Online edit of logbookentry {slug}"
|
||||||
add_commit(contents_path, commit_msg, editor)
|
add_commit(contents_path, commit_msg, editor)
|
||||||
|
|
||||||
# This does not change the URL in the browser, so despite a new slug being created,
|
# This does not change the URL in the browser, so despite a new slug being created,
|
||||||
# the next time this code is run it thinks a new slug needs to be created. So we should
|
# the next time this code is run it thinks a new slug needs to be created. So we should
|
||||||
# actually redirect to a new URL (an edit not a create) not simply return a render object.
|
# actually redirect to a new URL (an edit not a create) not simply return a render object.
|
||||||
# logbookedit/2022-08-21a
|
# logbookedit/2022-08-21a
|
||||||
|
|
||||||
# HOWEVER by doing a redirect rather than returning a rendered page, we lose all the
|
# HOWEVER by doing a redirect rather than returning a rendered page, we lose all the
|
||||||
# error settings e.g dateflag and authroflag so the user gets no feedback about bad data entered.
|
# error settings e.g dateflag and authroflag so the user gets no feedback about bad data entered.
|
||||||
# so we need to pass the flags explicitly in the url and then extract them from the request in the GET bit. sigh.
|
# so we need to pass the flags explicitly in the url and then extract them from the request in the GET bit. sigh.
|
||||||
response = HttpResponseRedirect(f"/logbookedit/{slug}?dateflag={dateflag}&authorflag={authorflag}")
|
response = HttpResponseRedirect(f"/logbookedit/{slug}?dateflag={dateflag}&authorflag={authorflag}")
|
||||||
response.set_cookie('editor_id', editor, max_age=get_cookie_max_age(request)) # cookie expires after get_cookie_max_age(request) seconds
|
response.set_cookie('editor_id', editor, max_age=get_cookie_max_age(request)) # cookie expires after get_cookie_max_age(request) seconds
|
||||||
return response
|
return response
|
||||||
|
|
||||||
# Do the redirect instead of this:
|
# Do the redirect instead of this:
|
||||||
|
|
||||||
# Code fragment illustration - not actually what gets saved to database
|
# Code fragment illustration - not actually what gets saved to database
|
||||||
# output = f'''
|
# output = f'''
|
||||||
|
|
||||||
# <div class="tripdate" id="{slug}">{date}</div>
|
# <div class="tripdate" id="{slug}">{date}</div>
|
||||||
# <div class="trippeople"><u>{author}</u>, {others}</div>
|
# <div class="trippeople"><u>{author}</u>, {others}</div>
|
||||||
@@ -356,22 +357,22 @@ def logbookedit(request, year=None, slug=None):
|
|||||||
# <hr />
|
# <hr />
|
||||||
|
|
||||||
# ''' # return render(
|
# ''' # return render(
|
||||||
# request,
|
# request,
|
||||||
# "logbookform.html",
|
# "logbookform.html",
|
||||||
# {
|
# {
|
||||||
# "form": form,
|
# "form": form,
|
||||||
# "year": year,
|
# "year": year,
|
||||||
# "date": date, "dateflag": dateflag,
|
# "date": date, "dateflag": dateflag,
|
||||||
# "author": author, "authorflag": authorflag,
|
# "author": author, "authorflag": authorflag,
|
||||||
# "others": others,
|
# "others": others,
|
||||||
# "place": place,
|
# "place": place,
|
||||||
# "title": title,
|
# "title": title,
|
||||||
# "tu": tu,
|
# "tu": tu,
|
||||||
# "entry": entry,
|
# "entry": entry,
|
||||||
# "output": output,
|
# "output": output,
|
||||||
# "slug": slug,
|
# "slug": slug,
|
||||||
# },
|
# },
|
||||||
# )
|
# )
|
||||||
|
|
||||||
# GET here. Does not fall-through from the POST section.
|
# GET here. Does not fall-through from the POST section.
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -476,6 +476,7 @@ def write_entries_json(entries, year, editor):
|
|||||||
|
|
||||||
for le in entries:
|
for le in entries:
|
||||||
# filename = f"{le.slug}-{le.pk:03}.json"
|
# filename = f"{le.slug}-{le.pk:03}.json"
|
||||||
|
print(le)
|
||||||
filename = f"{le.slug}.json"
|
filename = f"{le.slug}.json"
|
||||||
filepath = dirpath / filename
|
filepath = dirpath / filename
|
||||||
ensure_dir_exists(filepath)
|
ensure_dir_exists(filepath)
|
||||||
@@ -483,7 +484,7 @@ def write_entries_json(entries, year, editor):
|
|||||||
entrydict = serialize_logentry(le)
|
entrydict = serialize_logentry(le)
|
||||||
write_json_file(entrydict)
|
write_json_file(entrydict)
|
||||||
git_add(filename, dirpath)
|
git_add(filename, dirpath)
|
||||||
|
|
||||||
commit_msg = f"Exporting {len(entries)} logbook entries as individual files."
|
commit_msg = f"Exporting {len(entries)} logbook entries as individual files."
|
||||||
git_commit(dirpath, commit_msg, editor)
|
git_commit(dirpath, commit_msg, editor)
|
||||||
return True
|
return True
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
Traceback (most recent call last):
|
||||||
|
File "/home/philip/expo/troggle/manage.py", line 35, in <module>
|
||||||
|
execute_from_command_line(sys.argv)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
|
||||||
|
File "/home/philip/expo/troggle/.venv/lib/python3.13/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
|
||||||
|
utility.execute()
|
||||||
|
~~~~~~~~~~~~~~~^^
|
||||||
|
File "/home/philip/expo/troggle/.venv/lib/python3.13/site-packages/django/core/management/__init__.py", line 416, in execute
|
||||||
|
django.setup()
|
||||||
|
~~~~~~~~~~~~^^
|
||||||
|
File "/home/philip/expo/troggle/.venv/lib/python3.13/site-packages/django/__init__.py", line 24, in setup
|
||||||
|
apps.populate(settings.INSTALLED_APPS)
|
||||||
|
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/philip/expo/troggle/.venv/lib/python3.13/site-packages/django/apps/registry.py", line 91, in populate
|
||||||
|
app_config = AppConfig.create(entry)
|
||||||
|
File "/home/philip/expo/troggle/.venv/lib/python3.13/site-packages/django/apps/config.py", line 123, in create
|
||||||
|
mod = import_module(mod_path)
|
||||||
|
File "/home/philip/.local/share/uv/python/cpython-3.13.1-linux-x86_64-gnu/lib/python3.13/importlib/__init__.py", line 88, in import_module
|
||||||
|
return _bootstrap._gcd_import(name[level:], package, level)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
|
||||||
|
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
|
||||||
|
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
|
||||||
|
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
|
||||||
|
File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
|
||||||
|
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
|
||||||
|
File "/home/philip/expo/troggle/.venv/lib/python3.13/site-packages/django/contrib/auth/apps.py", line 8, in <module>
|
||||||
|
from .checks import check_middleware, check_models_permissions, check_user_model
|
||||||
|
File "/home/philip/expo/troggle/.venv/lib/python3.13/site-packages/django/contrib/auth/checks.py", line 9, in <module>
|
||||||
|
from .management import _get_builtin_permissions
|
||||||
|
File "/home/philip/expo/troggle/.venv/lib/python3.13/site-packages/django/contrib/auth/management/__init__.py", line 10, in <module>
|
||||||
|
from django.contrib.contenttypes.management import create_contenttypes
|
||||||
|
File "/home/philip/expo/troggle/.venv/lib/python3.13/site-packages/django/contrib/contenttypes/management/__init__.py", line 2, in <module>
|
||||||
|
from django.db import DEFAULT_DB_ALIAS, IntegrityError, migrations, router, transaction
|
||||||
|
File "/home/philip/expo/troggle/.venv/lib/python3.13/site-packages/django/db/migrations/__init__.py", line 1, in <module>
|
||||||
|
from .migration import Migration, swappable_dependency # NOQA
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
ModuleNotFoundError: No module named 'django.db.migrations.migration'
|
||||||
|
|||||||
Reference in New Issue
Block a user