forked from expo/troggle
Move exception handling to calling View
This commit is contained in:
@@ -45,19 +45,13 @@ def writetrogglefile(filepath, filecontent):
|
||||
filename = filepath.name
|
||||
git = settings.GIT
|
||||
|
||||
try:
|
||||
with open(filepath, "w") as f:
|
||||
os.chmod(filepath, 0o664) # set file permissions to rw-rw-r--
|
||||
f.write(filecontent)
|
||||
print(f'WRITING{cwd}---{filename} ')
|
||||
call([git, "add", filename], cwd=cwd)
|
||||
call([git, "commit", "-m", 'Online cave or entrance edit'], cwd=cwd)
|
||||
except PermissionError:
|
||||
message = f'CANNOT save this file.\nPERMISSIONS incorrectly set on server for this file {filename}. Ask a nerd to fix this.'
|
||||
return render(request,'errors/generic.html', {'message': message})
|
||||
except:
|
||||
message = f'CANNOT git on server for this file {filename}. Edits not saved.\nAsk a nerd to fix this.'
|
||||
return render(request,'errors/generic.html', {'message': message})
|
||||
# do not trap exceptions, pass them up to the view that called this function
|
||||
with open(filepath, "w") as f:
|
||||
os.chmod(filepath, 0o664) # set file permissions to rw-rw-r--
|
||||
f.write(filecontent)
|
||||
print(f'WRITING{cwd}---{filename} ')
|
||||
call([git, "add", filename], cwd=cwd)
|
||||
call([git, "commit", "-m", 'Online cave or entrance edit'], cwd=cwd)
|
||||
|
||||
|
||||
class Area(TroggleModel):
|
||||
|
||||
Reference in New Issue
Block a user