2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-17 13:57:06 +00:00

identified login for last form: survexfile. All done now.

This commit is contained in:
2025-02-17 21:23:20 +02:00
parent 6a5513e52b
commit 95878e630d
2 changed files with 21 additions and 5 deletions

View File

@@ -17,9 +17,16 @@ from troggle.core.models.caves import Cave, GetCaveLookup
from troggle.core.models.logbooks import LogbookEntry from troggle.core.models.logbooks import LogbookEntry
from troggle.core.models.survex import SurvexBlock, SurvexFile #, SurvexDirectory from troggle.core.models.survex import SurvexBlock, SurvexFile #, SurvexDirectory
from troggle.core.models.wallets import Wallet from troggle.core.models.wallets import Wallet
from troggle.core.utils import COOKIE_MAX_AGE, add_commit, current_expo, get_cookie, git_string from troggle.core.utils import (
COOKIE_MAX_AGE,
add_commit,
current_expo,
get_editor,
is_identified_user,
git_string)
from troggle.parsers.survex import parse_one_file from troggle.parsers.survex import parse_one_file
"""Everything that views survexfiles """Everything that views survexfiles
but also displays data on a cave or caves when there is ambiguity but also displays data on a cave or caves when there is ambiguity
""" """
@@ -146,6 +153,8 @@ class SvxForm(forms.Form):
This is not a ModelForm. This is not a ModelForm.
see https://docs.djangoproject.com/en/5.1/topics/forms/modelforms/ see https://docs.djangoproject.com/en/5.1/topics/forms/modelforms/
This is unlike any other form in troggle. It has methods (functions) for a start.
""" """
@@ -154,6 +163,7 @@ class SvxForm(forms.Form):
datetime = forms.DateTimeField(widget=forms.TextInput(attrs={"readonly": True})) datetime = forms.DateTimeField(widget=forms.TextInput(attrs={"readonly": True}))
outputtype = forms.CharField(widget=forms.TextInput(attrs={"readonly": True})) outputtype = forms.CharField(widget=forms.TextInput(attrs={"readonly": True}))
code = forms.CharField(widget=forms.Textarea(attrs={"cols": 140, "rows": 36})) code = forms.CharField(widget=forms.Textarea(attrs={"cols": 140, "rows": 36}))
identified_login = forms.BooleanField(required=False,widget=forms.CheckboxInput(attrs={"onclick":"return false"})) # makes it readonly
who_are_you = forms.CharField( who_are_you = forms.CharField(
widget=forms.TextInput( widget=forms.TextInput(
attrs={"size": 100, "placeholder": "You are editing this page, who are you ? e.g. 'Becka' or 'Animal <mta@gasthof.expo>'", attrs={"size": 100, "placeholder": "You are editing this page, who are you ? e.g. 'Becka' or 'Animal <mta@gasthof.expo>'",
@@ -238,6 +248,7 @@ class SvxForm(forms.Form):
return msg + "\nBUT PARSING failed. Do a completely new databaseReset." return msg + "\nBUT PARSING failed. Do a completely new databaseReset."
def Process(self): def Process(self):
# refactor this to use pathlib
print(">>>>....\n....Processing\n") print(">>>>....\n....Processing\n")
froox = os.fspath(SVXPATH / (self.data["filename"] + ".svx")) froox = os.fspath(SVXPATH / (self.data["filename"] + ".svx"))
froog = os.fspath(SVXPATH / (self.data["filename"] + ".log")) froog = os.fspath(SVXPATH / (self.data["filename"] + ".log"))
@@ -283,7 +294,7 @@ def svx(request, survex_file):
Requires CSRF to be set up correctly, and requires permission to write to the filesystem. Requires CSRF to be set up correctly, and requires permission to write to the filesystem.
Originally the non-existence of difflist was used as a marker to say that the file had been saved Originally the non-existence of difflist was used as a marker to say that the file had been saved
and that thuis there were no differences. This is inadequate, as a new file which has not been saved and that thus there were no differences. This is inadequate, as a new file which has not been saved
also has no difflist. also has no difflist.
Needs refactoring. Too many piecemeal edits and odd state dependencies. Needs refactoring. Too many piecemeal edits and odd state dependencies.
@@ -306,9 +317,11 @@ def svx(request, survex_file):
nowtime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") nowtime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
outputtype = "normal" outputtype = "normal"
editor = get_cookie(request) # editor = get_cookie(request)
identified_login = is_identified_user(request.user)
editor = get_editor(request)
form = SvxForm({"filename": survex_file, "dirname": dirname, "datetime": nowtime, "outputtype": outputtype, "who_are_you":editor}) form = SvxForm({"filename": survex_file, "dirname": dirname, "datetime": nowtime, "outputtype": outputtype, "identified_login": identified_login, "who_are_you":editor})
# if the form has been returned # if the form has been returned
difflist = [] difflist = []
@@ -408,6 +421,9 @@ def svx(request, survex_file):
events = events_on_dates(svxblocks) events = events_on_dates(svxblocks)
year = year_for_svx(svxblocks) year = year_for_svx(svxblocks)
form.data['who_are_you'] = editor form.data['who_are_you'] = editor
if identified_login:
# disable editing the git id string as we get it from the logged-on user data
form.fields["who_are_you"].widget.attrs["readonly"]="readonly"
vmap = { vmap = {
"year": year, "year": year,
"settings": settings, "settings": settings,
@@ -424,7 +440,6 @@ def svx(request, survex_file):
"filename": fn, "filename": fn,
#"dirparent": dirparent, #"dirparent": dirparent,
} }
if outputtype == "ajax": # used by CodeMirror ajax I think if outputtype == "ajax": # used by CodeMirror ajax I think
edit_response = render(request, "svxfiledifflistonly.html", vmap) edit_response = render(request, "svxfiledifflistonly.html", vmap)
else: else:

View File

@@ -54,6 +54,7 @@ $(document).ready(function()
<form id="codewikiform" action="" method="POST">{% csrf_token %} <form id="codewikiform" action="" method="POST">{% csrf_token %}
<div class="codeframebit">{{form.code}}</div> <div class="codeframebit">{{form.code}}</div>
<div>Identified login {{form.identified_login}}</div>
<div>Who are you? {{form.who_are_you}}</div> <div>Who are you? {{form.who_are_you}}</div>
<div style="display:none">{{form.filename}} {{form.dirname}} {{form.datetime}} {{form.outputtype}}</div> <div style="display:none">{{form.filename}} {{form.dirname}} {{form.datetime}} {{form.outputtype}}</div>
<input type="submit" name="diff" value="Differences between edited and saved versions of this file" /> <input type="submit" name="diff" value="Differences between edited and saved versions of this file" />