Add HostingContextMixin that sets the REDIRECT_TO_CMS and

MULTISITE_CMS_FALLBACK urls
This commit is contained in:
PCoder 2018-04-07 12:51:40 +02:00
parent ffe4eb4123
commit 399c91d636
1 changed files with 17 additions and 0 deletions

View File

@ -1,4 +1,7 @@
from cms.models.pagemodel import Page
from django.shortcuts import redirect
from django.conf import settings
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from opennebula_api.serializers import VirtualMachineTemplateSerializer
@ -24,3 +27,17 @@ class ProcessVMSelectionMixin(object):
request.session['next'] = reverse('hosting:payment')
return redirect(reverse('hosting:login'))
return redirect(reverse('hosting:payment'))
class HostingContextMixin(object):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['REDIRECT_TO_CMS'] = (Page
.objects
.filter(site_id=Site
.objects
.get_current()
.id)
.count())
context['MULTISITE_CMS_FALLBACK'] = settings.MULTISITE_CMS_FALLBACK
return context