Commit f82c2e00 by Rocky Duan

simplified mustache helper loading

parent 1c161a76
from django.core.urlresolvers import reverse
import django.core.urlresolvers as urlresolvers
import urllib
import sys
import inspect
def pluralize(content, text):
num, word = text.split(' ')
......@@ -9,10 +11,10 @@ def pluralize(content, text):
return num + ' ' + word
def url_for_user(content, user_id):
return reverse('django_comment_client.forum.views.user_profile', args=[content['course_id'], user_id])
return urlresolvers.reverse('django_comment_client.forum.views.user_profile', args=[content['course_id'], user_id])
def url_for_tags(content, tags): # assume that tags is in the format u'a, b, c'
return reverse('django_comment_client.forum.views.forum_form_discussion', args=[content['course_id']]) + '?' + urllib.urlencode({'tags': tags})
def url_for_tags(content, tags): # assume that attribute 'tags' is in the format u'a, b, c'
return urlresolvers.reverse('django_comment_client.forum.views.forum_form_discussion', args=[content['course_id']]) + '?' + urllib.urlencode({'tags': tags})
def close_thread_text(content):
if content.get('closed'):
......@@ -20,9 +22,7 @@ def close_thread_text(content):
else:
return 'Close thread'
mustache_helpers = {
'pluralize': pluralize,
'url_for_tags': url_for_tags,
'url_for_user': url_for_user,
'close_thread_text': close_thread_text,
}
current_module = sys.modules[__name__]
all_functions = inspect.getmembers(current_module, inspect.isfunction)
mustache_helpers = {k: v for k, v in all_functions if not k.startswith('_')}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment