def unpublish(self, request, article_id, language):
        """
        Publish or unpublish a language of a article
        """
        article = get_object_or_404(self.model, pk=article_id)
        if not article.has_publish_permission(request):
            return HttpResponseForbidden(force_text(_('You do not have permission to unpublish this article')))
        if not article.publisher_public_id:
            return HttpResponseForbidden(force_text(_('This article was never published')))
        try:
            article.unpublish(language)
            message = _('The %(language)s article "%(article)s" was successfully unpublished') % {
                'language': get_language_object(language)['name'], 'article': article}
            messages.info(request, message)
            LogEntry.objects.log_action(
                user_id=request.user.id,
                content_type_id=ContentType.objects.get_for_model(Article).pk,
                object_id=article_id,
                object_repr=article.get_title(),
                action_flag=CHANGE,
                change_message=message,
            )
        except RuntimeError:
            exc = sys.exc_info()[1]
            messages.error(request, exc.message)
        except ValidationError:
            exc = sys.exc_info()[1]
            messages.error(request, exc.message)
        path = admin_reverse('cms_articles_article_changelist')
        if request.GET.get('redirect_language'):
            path = '%s?language=%s&article_id=%s' % (
                path,
                request.GET.get('redirect_language'),
                request.GET.get('redirect_article_id')
            )
        return HttpResponseRedirect(path)
def unpublish ( self , request , article_id , language ) : article = get_object_or_404 ( self . model , pk = article_id ) if not article . has_publish_permission ( request ) : return HttpResponseForbidden ( force_text ( _ ( 'You do not have permission to unpublish this article' ) ) ) if not article . publisher_public_id : return HttpResponseForbidden ( force_text ( _ ( 'This article was never published' ) ) ) try : article . unpublish ( language ) message = _ ( 'The %(language)s article "%(article)s" was successfully unpublished' ) % { 'language' : get_language_object ( language ) [ 'name' ] , 'article' : article } messages . info ( request , message ) LogEntry . objects . log_action ( user_id = request . user . id , content_type_id = ContentType . objects . get_for_model ( Article ) . pk , object_id = article_id , object_repr = article . get_title ( ) , action_flag = CHANGE , change_message = message , ) except RuntimeError : exc = sys . exc_info ( ) [ 1 ] messages . error ( request , exc . message ) except ValidationError : exc = sys . exc_info ( ) [ 1 ] messages . error ( request , exc . message ) path = admin_reverse ( 'cms_articles_article_changelist' ) if request . GET . get ( 'redirect_language' ) : path = '%s?language=%s&article_id=%s' % ( path , request . GET . get ( 'redirect_language' ) , request . GET . get ( 'redirect_article_id' ) ) return HttpResponseRedirect ( path )
Publish or unpublish a language of a article