Commit 876c5bf8 by Csók Tamás

views.py: ClientCheck class that handles the Connect button information stage (with or without js)

parent f8366ce7
...@@ -346,6 +346,9 @@ class VmDetailView(CheckedDetailView): ...@@ -346,6 +346,9 @@ class VmDetailView(CheckedDetailView):
context['can_change_resources'] = self.request.user.has_perm( context['can_change_resources'] = self.request.user.has_perm(
"vm.change_resources") "vm.change_resources")
# client info
context['client_download'] = self.request.COOKIES.get('downloaded_client')
return context return context
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
...@@ -1323,6 +1326,30 @@ class GroupAclUpdateView(AclUpdateView): ...@@ -1323,6 +1326,30 @@ class GroupAclUpdateView(AclUpdateView):
return super(GroupAclUpdateView, self).get_object().profile return super(GroupAclUpdateView, self).get_object().profile
class ClientCheck(LoginRequiredMixin, TemplateView):
def get_template_names(self):
if self.request.is_ajax():
return ['dashboard/_modal.html']
else:
return ['dashboard/nojs-wrapper.html']
def get_context_data(self, *args, **kwargs):
context = super(ClientCheck, self).get_context_data(*args, **kwargs)
context.update({
'box_title': _('About CIRCLE Client'),
'ajax_title': False,
'template': "dashboard/_client-check.html",
'instance': get_object_or_404(Instance, pk=self.request.GET.get('vm')),
})
return context
def post(self, request, *args, **kwargs):
instance = get_object_or_404(Instance, pk=request.POST.get('vm'))
response = HttpResponseRedirect(reverse('dashboard.views.detail', args=[instance.pk]))
response.set_cookie('downloaded_client', 'True', 365 * 24 * 60 * 60)
return response
class TemplateChoose(LoginRequiredMixin, TemplateView): class TemplateChoose(LoginRequiredMixin, TemplateView):
def get_template_names(self): def get_template_names(self):
......
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 sign in to comment