Remove unreferenced mustache_helpers code
I can't seem to find any references to this code outside of the library and the tests themselves.
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
from django.utils.translation import ugettext as _
|
||||
import django.core.urlresolvers as urlresolvers
|
||||
import sys
|
||||
import inspect
|
||||
|
||||
# This method is used to pluralize the words "discussion" and "comment"
|
||||
# which is why you need to tack on an "s" for the case of 0 or two or more.
|
||||
|
||||
|
||||
def pluralize(content, text):
|
||||
num, word = text.split(' ')
|
||||
num = int(num or '0')
|
||||
if num >= 2 or num == 0:
|
||||
return word + 's'
|
||||
else:
|
||||
return word
|
||||
|
||||
|
||||
def url_for_user(content, user_id):
|
||||
return urlresolvers.reverse('django_comment_client.forum.views.user_profile', args=[content['course_id'], user_id])
|
||||
|
||||
|
||||
def close_thread_text(content):
|
||||
if content.get('closed'):
|
||||
return _('Re-open thread')
|
||||
else:
|
||||
return _('Close thread')
|
||||
|
||||
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('_')}
|
||||
@@ -1,27 +0,0 @@
|
||||
from django.test import TestCase
|
||||
import django_comment_client.mustache_helpers as mustache_helpers
|
||||
|
||||
|
||||
class PluralizeTest(TestCase):
|
||||
def setUp(self):
|
||||
super(PluralizeTest, self).setUp()
|
||||
self.text1 = '0 goat'
|
||||
self.text2 = '1 goat'
|
||||
self.text3 = '7 goat'
|
||||
self.content = 'unused argument'
|
||||
|
||||
def test_pluralize(self):
|
||||
self.assertEqual(mustache_helpers.pluralize(self.content, self.text1), 'goats')
|
||||
self.assertEqual(mustache_helpers.pluralize(self.content, self.text2), 'goat')
|
||||
self.assertEqual(mustache_helpers.pluralize(self.content, self.text3), 'goats')
|
||||
|
||||
|
||||
class CloseThreadTextTest(TestCase):
|
||||
def setUp(self):
|
||||
super(CloseThreadTextTest, self).setUp()
|
||||
self.contentClosed = {'closed': True}
|
||||
self.contentOpen = {'closed': False}
|
||||
|
||||
def test_close_thread_text(self):
|
||||
self.assertEqual(mustache_helpers.close_thread_text(self.contentClosed), 'Re-open thread')
|
||||
self.assertEqual(mustache_helpers.close_thread_text(self.contentOpen), 'Close thread')
|
||||
Reference in New Issue
Block a user