from django.contrib.auth.models import User as DjangoUser, AnonymousUser as DjangoAnonymousUser
from django.db.models import Q
+from forum.settings import TRUNCATE_LONG_USERNAMES, TRUNCATE_USERNAMES_LONGER_THAN
+
import string
from random import Random
@property
def decorated_name(self):
+ username = self.username
+
+ if len(username) > TRUNCATE_USERNAMES_LONGER_THAN and TRUNCATE_LONG_USERNAMES:
+ username = '%s...' % username[:TRUNCATE_USERNAMES_LONGER_THAN-3]
+
if settings.SHOW_STATUS_DIAMONDS:
if self.is_superuser:
- return u"%s \u2666\u2666" % self.username
+ return u"%s \u2666\u2666" % username
if self.is_staff:
- return u"%s \u2666" % self.username
+ return u"%s \u2666" % username
return self.username
help_text = _("A comma separated list of disabled usernames (usernames not allowed during a new user registration)."),
widget=CommaStringListWidget))
+TRUNCATE_LONG_USERNAMES = Setting('TRUNCATE_LONG_USERNAMES', True, USERS_SET, dict(
+label=_("Truncate long usernames"),
+help_text = _("The long usernames will be truncated.."),
+required=False,
+))
+
+TRUNCATE_USERNAMES_LONGER_THAN = Setting('TRUNCATE_USERNAMES_LONGER_THAN', 15, USERS_SET, dict(
+label = _("Truncate usernames longer than"),
+help_text = _("The usernames that are longer than this will be truncated and ... will be appended.")))
+
SHOW_STATUS_DIAMONDS = Setting('SHOW_STATUS_DIAMONDS', True, USERS_SET, dict(
label=_("Show status diamonds"),
help_text = _("Show status \"diamonds\" next to moderators or superusers usernames."),