def login(request): redirect_to = request.GET.get(REDIRECT_FIELD_NAME) if not is_safe_url(url=redirect_to, host=request.get_host()): redirect_to = reverse("pages-root") if request.user.is_authenticated(): return HttpResponseRedirect(redirect_to) form = CMSToolbarLoginForm(request=request, data=request.POST) if form.is_valid(): auth_login(request, form.user_cache) else: redirect_to += u'?cms_toolbar_login_error=1' return HttpResponseRedirect(redirect_to)
def get_render_context(self): if self.structure_mode_active and not self.uses_legacy_structure_mode: # User has explicitly requested structure mode # and the object (page, blog, etc..) allows for the non-legacy structure mode renderer = self.structure_renderer else: renderer = self.get_content_renderer() context = { 'cms_toolbar': self, 'cms_renderer': renderer, 'cms_edit_on': self.edit_mode_url_on, 'cms_edit_off': self.edit_mode_url_off, 'cms_structure_on': self.structure_mode_url_on, 'cms_version': __version__, 'django_version': DJANGO_VERSION, 'login_form': CMSToolbarLoginForm(), 'python_version': PYTHON_VERSION, } return context