Skip to content

Commit

Permalink
Merge pull request #1390 from firm1/hotfix-topicview
Browse files Browse the repository at this point in the history
corrige les erreurs dans les paramètres GET
  • Loading branch information
SpaceFox committed Aug 24, 2014
2 parents b03769c + f7dc548 commit 79a459b
Showing 1 changed file with 35 additions and 16 deletions.
51 changes: 35 additions & 16 deletions zds/forum/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,13 @@ def topic(request, topic_pk, topic_slug):
# The category list is needed to move threads

categories = Category.objects.all()
try:
page_nbr = int(request.GET["page"])
except KeyError:
if "page" in request.GET:
try:
page_nbr = int(request.GET["page"])
except:
# problem in variable format
raise Http404
else:
page_nbr = 1
try:
posts = paginator.page(page_nbr)
Expand Down Expand Up @@ -233,7 +237,8 @@ def new(request):

try:
forum_pk = request.GET["forum"]
except KeyError:
except:
# problem in variable format
raise Http404
forum = get_object_or_404(Forum, pk=forum_pk)
if not forum.can_read(request.user):
Expand Down Expand Up @@ -344,7 +349,8 @@ def move_topic(request):
raise PermissionDenied
try:
topic_pk = request.GET["sujet"]
except KeyError:
except:
# problem in variable format
raise Http404
forum = get_object_or_404(Forum, pk=request.POST["forum"])
if not forum.can_read(request.user):
Expand Down Expand Up @@ -374,12 +380,18 @@ def edit(request):

try:
topic_pk = request.POST["topic"]
except KeyError:
except:
# problem in variable format
raise Http404
try:
page = int(request.POST["page"])
except KeyError:
if "page" in request.POST:
try:
page = int(request.POST["page"])
except:
#problem in variable format
raise Http404
else:
page = 1

data = request.POST
resp = {}
g_topic = get_object_or_404(Topic, pk=topic_pk)
Expand Down Expand Up @@ -409,7 +421,8 @@ def edit(request):
if "move" in data:
try:
forum_pk = int(request.POST["move_target"])
except KeyError:
except:
# problem in variable format
raise Http404
forum = get_object_or_404(Forum, pk=forum_pk)
g_topic.forum = forum
Expand All @@ -432,7 +445,8 @@ def answer(request):

try:
topic_pk = request.GET["sujet"]
except KeyError:
except:
# problem in variable format
raise Http404

# Retrieve current topic.
Expand Down Expand Up @@ -589,7 +603,8 @@ def edit_post(request):

try:
post_pk = request.GET["message"]
except KeyError:
except:
# problem in variable format
raise Http404
post = get_object_or_404(Post, pk=post_pk)
if not post.topic.forum.can_read(request.user):
Expand Down Expand Up @@ -715,7 +730,8 @@ def useful_post(request):

try:
post_pk = request.GET["message"]
except KeyError:
except:
# problem in variable format
raise Http404
post = get_object_or_404(Post, pk=post_pk)

Expand All @@ -741,7 +757,8 @@ def unread_post(request):

try:
post_pk = request.GET["message"]
except KeyError:
except:
# problem in variable format
raise Http404
post = get_object_or_404(Post, pk=post_pk)

Expand Down Expand Up @@ -775,7 +792,8 @@ def like_post(request):

try:
post_pk = request.GET["message"]
except KeyError:
except:
# problem in variable format
raise Http404
resp = {}
post = get_object_or_404(Post, pk=post_pk)
Expand Down Expand Up @@ -822,7 +840,8 @@ def dislike_post(request):

try:
post_pk = request.GET["message"]
except KeyError:
except:
# problem in variable format
raise Http404
resp = {}
post = get_object_or_404(Post, pk=post_pk)
Expand Down

0 comments on commit 79a459b

Please sign in to comment.