]> git.openstreetmap.org Git - osqa.git/commitdiff
fixed feedback page
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sat, 17 Apr 2010 21:53:07 +0000 (21:53 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sat, 17 Apr 2010 21:53:07 +0000 (21:53 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@49 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/migrations/0012_set_active_revision.py
forum/migrations/0014_auto__add_field_question_accepted_answer.py
forum/settings/email.py
forum/skins/default/templates/feedback_email.txt [deleted file]
forum/skins/default/templates/notifications/feedback.html [new file with mode: 0644]
forum/views/meta.py
forum/views/users.py

index 29e9030e2b6f2dd94e482b449f12b303db68c524..24c419a7d0ee1beed5072f4c0a6ba9eb21110523 100644 (file)
@@ -8,8 +8,15 @@ class Migration(DataMigration):
     \r
     def forwards(self, orm):\r
         for n in orm.Node.objects.all():\r
-            n.active_revision = n.revisions.order_by('-id')[0]\r
-            n.save()\r
+            try:\r
+                n.active_revision = n.revisions.order_by('-id')[0]\r
+                n.save()\r
+            except:\r
+                r = orm.NodeRevision(author=n.author, body=n.body, title=n.title, revised_at=datetime.datetime.now(),\r
+                                 tagnames=n.tagnames, summary='Initial Revision', revision=1, node=n)\r
+                r.save()\r
+                n.active_revision = r\r
+                n.save()\r
     \r
     \r
     def backwards(self, orm):\r
index 799e13ab9dc56178ca2ccf1657fef3b6033f4229..54ef07805390b58352c8a7294a4f3e620e1fa2c8 100644 (file)
@@ -13,8 +13,9 @@ class Migration(SchemaMigration):
         db.add_column(u'question', 'accepted_answer', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['forum.Answer'], unique=True, null=True), keep_default=False)\r
 \r
         if db.backend_name == "postgres" and not "pgfulltext" in settings.DISABLED_MODULES:\r
+            pass\r
             db.execute("DROP TRIGGER tsvectorupdate ON question;")\r
-            db.execute("ALTER TABLE question DROP COLUMN tsv;")    \r
+            db.execute("ALTER TABLE question DROP COLUMN tsv;")\r
     \r
     def backwards(self, orm):\r
         \r
index 43baeb5a4d97481bc1ca61a9c28fc2ed849977ab..71c2e69ca18e37a591d5514d4aaa9c1084937f50 100644 (file)
@@ -39,7 +39,7 @@ Does your SMTP server uses TLS for authentication.
 required=False))\r
 \r
 DEFAULT_FROM_EMAIL = Setting('DEFAULT_FROM_EMAIL', '', EMAIL_SET, dict(\r
-label = _("Site email address"),\r
+label = _("Site 'from' email address"),\r
 help_text = _("""\r
 The address that will show up on the 'from' field on emails sent by your website.\r
 """),\r
@@ -50,4 +50,4 @@ label = _("Email subject prefix"),
 help_text = _("""\r
 Every email sent through your website will have the subject prefixed by this string. It's usually a good idea to have such a prefix so your users can easilly set up a filter on theyr email clients.\r
 """),\r
-required=False))
\ No newline at end of file
+required=False))\r
diff --git a/forum/skins/default/templates/feedback_email.txt b/forum/skins/default/templates/feedback_email.txt
deleted file mode 100644 (file)
index df76818..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-{% load i18n %}
-{% spaceless %}
-{% blocktrans with settings.APP_TITLE|safe as site_title %}
-Hello, this is a {{site_title}} forum feedback message
-{% endblocktrans %}
-{% endspaceless %}
-
-{% spaceless %}
-{% trans "Sender is" %}
-{% if user.is_authenticated %}
-    {{user.username|safe}} {% trans "email" %}:{{user.email|safe}} 
-{% else %}
-    {% if name %}{{name|safe}}{% else %}{% trans "anonymous" %}{% endif %}
-    {% if email %}{% trans "email" %}:{{email|safe}}{% endif %}
-{% endif %}
-    ip:{{request.META.REMOTE_ADDR}}
-{% endspaceless %}
-
-{% trans "Message body:" %} {{message|safe}}
diff --git a/forum/skins/default/templates/notifications/feedback.html b/forum/skins/default/templates/notifications/feedback.html
new file mode 100644 (file)
index 0000000..06b8b84
--- /dev/null
@@ -0,0 +1,28 @@
+{% extends "email_base.html" %}
+{% load i18n %}
+{% load extra_tags %}
+
+{% block content %}
+    <p>{% spaceless %}
+    {% blocktrans with settings.APP_SHORT_NAME as site_title %}
+    Hello, this is a {{site_title}} forum feedback message
+    {% endblocktrans %}
+    {% endspaceless %}</p>
+
+    <p>
+        {% trans "Sender" %}:
+        {% if user.is_authenticated %}
+            {{ user.username }} <br /> {% trans "email" %}:{{ user.email }}
+        {% else %}
+            {% if name %}{{ name }}{% else %}{% trans "anonymous" %}{% endif %}
+            {% if email %}{% trans "email" %}:{{ email }}{% endif %}
+        {% endif %}
+        <br/>
+            ip: {{request.META.REMOTE_ADDR}}
+    </p>
+
+    <blockquote>
+        {% trans "Message body:" %} {{ message }}
+    </blockquote>
+
+{% endblock %}
index 02cfbf77cae19d0c601711a01a3afa60bfe080ac..c15f8f6b725a3e926f34a50d5b88cb17799bdac3 100644 (file)
@@ -8,9 +8,11 @@ from django.core.urlresolvers import reverse
 from django.core.mail import mail_admins
 from django.utils.translation import ugettext as _
 from forum.utils.forms import get_next_url
-from forum.models import Badge, Award
+from forum.models import Badge, Award, User
 from forum.badges import ALL_BADGES
 from forum import settings
+from forum.utils.mail import send_email
+import re
 
 def favicon(request):
     return HttpResponseRedirect(str(settings.APP_FAVICON))
@@ -27,38 +29,34 @@ def faq(request):
     return render_to_response('faq.html', data, context_instance=RequestContext(request))
 
 def feedback(request):
-    data = {}
-    form = None
     if request.method == "POST":
         form = FeedbackForm(request.POST)
         if form.is_valid():
+            context = {'user': request.user}
+
             if not request.user.is_authenticated:
-                data['email'] = form.cleaned_data.get('email',None)
-            data['message'] = form.cleaned_data['message']
-            data['name'] = form.cleaned_data.get('name',None)
-            message = render_to_response('feedback_email.txt',data,context_instance=RequestContext(request))
-            mail_admins(_('Q&A forum feedback'), message)
+                context['email'] = form.cleaned_data.get('email',None)
+            context['message'] = form.cleaned_data['message']
+            context['name'] = form.cleaned_data.get('name',None)
+
+            recipients = [(adm.username, adm.email) for adm in User.objects.filter(is_superuser=True)]
+
+            send_email(settings.EMAIL_SUBJECT_PREFIX + _("Feedback message from %(site_name)s") % {'site_name': settings.APP_SHORT_NAME},
+                       recipients, "notifications/feedback.html", context)
+            
             msg = _('Thanks for the feedback!')
             request.user.message_set.create(message=msg)
             return HttpResponseRedirect(get_next_url(request))
     else:
         form = FeedbackForm(initial={'next':get_next_url(request)})
 
-    data['form'] = form
-    return render_to_response('feedback.html', data, context_instance=RequestContext(request))
+    return render_to_response('feedback.html', {'form': form}, context_instance=RequestContext(request))
 feedback.CANCEL_MESSAGE=_('We look forward to hearing your feedback! Please, give it next time :)')
 
 def privacy(request):
     return render_to_response('privacy.html', context_instance=RequestContext(request))
 
-def logout(request):#refactor/change behavior?
-#currently you click logout and you get
-#to this view which actually asks you again - do you really want to log out?
-#I guess rationale was to tell the user that s/he may be still logged in
-#through their external login sytem and we'd want to remind them about it
-#however it might be a little annoying
-#why not just show a message: you are logged out of osqa, but
-#if you really want to log out -> go to your openid provider
+def logout(request):
     return render_to_response('logout.html', {
         'next' : get_next_url(request),
     }, context_instance=RequestContext(request))
index 501b63a315fba44d4ceb32b758a77892bc7a71e0..227cdf603f140aabb0a6aa0385b68b7c4b3094c3 100644 (file)
@@ -120,7 +120,7 @@ def edit_user(request, id):
             user.about = sanitize_html(form.cleaned_data['about'])\r
 \r
             user.save()\r
-            # send user updated singal if full fields have been updated\r
+            # send user updated signal if full fields have been updated\r
             if user.email and user.real_name and user.website and user.location and \\r
                 user.date_of_birth and user.about:\r
                 user_updated.send(sender=user.__class__, instance=user, updated_by=user)\r