Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates #63

Merged
merged 20 commits into from
Jun 29, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
display message error on view list
on view not found (permission)
and multiple views (duplicate link_title views)
clavay committed Jun 27, 2023
commit d4d71747ede982cdec86caea92a4eac2bc395fb6
10 changes: 8 additions & 2 deletions pyscada/hmi/views.py
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
from django.contrib.auth import logout
from django.views.decorators.csrf import requires_csrf_token
from django.conf import settings
from django.core.exceptions import PermissionDenied

import time
import json
@@ -76,8 +77,13 @@ def view(request, link_title):
if v is None:
raise View.DoesNotExist
#v = View.objects.get(link_title=link_title)
except (View.DoesNotExist, View.MultipleObjectsReturned):
return HttpResponse(status=404)
except View.DoesNotExist as e:
logger.warning(f"{request.user} has no permission for view {link_title}")
raise PermissionDenied("You don't have access to this view.")
except View.MultipleObjectsReturned as e:
logger.error(f"{e} for view link_title", exc_info=True)
raise PermissionDenied(f"Multiples views with this link : {link_title}")
#return HttpResponse(status=404)

if v.theme is not None:
base_template = str(v.theme.base_filename) + ".html"