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:
@@ -17,9 +17,16 @@ from troggle.core.models.caves import Cave, GetCaveLookup
|
||||
from troggle.core.models.logbooks import LogbookEntry
|
||||
from troggle.core.models.survex import SurvexBlock, SurvexFile #, SurvexDirectory
|
||||
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
|
||||
|
||||
|
||||
"""Everything that views survexfiles
|
||||
but also displays data on a cave or caves when there is ambiguity
|
||||
"""
|
||||
@@ -147,6 +154,8 @@ class SvxForm(forms.Form):
|
||||
This is not a ModelForm.
|
||||
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.
|
||||
|
||||
"""
|
||||
|
||||
dirname = forms.CharField(widget=forms.TextInput(attrs={"readonly": True}))
|
||||
@@ -154,6 +163,7 @@ class SvxForm(forms.Form):
|
||||
datetime = forms.DateTimeField(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}))
|
||||
identified_login = forms.BooleanField(required=False,widget=forms.CheckboxInput(attrs={"onclick":"return false"})) # makes it readonly
|
||||
who_are_you = forms.CharField(
|
||||
widget=forms.TextInput(
|
||||
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."
|
||||
|
||||
def Process(self):
|
||||
# refactor this to use pathlib
|
||||
print(">>>>....\n....Processing\n")
|
||||
froox = os.fspath(SVXPATH / (self.data["filename"] + ".svx"))
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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")
|
||||
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
|
||||
difflist = []
|
||||
@@ -408,6 +421,9 @@ def svx(request, survex_file):
|
||||
events = events_on_dates(svxblocks)
|
||||
year = year_for_svx(svxblocks)
|
||||
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 = {
|
||||
"year": year,
|
||||
"settings": settings,
|
||||
@@ -424,7 +440,6 @@ def svx(request, survex_file):
|
||||
"filename": fn,
|
||||
#"dirparent": dirparent,
|
||||
}
|
||||
|
||||
if outputtype == "ajax": # used by CodeMirror ajax I think
|
||||
edit_response = render(request, "svxfiledifflistonly.html", vmap)
|
||||
else:
|
||||
|
||||
@@ -54,6 +54,7 @@ $(document).ready(function()
|
||||
|
||||
<form id="codewikiform" action="" method="POST">{% csrf_token %}
|
||||
<div class="codeframebit">{{form.code}}</div>
|
||||
<div>Identified login {{form.identified_login}}</div>
|
||||
<div>Who are you? {{form.who_are_you}}</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" />
|
||||
|
||||
Reference in New Issue
Block a user