From 7ab862375a0b78146ba03d02c6bedc55dbd40fe2 Mon Sep 17 00:00:00 2001 From: Patrick Samson Date: Sun, 27 Oct 2013 10:51:46 +0100 Subject: [PATCH] Renamed test_urls.py to urls_for_tests.py ; Converted some translations to lazy --- CHANGELOG | 7 ++++ docs/conf.py | 2 +- postman/__init__.py | 4 +-- postman/locale/nl/LC_MESSAGES/django.mo | Bin 3667 -> 4700 bytes postman/locale/nl/LC_MESSAGES/django.po | 31 ++++++++--------- postman/tests.py | 35 ++++++++++++++------ postman/urls.py | 2 +- postman/{test_urls.py => urls_for_tests.py} | 2 +- postman/views.py | 8 ++--- 9 files changed, 55 insertions(+), 36 deletions(-) rename postman/{test_urls.py => urls_for_tests.py} (99%) diff --git a/CHANGELOG b/CHANGELOG index be75a53..f7beab3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,13 @@ Django Postman changelog ======================== +Version 3.0.2, October 2013 +--------------------------- +* Rename test_urls.py to urls_for_tests.py, for adjustment with the new test discovery feature of Django 1.6. +* Fix the need for some translations to become lazy, introduced by the conversion to class-based views. +* Fix issue #36, BooleanField definition needs an explicit default value for Django 1.6. +* Fix issue #35, the app can work without the sites framework. + Version 3.0.1, August 2013 -------------------------- * Fix issue #32, an IndexError when a Paginator is used and the folder is empty. diff --git a/docs/conf.py b/docs/conf.py index 0894775..9a8fe1d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -47,7 +47,7 @@ copyright = u'2010, Patrick Samson' # The short X.Y version. version = '3.0' # The full version, including alpha/beta/rc tags. -release = '3.0.1.post1' +release = '3.0.2' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/postman/__init__.py b/postman/__init__.py index 86783a7..5f7f5b9 100644 --- a/postman/__init__.py +++ b/postman/__init__.py @@ -4,9 +4,9 @@ A messaging application for Django from __future__ import unicode_literals # following PEP 386: N.N[.N]+[{a|b|c|rc}N[.N]+][.postN][.devN] -VERSION = (3, 0, 1) +VERSION = (3, 0, 2) PREREL = () -POST = 1 +POST = 0 DEV = 0 # options diff --git a/postman/locale/nl/LC_MESSAGES/django.mo b/postman/locale/nl/LC_MESSAGES/django.mo index cb43240eb15eed35e876cd977860be4eba31bc14..da1c0340ee306e04818a01d5825ad8af8a63d808 100644 GIT binary patch literal 4700 zcma);ON<;x8GtJg2$?`a97q5MQZXdn#q(U}VaAVm*Sp>rv3Rl936Tt`2WBD`v3X;p4-2scvdJ6QkLJMln2AxdGY+^ZA!f#{uS#qGW6#ae#KMY@kqQ~Fh{qUbq*14BO zWxofYv^A7-cofRHEJ0cSJiG^bke~XzYkvXCx?h2^&R3zxbrm#u0Uv^QAhfKzAJU~dP{u7euDS1@hN4doeh^-P zVvlPOmDIPP?DG=D1nN~N_W3!K^?waTzCS=&|Ie=f?@-3yhR`zq9w_7XLYX%Q#m^R? z%sUL_JWfK18}jJlUG|G?k5C?WeaGP;SD%AzimWS-+!J|DlqlX^-uozzx<0uZk5NA2 z+8=Wi9Htzj9H1Pfh(F4iiG4+fWeVyQkLW0Nl4pMj^#oj`e8{z*g72Y-T}5Z{bMbxg z&+2(A6^TFc%u^O9a&FZlHmp-Ru0woBo`aNDQR8eKkH98H?D{Z8&Q~6Z7vhuhe3Y_M z)JngSGZnvifbu@+uhlN4Ch|>kSx*w1nQrY;&-y!;YpSj{ZKAWGfnjJTK{U{b@lqRg zRaYGun`7#jR*U_V1#QrFm~;`q_NCPur+a zf%S~$1Bkq_nNO#~&zQbJQh(Z!7@5m%qP~~u5S=sDF=*cp;=n{%b2>Q9(LYT$^Dx}e z7;^Vhssq_NNX2~ESNFY0_hgZ=Wjno@*s;!nvC)|=*wiQ4FtnICGs#$|SO8_~Vi?v+ zGvoP%E?#L{x9(Jyn>L&TVW=a6#b@?y>gQ};$Rf+m$|vgHwEN8JeD2SjU#f4=-3jHt z=?Q*$rf+&Y#>Z}nVTVszJ$9ZT4V+eQh@oAlrW&Maj*)vi8moJGX2&?1uhSjOIBwRK zt&VKQS;XN^y|lu_=AmE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0&xYGO9=f6{MVd#I#;&l$vY z_iMU0J8bF_@ra2yZbQanH;`HEMzg$bZPuZoqU?gS3@7Lh_z${OxqB;v%c}yxKpJwytSf@6<)34g1>tUHjW2ZnNjK`_|*lbu_;A cj)?(Q=Y4dWrk1!J`SaY(`G<#U3d+*{09*%{z5oCK diff --git a/postman/locale/nl/LC_MESSAGES/django.po b/postman/locale/nl/LC_MESSAGES/django.po index 0b8cf93..cd61737 100644 --- a/postman/locale/nl/LC_MESSAGES/django.po +++ b/postman/locale/nl/LC_MESSAGES/django.po @@ -3,15 +3,16 @@ # This file is distributed under the same license as the django-postman package. # # Translators: -# Patrick Samson , 2011. +# Gwildor , 2013 +# Patrick Samson , 2011 msgid "" msgstr "" "Project-Id-Version: django-postman\n" "Report-Msgid-Bugs-To: http://bitbucket.org/psam/django-postman/issues\n" -"POT-Creation-Date: 2012-12-10 23:13+0100\n" -"PO-Revision-Date: 2010-12-27 15:10+0000\n" -"Last-Translator: Patrick Samson \n" -"Language-Team: LANGUAGE \n" +"POT-Creation-Date: 2012-12-10 23:00+0100\n" +"PO-Revision-Date: 2013-10-11 14:53+0000\n" +"Last-Translator: Gwildor \n" +"Language-Team: Dutch (http://www.transifex.com/projects/p/django-postman/language/nl/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -137,7 +138,7 @@ msgstr "" #: .\models.py:28 msgid "Accepted" -msgstr "" +msgstr "Geaccepteerd" #: .\models.py:29 .\templates\postman\view.html.py:14 msgid "Rejected" @@ -245,11 +246,7 @@ msgid "" "\n" "{sender} wrote:\n" "{body}\n" -msgstr "" -"\n" -"\n" -"{sender} schreef:\n" -"{body}\n" +msgstr "\n\n{sender} schreef:\n{body}\n" #: .\utils.py:63 msgid "Re: {subject}" @@ -261,7 +258,7 @@ msgstr "Bericht succesvol verstuurd." #: .\views.py:146 .\views.py:208 msgid "Message rejected for at least one recipient." -msgstr "" +msgstr "Bericht geweigerd voor ten minste een ontvanger." #: .\views.py:299 msgid "Select at least one object." @@ -311,7 +308,7 @@ msgstr[1] "Herstel de fouten hieronder." #: .\templates\admin\postman\pendingmessage\submit_line.html.py:6 msgid "Accept" -msgstr "" +msgstr "Accepteer" #: .\templates\admin\postman\pendingmessage\submit_line.html.py:7 msgid "Reject" @@ -325,7 +322,7 @@ msgstr "" msgid "" "Messages in this folder will never be removed. You can use this folder for " "long term storage." -msgstr "" +msgstr "Berichten in deze map worden nooit verwijderd. Je kunt deze map gebruiken voor langdurige opslag." #: .\templates\postman\base.html.py:4 msgid "Messaging" @@ -423,7 +420,7 @@ msgstr "" #: .\templates\postman\email_user.txt.py:5 #: .\templates\postman\email_visitor.txt.py:5 msgid ", for the following reason:" -msgstr "" +msgstr ", voor de volgende reden:" #: .\templates\postman\email_user.txt.py:9 #: .\templates\postman\email_visitor.txt.py:10 @@ -460,7 +457,7 @@ msgstr "De sitebeheerder" msgid "" "Note: This message is issued by an automated system.\n" "Do not reply, this would not be taken into account." -msgstr "" +msgstr "NB: Dit bericht is verstuurd door een automatisch systeem.\nReageren helpt niet, dat wordt niet verwerkt." #: .\templates\postman\email_user_subject.txt.py:1 #: .\templates\postman\email_visitor_subject.txt.py:1 @@ -509,7 +506,7 @@ msgstr "Verwijderde berichten" msgid "" "Messages in this folder can be removed from time to time. For long term " "storage, use instead the archive folder." -msgstr "" +msgstr "Berichten in deze map kunnen van tijd tot tijd verwijderd worden. Gebruik de archiefmap voor langdurige opslag." #: .\templates\postman\view.html.py:6 msgid "Conversation" diff --git a/postman/tests.py b/postman/tests.py index fad8cc9..b781317 100644 --- a/postman/tests.py +++ b/postman/tests.py @@ -77,14 +77,14 @@ class GenericTest(TestCase): Usual generic tests. """ def test_version(self): - self.assertEqual(sys.modules['postman'].__version__, "3.0.1.post1") + self.assertEqual(sys.modules['postman'].__version__, "3.0.2") class BaseTest(TestCase): """ Common configuration and helper functions for all tests. """ - urls = 'postman.test_urls' + urls = 'postman.urls_for_tests' def setUp(self): deactivate() # necessary for 1.4 to consider a new settings.LANGUAGE_CODE; 1.3 is fine with or without @@ -322,6 +322,14 @@ class ViewTest(BaseTest): self.check_status(m, sender_deleted_at=True) self.assertEqual(len(mail.outbox), 0) + def check_contrib_messages(self, response, text): + if 'messages' in response.context: # contrib\messages\context_processors.py may be not there + messages = response.context['messages'] + if messages != []: # contrib\messages\middleware.py may be not there + self.assertEqual(len(messages), 1) + for message in messages: # can only be iterated + self.assertEqual(str(message), text) + def check_write_post(self, extra={}, is_anonymous=False): "Check message generation, redirection, and mandatory fields." url = reverse('postman_write') @@ -329,8 +337,9 @@ class ViewTest(BaseTest): data = {'recipients': self.user2.get_username(), 'subject': 's', 'body': 'b'} data.update(extra) # default redirect is to the requestor page - response = self.client.post(url, data, HTTP_REFERER=url) + response = self.client.post(url, data, HTTP_REFERER=url, follow=True) self.assertRedirects(response, url) + self.check_contrib_messages(response, 'Message successfully sent.') # no such check for the following posts, one is enough m = Message.objects.get() pk = m.pk self.check_message(m, is_anonymous) @@ -425,8 +434,9 @@ class ViewTest(BaseTest): url = reverse('postman_write') data = {'subject': 's', 'body': 'b', 'recipients': self.user2.get_username()} self.assertTrue(self.client.login(username='foo', password='pass')) - response = self.client.post(reverse('postman_write_moderate'), data, HTTP_REFERER=url) + response = self.client.post(reverse('postman_write_moderate'), data, HTTP_REFERER=url, follow=True) self.assertRedirects(response, url) + self.check_contrib_messages(response, 'Message rejected for at least one recipient.') self.check_status(Message.objects.get(), status=STATUS_REJECTED, recipient_deleted_at=True, moderation_date=True, moderation_reason="some reason") @@ -524,6 +534,7 @@ class ViewTest(BaseTest): # default redirect is to the requestor page response = self.client.post(url, data, HTTP_REFERER=url) self.assertRedirects(response, url) + # the check_contrib_messages() in test_write_post() is enough self.check_message(Message.objects.get(pk=pk+1)) # fallback redirect is to inbox response = self.client.post(url, data) @@ -607,6 +618,7 @@ class ViewTest(BaseTest): response = self.client.post(reverse('postman_reply_moderate', args=[pk]), data, HTTP_REFERER=url) self.assertRedirects(response, url) + # the check_contrib_messages() in test_write_post_moderate() is enough self.check_status(Message.objects.get(pk=pk+1), status=STATUS_REJECTED, recipient_deleted_at=True, parent=m, thread=m, moderation_date=True, moderation_reason="some reason") @@ -717,7 +729,7 @@ class ViewTest(BaseTest): response = self.client.get(url) self.assertEqual(len(response.context['pm_messages']), 2) - def check_update(self, view_name, field_bit, pk, field_value=None): + def check_update(self, view_name, success_msg, field_bit, pk, field_value=None): "Check permission, redirection, field updates, invalid cases." url = reverse(view_name) url_with_success_url = reverse(view_name + '_with_success_url_to_archives') @@ -729,8 +741,9 @@ class ViewTest(BaseTest): self.assertTrue(self.client.login(username='foo', password='pass')) # default redirect is to the requestor page redirect_url = reverse('postman_sent') - response = self.client.post(url, data, HTTP_REFERER=redirect_url) + response = self.client.post(url, data, HTTP_REFERER=redirect_url, follow=True) # 'follow' to access messages self.assertRedirects(response, redirect_url) + self.check_contrib_messages(response, success_msg) sender_kw = 'sender_{0}'.format(field_bit) recipient_kw = 'recipient_{0}'.format(field_bit) self.check_status(Message.objects.get(pk=pk), status=STATUS_ACCEPTED, **{sender_kw: field_value}) @@ -747,8 +760,9 @@ class ViewTest(BaseTest): response = self.client.post(url_with_success_url + '?next=' + redirect_url, data, HTTP_REFERER='does not matter') self.assertRedirects(response, redirect_url) # missing payload - response = self.client.post(url) + response = self.client.post(url, follow=True) self.assertRedirects(response, reverse('postman_inbox')) + self.check_contrib_messages(response, 'Select at least one object.') # not a POST response = self.client.get(url, data) @@ -766,6 +780,7 @@ class ViewTest(BaseTest): self.assertTrue(self.client.login(username='foo', password='pass')) response = self.client.post(url, data) self.assertRedirects(response, reverse('postman_inbox')) + # contrib.messages are already tested with check_update() sender_kw = 'sender_{0}'.format(field_bit) recipient_kw = 'recipient_{0}'.format(field_bit) self.check_status(Message.objects.get(pk=pk), status=STATUS_ACCEPTED, is_new=False, is_replied=True, thread=root_msg, **{sender_kw: field_value}) @@ -788,7 +803,7 @@ class ViewTest(BaseTest): self.c21() self.c12() self.c13() - self.check_update('postman_archive', 'archived', pk, True) + self.check_update('postman_archive', 'Messages or conversations successfully archived.', 'archived', pk, True) def test_archive_conversation(self): "Test archive action on conversations." @@ -804,7 +819,7 @@ class ViewTest(BaseTest): self.c21() self.c12() self.c13() - self.check_update('postman_delete', 'deleted_at', pk, True) + self.check_update('postman_delete', 'Messages or conversations successfully deleted.', 'deleted_at', pk, True) def test_delete_conversation(self): "Test delete action on conversations." @@ -820,7 +835,7 @@ class ViewTest(BaseTest): self.c21(recipient_deleted_at=now()) self.c12(sender_deleted_at=now()) self.c13() - self.check_update('postman_undelete', 'deleted_at', pk) + self.check_update('postman_undelete', 'Messages or conversations successfully recovered.', 'deleted_at', pk) def test_undelete_conversation(self): "Test undelete action on conversations." diff --git a/postman/urls.py b/postman/urls.py index b34c741..1fcc091 100644 --- a/postman/urls.py +++ b/postman/urls.py @@ -100,7 +100,7 @@ from .views import (InboxView, SentView, ArchivesView, TrashView, ArchiveView, DeleteView, UndeleteView) -urlpatterns = patterns('postman.views', +urlpatterns = patterns('', url(r'^inbox/(?:(?P