def __init__(self, *args, **kwargs):
super(UserPreferencesForm, self).__init__(*args, **kwargs)
if not FAVORITE_CHARACTERS:
for i in range(1, 4):
self.fields.pop('favorite_character{}'.format(i))
else:
for i in range(1, 4):
self.fields['favorite_character{}'.format(i)] = forms.ChoiceField(
required=False,
choices=BLANK_CHOICE_DASH + [(name, localized) for (name, localized, image) in FAVORITE_CHARACTERS],
label=(_(FAVORITE_CHARACTER_NAME) if FAVORITE_CHARACTER_NAME
else _('{nth} Favorite Character')).format(nth=_(ordinalNumber(i))))
self.fields['birthdate'] = date_input(self.fields['birthdate'])
if USER_COLORS:
self.fields['color'].choices = BLANK_CHOICE_DASH + [(name, localized_name) for (name, localized_name, css_color, hex_color) in USER_COLORS]
if self.instance:
self.fields['color'].initial = self.instance.color
else:
self.fields.pop('color')
self.fields['language'].choices = [l for l in self.fields['language'].choices if l[0]]
self.old_location = self.instance.location if self.instance else None
if 'activity' not in RAW_CONTEXT['all_enabled']:
del(self.fields['view_activities_language_only'])
评论列表
文章目录