Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixing if and elses that have issues with python 2.4

Signed-off-by: Mike Chen <chagel@gmail.com>
  • Loading branch information...
commit 09b805b00f25fe6a5509334f9091332d89e7d40d 1 parent e6d0c31
Adolfo Fitoria authored committed
Showing with 22 additions and 5 deletions.
  1. +4 −1 forum/auth.py
  2. +10 −2 forum/models.py
  3. +8 −2 forum/views.py
View
5 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):
View
12 forum/models.py
@@ -173,7 +173,10 @@ def get_question_title(self):
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()
View
10 forum/views.py
@@ -1037,8 +1037,14 @@ def __init__(self, time, type, title, summary, answer_id, question_id):
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
Please sign in to comment.
Something went wrong with that request. Please try again.