]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/middleware/anon_user.py
Jira OSQA-692, .php and .jsp have nothing to domain name extensions list. You can...
[osqa.git] / forum / middleware / anon_user.py
index 866734dae47127802c82396fb62bcf036842f730..25f192a00f94f83adaeec97d785352e943e60038 100644 (file)
@@ -1,8 +1,8 @@
-from django.http import HttpResponseRedirect
-from forum.utils.forms import get_next_url
+from django.http import HttpResponseRedirect, HttpResponse
+from forum.forms import get_next_url
 from django.utils.translation import ugettext as _
 from forum.user_messages import create_message, get_and_delete_messages
 from django.utils.translation import ugettext as _
 from forum.user_messages import create_message, get_and_delete_messages
-from django.conf import settings
+from forum import settings
 from django.core.urlresolvers import reverse
 import logging
 
 from django.core.urlresolvers import reverse
 import logging
 
@@ -31,5 +31,13 @@ class ConnectToSessionMessagesMiddleware(object):
             #also set the first greeting one time per session only
             if 'greeting_set' not in request.session:
                 request.session['greeting_set'] = True
             #also set the first greeting one time per session only
             if 'greeting_set' not in request.session:
                 request.session['greeting_set'] = True
+
                 msg = _('First time here? Check out the <a href="%s">FAQ</a>!') % reverse('faq')
                 msg = _('First time here? Check out the <a href="%s">FAQ</a>!') % reverse('faq')
-                request.user.message_set.create(message=msg)
+
+                # If the store greeting in cookie setting is activated make sure that the greeting_set cookies isn't set
+                if (settings.STORE_GREETING_IN_COOKIE and not request.COOKIES.has_key('greeting_set')) or \
+                  not settings.STORE_GREETING_IN_COOKIE:
+                    request.user.message_set.create(message=msg)
+
+                if settings.STORE_GREETING_IN_COOKIE:
+                    request.COOKIES.set(key='greeting_set', value=True)