diff options
author | Philip Sargent <philip.sargent@klebos.com> | 2022-03-05 17:05:15 +0000 |
---|---|---|
committer | Philip Sargent <philip.sargent@klebos.com> | 2022-03-05 17:05:15 +0000 |
commit | d7fd6b00ae6845e5dfb7263a4f440e7ab36c145c (patch) | |
tree | 94e9bd59d2c6849cb2952b005fb73fa4bb80808c /core/views/expo.py | |
parent | 32377f4e6cc4f3e7ef365497f24e560c80f4ca7a (diff) | |
download | troggle-d7fd6b00ae6845e5dfb7263a4f440e7ab36c145c.tar.gz troggle-d7fd6b00ae6845e5dfb7263a4f440e7ab36c145c.tar.bz2 troggle-d7fd6b00ae6845e5dfb7263a4f440e7ab36c145c.zip |
Detect unwriteable file permissions earlier
Diffstat (limited to 'core/views/expo.py')
-rw-r--r-- | core/views/expo.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/views/expo.py b/core/views/expo.py index 3a89269..c6ef01b 100644 --- a/core/views/expo.py +++ b/core/views/expo.py @@ -142,7 +142,7 @@ def expowebpage(request, expowebpath, path): if m: editable = False else: - editable = True + editable = os.access(Path(expowebpath / path), os.W_OK) # are file permissions writeable? has_menu = False menumatch = re.match(r'(.*)<div id="menu">', body, re.DOTALL + re.IGNORECASE) @@ -253,7 +253,7 @@ def getmimetype(path): @ensure_csrf_cookie def editexpopage(request, path): '''Manages the 'Edit this Page' capability for expo handbook and other html pages. - Relies on javascript to provide the in-browser editing environment. + Relies on HTML5 or javascript to provide the in-browser editing environment. ''' try: # if a cave not a webpage at all. @@ -310,7 +310,8 @@ def editexpopage(request, path): cwd = filepath.parent filename = filepath.name git = settings.GIT - # see also core/models/cave.py writetrogglefile() + # GIT see also core/models/cave.py writetrogglefile() + # GIT see also core/views/uploads.py dwgupload() try: with open(filepath, "w") as f: print(f'WRITING{cwd}---{filename} ') @@ -328,11 +329,11 @@ def editexpopage(request, path): message = f'CANNOT git on server for this file {filename}. Edits saved but not added to git.\n\n' + msgdata return render(request,'errors/generic.html', {'message': message}) - cp_commit = subprocess.run([git, "commit", "-m", 'Edit this page'], cwd=cwd, capture_output=True, text=True) - # This produces return code = 1 if it commits OK, but if the repo still needs to be pushed to origin/expoweb + cp_commit = subprocess.run([git, "commit", "-m", f'Troggle online: Edit this page - {filename}'], cwd=cwd, capture_output=True, text=True) + # This produces return code = 1 if it commits OK, but when the repo still needs to be pushed to origin/expoweb if cp_commit.returncode != 0 and cp_commit.stdout != 'nothing to commit, working tree clean': msgdata = 'Ask a nerd to fix this.\n\n' + cp_commit.stderr + '\n\n' + cp_commit.stdout + '\n\nreturn code: ' + str(cp_commit.returncode) - message = f'Eror code with git on server for this file {filename}. Edits saved, added to git but NOT committed.\n\n' + msgdata + message = f'Error code with git on server for this file {filename}. Edits saved, added to git, but NOT committed.\n\n' + msgdata return render(request,'errors/generic.html', {'message': message}) except subprocess.SubprocessError: |