]> git.openstreetmap.org Git - osqa.git/commitdiff
Converts the temp login email to the new style, and makes some more enahncements...
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 4 Jun 2010 15:22:27 +0000 (15:22 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Fri, 4 Jun 2010 15:22:27 +0000 (15:22 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@376 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/settings/base.py
forum/skins/default/templates/auth/temp_login_email.html
forum/views/auth.py
forum/views/meta.py
forum_modules/localauth/views.py

index 75687be8b7f662125a45f11f6d601c97da2fdde8..cdc80b0214d08a711b74988f69add029c3506669 100644 (file)
@@ -1,6 +1,7 @@
 import django.dispatch
 from django.utils.encoding import force_unicode
 from datetime import datetime, timedelta
+import logging
 
 TMP_MINICACHE_SECONDS = 5
 
@@ -54,22 +55,28 @@ class BaseSetting(object):
             v = kv.value
             self._temp = (v, datetime.now() + timedelta(seconds=TMP_MINICACHE_SECONDS))
             return v
+        except KeyValue.DoesNotExist:
+            self._temp = (self.default, datetime.now() + timedelta(seconds=TMP_MINICACHE_SECONDS))
         except Exception, e:
-                return self.default
+            logging.error("Error retrieving setting from database (%s): %s" % (self.name, str(e)))
+            
+        return self.default
 
     def set_value(self, new_value):
         new_value = self._parse(new_value)
+        self._temp = None
         self.save(new_value)
 
     def save(self, value):
-        self._temp = None
-        
         from forum.models import KeyValue
 
         try:
             kv = KeyValue.objects.get(key=self.name)
-        except:
+        except KeyValue.DoesNotExist:
             kv = KeyValue(key=self.name)
+        except Exception, e:
+            logging.error("Error savin setting to database (%s): %s" % (self.name, str(e)))
+            return
 
         kv.value = value
         kv.save()
index 8a23f65c4af96a31a762a5bba5f166c27d72f5cb..797221378c8183f289c80c5e2c799d20e5d0ec88 100644 (file)
@@ -1,21 +1,31 @@
-{% extends "email_base.html" %}
-{% load i18n %}
-{% load extra_tags %}
-{% load email_tags %}
+{% load i18n extra_tags email_tags %}
 
-{% block content %}
-    <p>{% trans "Greetings from the Q&A forum" %},</p>
+{% declare %}
+    prefix = settings.EMAIL_SUBJECT_PREFIX
+    app_name = settings.APP_SHORT_NAME
 
-    <p>{% trans "You're seeing this because someone requested a temporary login link" %}</p>
+    exclude_finetune = True
+{% enddeclare %}
 
-    <a href="{% fullurl auth_tempsignin user=user.id,code=temp_login_code %}">{% fullurl auth_tempsignin user=user.id,code=temp_login_code %}</a>
+{% email %}
+    {% subject %}{% blocktrans %}{{ prefix }} Temporary login link{% endblocktrans %}{% endsubject %}
 
-    <p>{% trans "Following the link above will give you access to your account." %}</p>
+    {% htmlcontent notifications/base.html %}
+        <p style="{{ p_style }}">
+            {% blocktrans %}The following link grants you a one time access to your account at {{ app_name }}.{% endblocktrans %}
+        </p>
+        <a  style="{{ a_style }}}" href="{% fullurl auth_tempsignin user=recipient.id,code=temp_login_code %}">{% trans "Go to your account" %}</a>
 
-    <p>{% blocktrans %}If you beleive that this message was sent in mistake -
-    no further action is needed. Just ingore this email, we apologize
-    for any inconvenience{% endblocktrans %}</p>
+        <p style="{{ p_style }}}">{% trans "If the above link is not clickable, copy and paste this url into your web browser's address bar:" %}</p>
+
+        <p style="{{ p_style }}">{% fullurl auth_tempsignin user=recipient.id,code=temp_login_code %}</p>
+    {% endhtmlcontent %}
+
+{% textcontent notifications/base_text.html %}
+{% blocktrans %}The following url grants you a one time access to your account at {{ app_name }}.{% endblocktrans %}
+
+{% fullurl auth_tempsignin user=recipient.id,code=temp_login_code %}
+{% endtextcontent %}
+
+{% endemail %}
 
-    <p>{% blocktrans %}Sincerely,<br />
-    Forum Administrator{% endblocktrans %}</p>
-{% endblock %}
index 442bf01fdb2ddeac30d4cab43dddd31965be357f..7a433499e6e6b5b8c8d3ac5a935adb40ebb4aa8b 100644 (file)
@@ -215,10 +215,7 @@ def request_temp_login(request):
             except:
                 hash = ValidationHash.objects.create_new(user, 'templogin', [user.id])
 
-            send_email(_("Temporary login link"), [(user.username, user.email)], "auth/temp_login_email.html", {
-                'temp_login_code': hash,
-                'user': user
-            })
+            send_template_email([user], "auth/temp_login_email.html", {'temp_login_code': hash})
 
             request.user.message_set.create(message=_("An email has been sent with your temporary login key"))
 
index c0da3a25e39c94defb93c065f87b4f61ea0fbd8a..b4cb75affa147a78a03a66b9f42b92bd7cd6bde6 100644 (file)
@@ -28,9 +28,6 @@ def media(request, skin, path):
                  document_root=os.path.join(os.path.dirname(os.path.dirname(__file__)),'skins').replace('\\','/'))
 
 def markdown_help(request):
-    # md = markdown.Markdown([SettingsExtension({})])
-    # text = md.convert(settings.FAQ_PAGE_TEXT.value)
-
     return render_to_response('markdown_help.html', context_instance=RequestContext(request))
 
 
index 6416feea555affde9901ebddad2dce921ab7ff31..4392c5a939837cf078c4335dfef0333a60fb4a3e 100644 (file)
@@ -23,6 +23,7 @@ def register(request):
 
             if User.objects.all().count() == 0:
                 user_.is_superuser = True
+                user_.is_staff = True
 
             user_.save()
             UserJoinsAction(user=user_, ip=request.META['REMOTE_ADDR']).save()