Commit 17a540a1 authored by sebastien letort's avatar sebastien letort

the get method of Metrics view turned to get_context_data.

parent 86ad135f
Pipeline #71325 failed with stage
in 1 second
......@@ -1497,18 +1497,19 @@ class RunnerDelete(UserAccessMixin, DeleteView):
class Metrics(UserAccessMixin, TemplateView):
template_name = 'metrics.html'
def get(self, request ):
if request.user.is_superuser:
def get_context_data(self, **kwargs ):
if self.request.user.is_superuser:
apps = Webapp.objects.all()
else:
apps = Webapp.objects.filter(user=request.user)
params = {
'apps': apps.order_by('name'),
'show_form': 0 != len(apps),
}
log.info( "Site metrics. User = {}".format(str(request.user)) )
return render( request, self.template_name, params )
apps = Webapp.objects.filter(user=self.request.user)
# context is a dictionnary
context = super().get_context_data(**kwargs)
context['apps'] = apps.order_by('name')
context['show_form'] = 0 != len(apps)
log.info( "Site metrics. User = {}".format(str(self.request.user)) )
return context
@csrf_exempt
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment