diff options
author | Adolfo Fitoria <fitoria@fitoria-laptop.(none)> | 2009-08-06 00:00:13 +0800 |
---|---|---|
committer | Mike Chen <chagel@gmail.com> | 2009-08-09 11:39:49 +0800 |
commit | 09b805b00f25fe6a5509334f9091332d89e7d40d (patch) | |
tree | b73a4ea4cb57c05bbbb6a89993dd6112cbc25c5d /forum | |
parent | e6d0c3145ca5447ede865e8145423cf5621a226a (diff) | |
download | askbot-09b805b00f25fe6a5509334f9091332d89e7d40d.tar.gz askbot-09b805b00f25fe6a5509334f9091332d89e7d40d.tar.bz2 askbot-09b805b00f25fe6a5509334f9091332d89e7d40d.zip |
fixing if and elses that have issues with python 2.4
Signed-off-by: Mike Chen <chagel@gmail.com>
Diffstat (limited to 'forum')
-rw-r--r-- | forum/auth.py | 5 | ||||
-rw-r--r-- | forum/models.py | 12 | ||||
-rw-r--r-- | forum/views.py | 10 |
3 files changed, 22 insertions, 5 deletions
diff --git a/forum/auth.py b/forum/auth.py index 0608031a..082f5186 100644 --- a/forum/auth.py +++ b/forum/auth.py @@ -167,7 +167,10 @@ def can_upload_files(request_user): ###########################################
def calculate_reputation(origin, offset):
result = int(origin) + int(offset)
- return result if result > 0 else 1
+ if (result > 0):
+ return result
+ else:
+ return 1
@transaction.commit_on_success
def onFlaggedItem(item, post, user):
diff --git a/forum/models.py b/forum/models.py index 570db274..ee7e59a1 100644 --- a/forum/models.py +++ b/forum/models.py @@ -173,7 +173,10 @@ class Question(models.Model): attr = CONST['deleted']
else:
attr = None
- return u'%s %s' % (self.title, attr) if attr is not None else self.title
+ if (attr is not None):
+ return u'%s %s' % (self.title, attr)
+ else:
+ self.title
def get_revision_url(self):
return reverse('question_revisions', args=[self.id])
@@ -517,7 +520,12 @@ def record_comment_event(instance, created, **kwargs): from django.contrib.contenttypes.models import ContentType
question_type = ContentType.objects.get_for_model(Question)
question_type_id = question_type.id
- type = TYPE_ACTIVITY_COMMENT_QUESTION if instance.content_type_id == question_type_id else TYPE_ACTIVITY_COMMENT_ANSWER
+ #python 2.4 issues - Adolfo Fitoria
+ #type = TYPE_ACTIVITY_COMMENT_QUESTION if instance.content_type_id == question_type_id else TYPE_ACTIVITY_COMMENT_ANSWER
+ if (instance.content_type_id == question_type_id):
+ type = TYPE_ACTIVITY_COMMENT_QUESTION
+ else:
+ type = TYPE_ACTIVITY_COMMENT_ANSWER
activity = Activity(user=instance.user, active_at=instance.added_at, content_object=instance, activity_type=type)
activity.save()
diff --git a/forum/views.py b/forum/views.py index 08a0e958..5d377c3f 100644 --- a/forum/views.py +++ b/forum/views.py @@ -1037,8 +1037,14 @@ def user_recent(request, user_id, user_view): self.type_id = type
self.title = title
self.summary = summary
- self.title_link = u'/questions/%s/%s#%s' %(question_id, title, answer_id)\
- if int(answer_id) > 0 else u'/questions/%s/%s' %(question_id, title)
+ #python 2.4 issue - Adolfo Fitoria
+ #self.title_link = u'/questions/%s/%s#%s' %(question_id, title, answer_id)\
+ # if int(answer_id) > 0 else u'/questions/%s/%s' %(question_id, title)
+ if (int(answer_id)>0):
+ self.title_link = u'/questions/%s/%s#%s' %(question_id, title, answer_id)
+ else:
+ self.title_link = u'/questions/%s/%s' %(question_id, title)
+
class AwardEvent:
def __init__(self, time, type, id):
self.time = time
|