summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-09-20 13:47:34 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-09-20 13:47:34 -0300
commitd967dc8765eeb8f2b11a206a0cb7f041b752b583 (patch)
tree1d2445f1afa70e8b382f7ee252693fcea1073a11
parentfdaabe9a5d03493394bacac35f03694cbe781325 (diff)
downloadaskbot-d967dc8765eeb8f2b11a206a0cb7f041b752b583.tar.gz
askbot-d967dc8765eeb8f2b11a206a0cb7f041b752b583.tar.bz2
askbot-d967dc8765eeb8f2b11a206a0cb7f041b752b583.zip
fixed incorrect usage of diff_date in the templates, added a better test for the responses page, and improved error checking in PageLoadTests
-rw-r--r--askbot/forms.py31
-rw-r--r--askbot/models/__init__.py2
-rw-r--r--askbot/skins/default/templates/user_profile/user_inbox.html4
-rw-r--r--askbot/skins/default/templates/user_profile/user_recent.html2
-rw-r--r--askbot/skins/default/templates/user_profile/user_votes.html2
-rw-r--r--askbot/tests/page_load_tests.py32
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
<a style="font-size:12px" href="{{ response.user.get_absolute_url() }}">{{ response.user.username }}</a>
<a style="text-decoration:none;" href="{{ response.response_url }}">
{{ response.response_type }}
- ({{ response.timestamp|diff_date(3, True) }}):<br/>
+ ({{ response.timestamp|diff_date(True) }}):<br/>
{{ response.response_snippet}}
</a>
</div>
@@ -84,7 +84,7 @@ inbox_section - forum|flags
<a style="font-size:12px" href="{{ nested_response.user.get_absolute_url() }}">{{ nested_response.user.username }}</a>
<a style="text-decoration:none;" href="{{ nested_response.response_url }}">
{{ nested_response.response_type }}
- ({{ nested_response.timestamp|diff_date(3, True) }}):<br/>
+ ({{ nested_response.timestamp|diff_date(True) }}):<br/>
{{ nested_response.response_snippet}}
</a>
</div>
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 @@
<div style="padding-top:5px;font-size:13px;">
{% for act in activities %}
<div style="clear:both;line-height:20px" >
- <div style="width:180px;float:left">{{ act.time|diff_date(3) }}</div>
+ <div style="width:180px;float:left">{{ act.time|diff_date(True) }}</div>
<div style="width:150px;float:left">
<span class="user-action-{{ act.type_id }}">{{ act.type }}</span>
</div>
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 @@
<div style="padding-top:5px;font-size:13px;">
{% for vote in votes %}
<div style="clear:both;line-height:20px" >
- <div style="width:150px;float:left">{{vote.voted_at|diff_date(3)}}</div>
+ <div style="width:150px;float:left">{{vote.voted_at|diff_date(True)}}</div>
<div style="width:30px;float:left">
{% if vote.vote==1 %}
<img src="{{"/images/vote-arrow-up-on.png"|media}}" title="{% trans %}upvote{% endtrans %}">
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):