Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ZEP-13]Corrige quelques erreurs 500 #4160

Merged
merged 2 commits into from
Apr 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion zds/tutorialv2/views/views_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,7 @@ class AddAuthorToContent(LoggedWithReadWriteHability, SingleContentFormViewMixin
authorized_for_staff = True
already_finished = False

def get(self):
def get(self, request, *args, **kwargs):
content = self.get_object()
url = 'content:find-{}'.format('tutorial' if content.is_tutorial() else content.type.lower())
return redirect(url, self.request.user)
Expand Down
15 changes: 10 additions & 5 deletions zds/tutorialv2/views/views_published.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.core.exceptions import PermissionDenied
from django.db import transaction
from django.http import Http404, HttpResponsePermanentRedirect, StreamingHttpResponse, HttpResponse
from django.db.models import F
from django.db.models import F, Q
from django.shortcuts import get_object_or_404, redirect, render_to_response
from django.template.loader import render_to_string
from django.utils.datastructures import MultiValueDictKeyError
Expand Down Expand Up @@ -331,13 +331,17 @@ def get_queryset(self):
'tutorialv2_publishablecontent.id'
)
queryset = PublishedContent.objects \
.filter(must_redirect=False) \

.filter(must_redirect=False)
# this condition got more complexe with development of zep13
# if we do filter by content_type, then every published content can be
# displayed. Othewise, we have to be sure the content was expressly chosen by
# someone with staff authorization. Another way to say it "it has to be a
# validated content (article, tutorial), `ContentWithoutValidation` live their
# own life in their own page.
if self.current_content_type:
queryset = queryset.filter(content_type=self.current_content_type)
else:
queryset = queryset.filter(content__sha_picked=F('sha_public'))

queryset = queryset.filter(~Q(content_type="OPINION"))
# prefetch:
queryset = queryset\
.prefetch_related('content') \
Expand Down Expand Up @@ -761,6 +765,7 @@ def post(self, request, *args, **kwargs):


class FollowContentReaction(LoggedWithReadWriteHability, SingleOnlineContentViewMixin, FormView):
redirection_is_needed = False

def post(self, request, *args, **kwargs):
response = {}
Expand Down
6 changes: 4 additions & 2 deletions zds/tutorialv2/views/views_validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ class UnpublishOpinion(LoginRequiredMixin, SingleOnlineContentFormViewMixin, NoV
"""Unpublish an opinion"""

form_class = RevokeValidationForm
is_public = True

modal_form = True

Expand Down Expand Up @@ -640,7 +641,7 @@ def form_valid(self, form):


class PickOpinion(PermissionRequiredMixin, NoValidationBeforeFormViewMixin):
"""Add the opinion in the picked list """
"""Approve and Add the opinion in the picked list """

form_class = PickOpinionForm

Expand Down Expand Up @@ -747,7 +748,8 @@ def form_valid(self, form):


class PromoteOpinionToArticle(PermissionRequiredMixin, NoValidationBeforeFormViewMixin):
"""Promote an opinion to article"""
"""Promote an opinion to article. this duplicates the opinion and declares
the clone as an article."""

form_class = PromoteOpinionToArticleForm

Expand Down