示例#1
0
    def change_view(self, request, object_id, extra_context=None):
        """
        The 'change' admin view for the Page model.
        """

        try:
            obj = self.model.objects.get(pk=object_id)
        except self.model.DoesNotExist:
            # Don't raise Http404 just yet, because we haven't checked
            # permissions yet. We don't want an unauthenticated user to be able
            # to determine whether a given object exists.
            obj = None
        else:
            template = get_template_from_request(request, obj)
            moderation_level, moderation_required = get_test_moderation_level(obj, request.user)
            
            # if there is a delete request for this page
            moderation_delete_request = (settings.CMS_MODERATOR and
                    obj.pagemoderatorstate_set.get_delete_actions(
                    ).count())

            language = get_language_from_request(request, obj)
            #activate(user_lang_set)
            extra_context = {
                'placeholders': get_placeholders(request, template),
                'language': language,
                'traduction_language': settings.CMS_LANGUAGES,
                'show_language_tabs': len(settings.CMS_LANGUAGES) > 1,
                'page': obj,
                'CMS_PERMISSION': settings.CMS_PERMISSION,
                'CMS_MODERATOR': settings.CMS_MODERATOR,
                'has_change_permissions_permission': obj.has_change_permissions_permission(request),
                'has_moderate_permission': obj.has_moderate_permission(request),
                
                'moderation_level': moderation_level,
                'moderation_required': moderation_required,
                'moderator_should_approve': moderator_should_approve(request, obj),
                
                'moderation_delete_request': moderation_delete_request,
            }
        tab_language = request.GET.get("language", None)
        response = super(PageAdmin, self).change_view(request, object_id, extra_context)
        
        if tab_language and response.status_code == 302 and response._headers['location'][1] == request.path :
            location = response._headers['location']
            response._headers['location'] = (location[0], "%s?language=%s" % (location[1], tab_language))
        return response
示例#2
0
    def change_view(self, request, object_id, extra_context=None):
        """
        The 'change' admin view for the Page model.
        """

        try:
            obj = self.model.objects.get(pk=object_id)
        except self.model.DoesNotExist:
            # Don't raise Http404 just yet, because we haven't checked
            # permissions yet. We don't want an unauthenticated user to be able
            # to determine whether a given object exists.
            obj = None
        else:
            template = get_template_from_request(request, obj)
            moderation_level, moderation_required = get_test_moderation_level(obj, request.user)

            # if there is a delete request for this page
            moderation_delete_request = (
                settings.CMS_MODERATOR and obj.pagemoderatorstate_set.get_delete_actions().count()
            )

            # activate(user_lang_set)
            extra_context = {
                "placeholders": get_placeholders(request, template),
                "page": obj,
                "CMS_PERMISSION": settings.CMS_PERMISSION,
                "CMS_MODERATOR": settings.CMS_MODERATOR,
                "has_change_permissions_permission": obj.has_change_permissions_permission(request),
                "has_moderate_permission": obj.has_moderate_permission(request),
                "moderation_level": moderation_level,
                "moderation_required": moderation_required,
                "moderator_should_approve": moderator_should_approve(request, obj),
                "moderation_delete_request": moderation_delete_request,
                "show_delete_translation": len(obj.get_languages()) > 1,
            }
            extra_context = self.update_language_tab_context(request, obj, extra_context)
        tab_language = request.GET.get("language", None)
        response = super(PageAdmin, self).change_view(request, object_id, extra_context)

        if tab_language and response.status_code == 302 and response._headers["location"][1] == request.path:
            location = response._headers["location"]
            response._headers["location"] = (location[0], "%s?language=%s" % (location[1], tab_language))
        return response
示例#3
0
    def change_view(self, request, object_id, extra_context=None):
        """
        The 'change' admin view for the Page model.
        """

        try:
            obj = self.model.objects.get(pk=object_id)
        except self.model.DoesNotExist:
            # Don't raise Http404 just yet, because we haven't checked
            # permissions yet. We don't want an unauthenticated user to be able
            # to determine whether a given object exists.
            obj = None
        else:
            template = get_template_from_request(request, obj)
            moderation_level, moderation_required = get_test_moderation_level(obj, request.user)
            
            # if there is a delete request for this page
            moderation_delete_request = (settings.CMS_MODERATOR and
                    obj.pagemoderatorstate_set.get_delete_actions(
                    ).count())

            user_lang_set = request.GET.get('language',
                                            django_settings.LANGUAGE_CODE)
            activate(user_lang_set)
            extra_context = {
                'placeholders': get_placeholders(request, template),
                'language': user_lang_set,
                'traduction_language': settings.CMS_LANGUAGES,
                'page': obj,
                'CMS_PERMISSION': settings.CMS_PERMISSION,
                'CMS_MODERATOR': settings.CMS_MODERATOR,
                'has_change_permissions_permission': obj.has_change_permissions_permission(request),
                'has_moderate_permission': obj.has_moderate_permission(request),
                
                'moderation_level': moderation_level,
                'moderation_required': moderation_required,
                'moderator_should_approve': moderator_should_approve(request, obj),
                
                'moderation_delete_request': moderation_delete_request,
            }
        
        return super(PageAdmin, self).change_view(request, object_id, extra_context)
示例#4
0
    def change_view(self, request, object_id, extra_context=None):
        """
        The 'change' admin view for the Page model.
        """

        try:
            obj = self.model.objects.get(pk=object_id)
        except self.model.DoesNotExist:
            # Don't raise Http404 just yet, because we haven't checked
            # permissions yet. We don't want an unauthenticated user to be able
            # to determine whether a given object exists.
            obj = None
        else:
            template = get_template_from_request(request, obj)
            moderation_level, moderation_required = get_test_moderation_level(
                obj, request.user)

            # if there is a delete request for this page
            moderation_delete_request = (
                settings.CMS_MODERATOR
                and obj.pagemoderatorstate_set.get_delete_actions().count())

            #activate(user_lang_set)
            extra_context = {
                'placeholders':
                get_placeholders(request, template),
                'page':
                obj,
                'CMS_PERMISSION':
                settings.CMS_PERMISSION,
                'CMS_MODERATOR':
                settings.CMS_MODERATOR,
                'ADMIN_MEDIA_URL':
                settings.ADMIN_MEDIA_PREFIX,
                'has_change_permissions_permission':
                obj.has_change_permissions_permission(request),
                'has_moderate_permission':
                obj.has_moderate_permission(request),
                'moderation_level':
                moderation_level,
                'moderation_required':
                moderation_required,
                'moderator_should_approve':
                moderator_should_approve(request, obj),
                'moderation_delete_request':
                moderation_delete_request,
                'show_delete_translation':
                len(obj.get_languages()) > 1
            }
            extra_context = self.update_language_tab_context(
                request, obj, extra_context)
        tab_language = request.GET.get("language", None)
        response = super(PageAdmin, self).change_view(request, object_id,
                                                      extra_context)

        if tab_language and response.status_code == 302 and response._headers[
                'location'][1] == request.path:
            location = response._headers['location']
            response._headers['location'] = (location[0], "%s?language=%s" %
                                             (location[1], tab_language))
        return response