diff options
Diffstat (limited to 'core/views')
-rw-r--r-- | core/views/survex.py | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/core/views/survex.py b/core/views/survex.py index ea8f430..72d44f1 100644 --- a/core/views/survex.py +++ b/core/views/survex.py @@ -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 """ @@ -146,6 +153,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. """ @@ -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: |