mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-21 14:51:51 +00:00
new entry deletuion capability
This commit is contained in:
parent
6729698d7b
commit
12fa55f537
@ -3,9 +3,11 @@ import re
|
||||
from django.db.models import Q
|
||||
from django.shortcuts import render
|
||||
from django.views.generic.list import ListView
|
||||
from django.shortcuts import render, redirect
|
||||
|
||||
|
||||
import troggle.settings as settings
|
||||
from troggle.core.models.logbooks import LogbookEntry, PersonLogEntry, QM
|
||||
from troggle.core.models.logbooks import LogbookEntry, PersonLogEntry, QM, writelogbook
|
||||
from troggle.core.models.survex import SurvexBlock, SurvexFile
|
||||
from troggle.core.models.troggle import Expedition, Person
|
||||
from troggle.core.models.wallets import Wallet
|
||||
@ -218,6 +220,31 @@ def personexpedition(request, slug="", year=""):
|
||||
print(msg)
|
||||
return render(request, "errors/generic.html", {"message": msg})
|
||||
|
||||
def logentrydelete(request, year):
|
||||
"""This only gets called by a POST from the logreport page
|
||||
|
||||
The function in memory of James Waite who managed to make so many duplicate logbook entries
|
||||
that we needed a sopecial mechanism to delete them.
|
||||
"""
|
||||
eslug = request.POST["entry_slug"]
|
||||
entry = LogbookEntry.objects.get(slug=eslug)
|
||||
# OK we delete it formt he db and then re-save logbook.html file
|
||||
# to ensure that the permanent record also has the entry deleted.
|
||||
entry.delete()
|
||||
|
||||
print(f"- Rewriting the entire {year} logbook to disc ")
|
||||
filename= "logbook.html"
|
||||
try:
|
||||
writelogbook(year, filename) # uses a template
|
||||
except:
|
||||
message = f'! - Logbook saving failed - \n!! Permissions failure ?! on attempting to save file "logbook.html"'
|
||||
print(message)
|
||||
return render(request, "errors/generic.html", {"message": message})
|
||||
|
||||
|
||||
return redirect(f"/logreport/{year}")
|
||||
|
||||
|
||||
def logreport(request, year=1999):
|
||||
"""
|
||||
Remember that 'personexpedition__expedition' is interpreted by Django to mean the
|
||||
@ -231,7 +258,12 @@ def logreport(request, year=1999):
|
||||
expeditions = Expedition.objects.all() # top menu only, evaluated only when template renders
|
||||
dates = None
|
||||
dateditems = None
|
||||
logged_in = False
|
||||
|
||||
|
||||
if request.user.is_superuser: # expoadmin is both .is_staff and ._is_superuser
|
||||
logged_in = True
|
||||
|
||||
|
||||
try:
|
||||
expo = Expedition.objects.get(year=int(year))
|
||||
@ -265,6 +297,7 @@ def logreport(request, year=1999):
|
||||
"settings": settings,
|
||||
"dateditems": dateditems,
|
||||
"dates": dates,
|
||||
"logged_in": logged_in,
|
||||
}
|
||||
# print(f"logreport(): rendering..")
|
||||
return render(request, "logreport.html", context)
|
||||
|
@ -291,7 +291,7 @@ class LoadingSurvex:
|
||||
rx_include = re.compile(r"(?i)^\s*(\*include[\s].*)$")
|
||||
rx_include2 = re.compile("(?i)include$")
|
||||
rx_commref = re.compile(r"(?i)^\s*ref(?:erence)?[\s.:]*(\d+)\s*#\s*(X)?\s*(\d+)")
|
||||
rx_ref_text = re.compile(r'(?i)^\s*\"[^"]*\"\s*$')
|
||||
rx_ref_text = re.compile(r'(?i)^\s*\"[^"]*\"\s*$')
|
||||
rx_star = re.compile(r"(?i)\s*\*[\s,]*(\w+)\s*(.*?)\s*(?:;.*)?$")
|
||||
rx_starref = re.compile(r"(?i)^\s*\*ref[\s.:]*((?:19[6789]\d)|(?:20[0123]\d))\s*#?\s*(X)?\s*(.*?\d+.*?)$")
|
||||
rx_argsref = re.compile(r"(?i)^[\s.:]*((?:19[6789]\d)|(?:20[012345]\d))\s*#?\s*(X)?\s*(.*?\d+.*?)$")
|
||||
@ -2689,7 +2689,7 @@ def survexifywallets():
|
||||
if b.parent.scanswallet != sentinelbad:
|
||||
b.scanswallet = b.parent.scanswallet
|
||||
continue
|
||||
message = f" ! *REF missing {b.date} {b.survexfile}.svx : '{b}'"
|
||||
message = f" ! *REF missing {b.date} {b.survexfile}.svx : '{b}'" # msg appears if a *ref "something in quotes" actually does exist.
|
||||
if b.date > date(2019, 1, 1) and b.date < date(2020, 1, 1):
|
||||
print(message, file=sys.stderr)
|
||||
url = get_offending_filename(b.survexfile.path)
|
||||
|
@ -19,9 +19,14 @@
|
||||
</p>
|
||||
|
||||
<p>(Hover mouse over the date to see the slug for the entry.)
|
||||
{% if logged_in %}<font color="red">Logged in as expoadmin</font>{% endif %}
|
||||
|
||||
|
||||
|
||||
<table class="expeditionlogbooks">
|
||||
<tr><th>Date</th><th>Logged trips and diary entries</th><th>Cave</th><th>Text..</th><th>Words</th><th>Author</th><th>Who else</th></tr>
|
||||
<tr><th>Date</th><th>Logged trips and diary entries</th><th>Cave</th><th>Text..</th><th>Words</th><th>Author</th><th>Who else</th>
|
||||
{% if logged_in %}<th><font color="red">Admin</font></th>{% endif %}
|
||||
</tr>
|
||||
{% regroup dateditems|dictsort:"date" by date as dates %}
|
||||
{% for date in dates %}
|
||||
{% for entry in date.list %}
|
||||
@ -52,12 +57,20 @@
|
||||
<a href="/personexpedition/{{w.personexpedition.person}}/{{year}}">{{w.nickname_used}}</a>,
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
</td>
|
||||
{% if logged_in %}
|
||||
<form name="import" method="post" action="/logentrydelete/{{year}}">{% csrf_token %}
|
||||
<td><input type="hidden" value="{{entry.slug}}" name="entry_slug">
|
||||
<input type="submit" value="delete"></td>
|
||||
</form>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
<p>See also:
|
||||
<ul>
|
||||
|
4
urls.py
4
urls.py
@ -15,7 +15,7 @@ from troggle.core.views.expo import (pubspage, indexpage, editexpopage, expofile
|
||||
expofilessingle, expopage, map, mapfile,
|
||||
mediapage, spider)
|
||||
from troggle.core.views.logbooks import (QMs_jsonListView, Expeditions_jsonListView,
|
||||
Expeditions_tsvListView, expedition, logreport,
|
||||
Expeditions_tsvListView, expedition, logreport, logentrydelete,
|
||||
get_logbook_entries, get_people,
|
||||
logbookentry, notablepersons, person,
|
||||
personexpedition)
|
||||
@ -150,6 +150,8 @@ trogglepatterns = [
|
||||
re_path(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', logbookentry,name="logbookentry"),
|
||||
re_path(r'^logbook$', exportlogbook, name='exportlogbook'),
|
||||
path('logreport/<slug:year>', logreport, name='logreport'),
|
||||
path('logentrydelete/<slug:year>', logentrydelete, name='logentrydelete'),
|
||||
|
||||
|
||||
# Internal. editfile.html template uses these internally
|
||||
re_path(r'^getPeople/(?P<expeditionslug>.*)', get_people, name = "get_people"),
|
||||
|
Loading…
Reference in New Issue
Block a user