From f8a55d886d0d75c7d3a2b97cc5942b46783c06fa Mon Sep 17 00:00:00 2001 From: LatidoReMe <30684769+LatidoReMe@users.noreply.github.com> Date: Sun, 21 Mar 2021 03:08:54 -0700 Subject: [PATCH] SP Notes Field & Filter Using translation SP notes for consistency terminology on the site. --- bang/forms.py | 5 ++++- bang/magicollections.py | 6 ++++++ bang/models.py | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bang/forms.py b/bang/forms.py index 18892fb..6d439c3 100644 --- a/bang/forms.py +++ b/bang/forms.py @@ -977,12 +977,15 @@ class SongFilterForm(MagiFiltersForm): is_full = forms.NullBooleanField(initial=None, required=False, label=_('FULL version')) is_full_filter = MagiFilter(selector='is_full') + sp_notes = forms.NullBooleanField(initial=None, required=False, label=_('{} notes').format('SP')) + sp_notes_filter = MagiFilter(selector='sp_notes') + version = forms.ChoiceField(label=_(u'Server availability'), choices=BLANK_CHOICE_DASH + models.Account.VERSION_CHOICES) version_filter = MagiFilter(to_queryset=lambda form, queryset, request, value: queryset.filter(c_versions__contains=value)) class Meta(MagiFiltersForm.Meta): model = models.Song - fields = ('search', 'i_band', 'i_unlock', 'is_cover', 'is_full', 'version', 'ordering', 'reverse_order') + fields = ('search', 'i_band', 'i_unlock', 'is_cover', 'is_full', 'sp_notes', 'version', 'ordering', 'reverse_order') ############################################################ # AreaItem form diff --git a/bang/magicollections.py b/bang/magicollections.py index c8f6d67..2cfe6a9 100644 --- a/bang/magicollections.py +++ b/bang/magicollections.py @@ -1892,6 +1892,7 @@ def extra_context(self, context): 'event': 'event', 'versions': 'world', 'played': 'contest', + 'sp_notes': 'toggler' } SONG_ITEM_FIELDS_ORDER = ['song_name'] @@ -1950,6 +1951,8 @@ def to_fields(self, view, item, *args, **kwargs): setSubField(fields, u'{}_difficulty'.format(difficulty), key='type', value='html') setSubField(fields, u'{}_difficulty'.format(difficulty), key='value', value=mark_safe(u'{}
'.format(generateDifficulty(diff)))) + if item.sp_notes: + setSubField(fields, 'special_difficulty', key='annotation', value='+ '+_('{} notes').format('SP')) if 'event' in fields: fields['event'] = subtitledImageLink(item.event, _('Event'), 'event') @@ -1970,6 +1973,9 @@ class ListView(MainItemCollection.ListView): ('is_full', { 'type': CuteFormType.YesNo, }), + ('sp_notes', { + 'type': CuteFormType.YesNo, + }), ]) def extra_context(self, context): diff --git a/bang/models.py b/bang/models.py index 8d33c4d..69f51ec 100644 --- a/bang/models.py +++ b/bang/models.py @@ -1401,6 +1401,7 @@ def length_in_minutes(self): expert_difficulty = models.PositiveIntegerField(string_concat(_('Expert'), ' - ', _('Difficulty')), validators=DIFFICULTY_VALIDATORS, null=True) special_notes = models.PositiveIntegerField(string_concat(_('Special'), ' - ', _('Notes')), null=True) special_difficulty = models.PositiveIntegerField(string_concat(_('Special'), ' - ', _('Difficulty')), validators=DIFFICULTY_VALIDATORS, null=True) + sp_notes = models.BooleanField(_('{} notes').format('SP'), default=False) UNLOCK = OrderedDict([ ('gift', {