|
@@ -27,6 +27,9 @@ class VPNView(SuccessMessageMixin, UpdateView):
|
|
return super(VPNView, self).dispatch(*args, **kwargs)
|
|
return super(VPNView, self).dispatch(*args, **kwargs)
|
|
|
|
|
|
def get_object(self):
|
|
def get_object(self):
|
|
|
|
+ if self.request.user.is_superuser:
|
|
|
|
+ return get_object_or_404(VPNConfiguration, pk=self.kwargs.get("id"))
|
|
|
|
+ # For normal users, ensure the VPN belongs to them.
|
|
return get_object_or_404(VPNConfiguration, pk=self.kwargs.get("id"),
|
|
return get_object_or_404(VPNConfiguration, pk=self.kwargs.get("id"),
|
|
offersubscription__member=self.request.user)
|
|
offersubscription__member=self.request.user)
|
|
|
|
|
|
@@ -66,8 +69,12 @@ class VPNGeneratePasswordView(VPNView):
|
|
def get_graph(request, vpn_id, period="daily"):
|
|
def get_graph(request, vpn_id, period="daily"):
|
|
""" This get the graph for the associated vpn_id and time period
|
|
""" This get the graph for the associated vpn_id and time period
|
|
"""
|
|
"""
|
|
- vpn = get_object_or_404(VPNConfiguration, pk=vpn_id,
|
|
|
|
- offersubscription__member=request.user)
|
|
|
|
|
|
+ if request.user.is_superuser:
|
|
|
|
+ vpn = get_object_or_404(VPNConfiguration, pk=vpn_id)
|
|
|
|
+ else:
|
|
|
|
+ # For normal users, ensure the VPN belongs to them
|
|
|
|
+ vpn = get_object_or_404(VPNConfiguration, pk=vpn_id,
|
|
|
|
+ offersubscription__member=request.user)
|
|
|
|
|
|
time_periods = { 'hourly': '-1hour', 'daily': '-24hours', 'weekly': '-8days', 'monthly': '-32days', 'yearly': '-13months', }
|
|
time_periods = { 'hourly': '-1hour', 'daily': '-24hours', 'weekly': '-8days', 'monthly': '-32days', 'yearly': '-13months', }
|
|
if period not in time_periods:
|
|
if period not in time_periods:
|