From d967dc8765eeb8f2b11a206a0cb7f041b752b583 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Tue, 20 Sep 2011 13:47:34 -0300 Subject: fixed incorrect usage of diff_date in the templates, added a better test for the responses page, and improved error checking in PageLoadTests --- askbot/forms.py | 31 +++++++++++++-------- askbot/models/__init__.py | 2 ++ .../default/templates/user_profile/user_inbox.html | 4 +-- .../templates/user_profile/user_recent.html | 2 +- .../default/templates/user_profile/user_votes.html | 2 +- askbot/tests/page_load_tests.py | 32 +++++++++++++++++++++- 6 files changed, 56 insertions(+), 17 deletions(-) diff --git a/askbot/forms.py b/askbot/forms.py index b13abe0c..afef2cc5 100644 --- a/askbot/forms.py +++ b/askbot/forms.py @@ -968,19 +968,26 @@ class EmailFeedSettingField(forms.ChoiceField): class EditUserEmailFeedsForm(forms.Form): FORM_TO_MODEL_MAP = { - 'all_questions':'q_all', - 'asked_by_me':'q_ask', - 'answered_by_me':'q_ans', - 'individually_selected':'q_sel', - 'mentions_and_comments':'m_and_c', - } + 'all_questions':'q_all', + 'asked_by_me':'q_ask', + 'answered_by_me':'q_ans', + 'individually_selected':'q_sel', + 'mentions_and_comments':'m_and_c', + } NO_EMAIL_INITIAL = { - 'all_questions':'n', - 'asked_by_me':'n', - 'answered_by_me':'n', - 'individually_selected':'n', - 'mentions_and_comments':'n', - } + 'all_questions':'n', + 'asked_by_me':'n', + 'answered_by_me':'n', + 'individually_selected':'n', + 'mentions_and_comments':'n', + } + INSTANT_EMAIL_INITIAL = { + 'all_questions':'i', + 'asked_by_me':'i', + 'answered_by_me':'i', + 'individually_selected':'i', + 'mentions_and_comments':'i', + } asked_by_me = EmailFeedSettingField( label=_('Asked by me') diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py index 85533ece..d7c034e3 100644 --- a/askbot/models/__init__.py +++ b/askbot/models/__init__.py @@ -1202,6 +1202,8 @@ def user_post_question( is_anonymous = False, timestamp = None ): + """makes an assertion whether user can post the question + then posts it and returns the question object""" self.assert_can_post_question() diff --git a/askbot/skins/default/templates/user_profile/user_inbox.html b/askbot/skins/default/templates/user_profile/user_inbox.html index 4743a4c1..e7e3dbfe 100644 --- a/askbot/skins/default/templates/user_profile/user_inbox.html +++ b/askbot/skins/default/templates/user_profile/user_inbox.html @@ -70,7 +70,7 @@ inbox_section - forum|flags {{ response.user.username }} {{ response.response_type }} - ({{ response.timestamp|diff_date(3, True) }}):
+ ({{ response.timestamp|diff_date(True) }}):
{{ response.response_snippet}}
@@ -84,7 +84,7 @@ inbox_section - forum|flags {{ nested_response.user.username }} {{ nested_response.response_type }} - ({{ nested_response.timestamp|diff_date(3, True) }}):
+ ({{ nested_response.timestamp|diff_date(True) }}):
{{ nested_response.response_snippet}}
diff --git a/askbot/skins/default/templates/user_profile/user_recent.html b/askbot/skins/default/templates/user_profile/user_recent.html index 9239196a..cbd59202 100644 --- a/askbot/skins/default/templates/user_profile/user_recent.html +++ b/askbot/skins/default/templates/user_profile/user_recent.html @@ -7,7 +7,7 @@
{% for act in activities %}
-
{{ act.time|diff_date(3) }}
+
{{ act.time|diff_date(True) }}
{{ act.type }}
diff --git a/askbot/skins/default/templates/user_profile/user_votes.html b/askbot/skins/default/templates/user_profile/user_votes.html index b6fe784b..d5e469ae 100644 --- a/askbot/skins/default/templates/user_profile/user_votes.html +++ b/askbot/skins/default/templates/user_profile/user_votes.html @@ -7,7 +7,7 @@
{% for vote in votes %}
-
{{vote.voted_at|diff_date(3)}}
+
{{vote.voted_at|diff_date(True)}}
{% if vote.vote==1 %} diff --git a/askbot/tests/page_load_tests.py b/askbot/tests/page_load_tests.py index 58ca7537..4d98a971 100644 --- a/askbot/tests/page_load_tests.py +++ b/askbot/tests/page_load_tests.py @@ -49,11 +49,21 @@ class PageLoadTestCase(TestCase): if template: if isinstance(r.template, coffin.template.Template): self.assertEqual(r.template.name, template) - else: + elif isinstance(r.template, list): #asuming that there is more than one template template_names = ','.join([t.name for t in r.template]) print 'templates are %s' % template_names + if follow == False: + self.fail( + 'This should not have happened, ' + 'since you are not expecting a redirect ' + 'i.e. follow == False, there should be only ' + 'one template' + ) + self.assertEqual(r.template[0].name, template) + else: + raise Exception('unexpected error while runnig test') class PageLoadTests(PageLoadTestCase): fixtures = ['tmp/fixture2.json', ] @@ -313,6 +323,26 @@ class PageLoadTests(PageLoadTestCase): ) self.client.logout() + def test_inbox_page(self): + asker = models.User.objects.get(id = 2) + question = asker.post_question( + title = 'How can this happen?', + body_text = 'This is the body of my question', + tags = 'question answer test', + ) + responder = models.User.objects.get(id = 3) + responder.post_answer( + question = question, + body_text = 'this is the answer text' + ) + self.client.login(method = 'force', user_id = asker.id) + self.try_url( + 'user_profile', + kwargs={'id': asker.id, 'slug': slugify(asker.username)}, + data={'sort':'inbox'}, + template='user_profile/user_inbox.html', + ) + class AvatarTests(AskbotTestCase): def test_avatar_for_two_word_user_works(self): -- cgit v1.2.3-1-g7c22