diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2009-08-10 21:40:01 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2009-08-10 21:40:01 -0400 |
commit | 1eacc7a42618e84766477fbcc2c32a1da3547115 (patch) | |
tree | 23b90f5410c1dfd94704cbb38aad2bdf32cf0f5f /forum | |
parent | 0f607d83e801192977bff15c256456fa2f44ff85 (diff) | |
download | askbot-1eacc7a42618e84766477fbcc2c32a1da3547115.tar.gz askbot-1eacc7a42618e84766477fbcc2c32a1da3547115.tar.bz2 askbot-1eacc7a42618e84766477fbcc2c32a1da3547115.zip |
untested commit. merged Adolfos mods, validated most of html, slugify urls, fixed IE issues in openid signin
Diffstat (limited to 'forum')
-rw-r--r-- | forum/models.py | 20 | ||||
-rw-r--r-- | forum/templatetags/extra_filters.py | 9 | ||||
-rw-r--r-- | forum/templatetags/extra_tags.py | 6 |
3 files changed, 22 insertions, 13 deletions
diff --git a/forum/models.py b/forum/models.py index 7de703ca..9510476a 100644 --- a/forum/models.py +++ b/forum/models.py @@ -274,6 +274,16 @@ class Question(models.Model): class Meta: db_table = u'question' +class FavoriteQuestion(models.Model): + """A favorite Question of a User.""" + question = models.ForeignKey(Question) + user = models.ForeignKey(User, related_name='user_favorite_questions') + added_at = models.DateTimeField(default=datetime.datetime.now) + class Meta: + db_table = u'favorite_question' + def __unicode__(self): + return '[%s] favorited at %s' %(self.user, self.added_at) + class QuestionRevision(models.Model): """A revision of a Question.""" question = models.ForeignKey(Question, related_name='revisions') @@ -422,16 +432,6 @@ class AnswerRevision(models.Model): flat=True)[0] + 1 super(AnswerRevision, self).save(**kwargs) -class FavoriteQuestion(models.Model): - """A favorite Question of a User.""" - question = models.ForeignKey(Question) - user = models.ForeignKey(User, related_name='user_favorite_questions') - added_at = models.DateTimeField(default=datetime.datetime.now) - class Meta: - db_table = u'favorite_question' - def __unicode__(self): - return '[%s] favorited at %s' %(self.user, self.added_at) - class Badge(models.Model): """Awarded for notable actions performed on the site by Users.""" GOLD = 1 diff --git a/forum/templatetags/extra_filters.py b/forum/templatetags/extra_filters.py index cec97920..d8b8e61f 100644 --- a/forum/templatetags/extra_filters.py +++ b/forum/templatetags/extra_filters.py @@ -1,8 +1,13 @@ -from django import template +from django import template from forum import auth register = template.Library() +@template.defaultfilters.stringfilter +@register.filter +def collapse(input): + return ' '.join(input.split()) + @register.filter def can_vote_up(user): return auth.can_vote_up(user) @@ -80,4 +85,4 @@ def cnprog_intword(number): else: return number except: - return number
\ No newline at end of file + return number diff --git a/forum/templatetags/extra_tags.py b/forum/templatetags/extra_tags.py index ac4e6ca3..06a2d27c 100644 --- a/forum/templatetags/extra_tags.py +++ b/forum/templatetags/extra_tags.py @@ -14,7 +14,8 @@ register = template.Library() GRAVATAR_TEMPLATE = ('<img width="%(size)s" height="%(size)s" ' 'src="http://www.gravatar.com/avatar/%(gravatar_hash)s' - '?s=%(size)s&d=identicon&r=PG">') + '?s=%(size)s&d=identicon&r=PG" ' + 'alt="%(username)s\'s gravatar image" />') @register.simple_tag def gravatar(user, size): @@ -26,11 +27,14 @@ def gravatar(user, size): """ try: gravatar = user['gravatar'] + username = user['username'] except (TypeError, AttributeError, KeyError): gravatar = user.gravatar + username = user.username return mark_safe(GRAVATAR_TEMPLATE % { 'size': size, 'gravatar_hash': gravatar, + 'username': template.defaultfilters.urlencode(username), }) MAX_FONTSIZE = 18 |