Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix incompatibility with django 1.4 #6

Merged
merged 2 commits into from

2 participants

@almalki

User.message_set is removed in Django 1.4 which result in exception:
'User' object has no attribute ''message_set"

The messages framework should be used instead.

Abdulaziz Al... added some commits
Abdulaziz Al-Malki fix incompatiblity with django 1.4
User.message_set is removed in Django 1.4 which result in exception:
'User' object has no attribute ''message_set"

The messages framework should be used instead.
6f7d4d4
Abdulaziz AlMalki redirect to template after flag if no next specified 83bdc4e
@paltman paltman merged commit c1c9617 into pinax:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 3, 2012
  1. fix incompatiblity with django 1.4

    Abdulaziz Al-Malki authored
    User.message_set is removed in Django 1.4 which result in exception:
    'User' object has no attribute ''message_set"
    
    The messages framework should be used instead.
Commits on Dec 16, 2012
  1. redirect to template after flag if no next specified

    Abdulaziz AlMalki authored
This page is out of date. Refresh to see the latest.
View
10 flag/templates/flag/thank_you.html
@@ -0,0 +1,10 @@
+{% load i18n %}
+
+<h3>{% trans 'Thank you' %}</h3>
+{% if messages %}
+<div class="messages">
+ {% for message in messages %}
+ <p class=" alert alert-{% if message.tags %}{{ message.tags }}{% endif %}">{{ message }}</p>
+ {% endfor %}
+</div>
+{% endif %}
View
2  flag/urls.py
@@ -1,6 +1,8 @@
from django.conf.urls.defaults import *
+from django.views.generic import TemplateView
urlpatterns = patterns("",
url(r"^$", "flag.views.flag", name="flag"),
+ url(r'^thank_you', TemplateView.as_view(template_name="flag/thank_you.html"), name='flag-reported'),
)
View
9 flag/views.py
@@ -1,9 +1,11 @@
+from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, Http404
from django.shortcuts import get_object_or_404
from django.contrib.auth.decorators import login_required
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext as _
+from django.contrib import messages
from flag.models import add_flag
@@ -28,12 +30,9 @@ def flag(request):
creator = None
add_flag(request.user, content_type, object_id, creator, comment)
- request.user.message_set.create(
- message = _("You have added a flag. A moderator will review your "
- "submission shortly.")
- )
+ messages.success(request, _("You have added a flag. A moderator will review your submission shortly."), fail_silently=True)
if next:
return HttpResponseRedirect(next)
else:
- return Http404
+ return HttpResponseRedirect(reverse('flag-reported'))
Something went wrong with that request. Please try again.