1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
from django import template
from forum import auth
from forum_modules.grapefruit import Color
from django.utils.translation import ugettext as _
import logging
register = template.Library()
@template.defaultfilters.stringfilter
@register.filter
def collapse(input):
return ' '.join(input.split())
@register.filter
def can_moderate_users(user):
return auth.can_moderate_users(user)
@register.filter
def can_vote_up(user):
return auth.can_vote_up(user)
@register.filter
def can_flag_offensive(user):
return auth.can_flag_offensive(user)
@register.filter
def can_add_comments(user,subject):
return auth.can_add_comments(user,subject)
@register.filter
def can_vote_down(user):
return auth.can_vote_down(user)
@register.filter
def can_retag_questions(user):
return auth.can_retag_questions(user)
@register.filter
def can_edit_post(user, post):
return auth.can_edit_post(user, post)
@register.filter
def can_delete_comment(user, comment):
return auth.can_delete_comment(user, comment)
@register.filter
def can_view_offensive_flags(user):
return auth.can_view_offensive_flags(user)
@register.filter
def can_close_question(user, question):
return auth.can_close_question(user, question)
@register.filter
def can_lock_posts(user):
return auth.can_lock_posts(user)
@register.filter
def can_accept_answer(user, question, answer):
return auth.can_accept_answer(user, question, answer)
@register.filter
def can_reopen_question(user, question):
return auth.can_reopen_question(user, question)
@register.filter
def can_delete_post(user, post):
return auth.can_delete_post(user, post)
@register.filter
def can_view_user_edit(request_user, target_user):
return auth.can_view_user_edit(request_user, target_user)
@register.filter
def can_view_user_votes(request_user, target_user):
return auth.can_view_user_votes(request_user, target_user)
@register.filter
def can_view_user_preferences(request_user, target_user):
return auth.can_view_user_preferences(request_user, target_user)
@register.filter
def is_user_self(request_user, target_user):
return auth.is_user_self(request_user, target_user)
@register.filter
def cnprog_intword(number):
try:
if 1000 <= number < 10000:
string = str(number)[0:1]
return '<span class="thousand">%sk</span>' % string
else:
return number
except:
return number
@register.filter
def humanize_counter(number):
if number == 0:
return _('no items in counter')
elif number >= 1000:
number = number/1000
s = '%.1f' % number
if s.endswith('.0'):
return s[:-2] + 'k'
else:
return s + 'k'
else:
return str(number)
|