def to_fields(self, view, item, *args, **kwargs): fields = super(SongCollection, self).to_fields(view, item, *args, icons=SONGS_ICONS, images={ 'attribute': staticImageURL(item.i_attribute, folder='i_attribute', extension='png'), 'unit': staticImageURL(item.i_unit, folder='i_unit', extension='png'), 'subunit': staticImageURL(item.i_subunit, folder='i_subunit', extension='png'), }, **kwargs) setSubField(fields, 'b_side_start', key='timezones', value=['Asia/Tokyo', 'Local time']) setSubField(fields, 'b_side_end', key='timezones', value=['Asia/Tokyo', 'Local time']) setSubField(fields, 'release', key='timezones', value=['Asia/Tokyo', 'Local time']) setSubField(fields, 'length', key='value', value=lambda f: item.length_in_minutes) return fields
def to_fields(self, view, item, *args, **kwargs): # Add/Edit view auto-see All-attribute rarity symbols #Item/List view see proper attribute v. when known if item.attribute: rarityfolder='rarity_' + str(item.i_attribute) else: rarityfolder='rarity_3' fields = super(CardCollection, self).to_fields(view, item, *args, icons=CARDS_ICONS, images={ 'attribute': staticImageURL(item.i_attribute, folder='i_attribute', extension='png'), 'rarity': staticImageURL(item.i_rarity, folder=rarityfolder, extension='png'), }, **kwargs) setSubField(fields, 'release', key='timezones', value=['Asia/Tokyo']) setSubField(fields, 'card_id', key='type', value='text') setSubField(fields, 'card_id', key='value', value=u'#{}'.format(item.card_id)) return fields
def to_fields(self, item, images=None, *args, **kwargs): if images is None: images = {} images.update({ 'website': item.website_image, 'groups': staticImageURL(item.groups[0], folder='groups', extension='png') if item.groups else None, }) fields = super(AccountCollection.ItemView, self).to_fields(item, *args, images=images, **kwargs) setSubField(fields, 'website', key='type', value=u'link') setSubField(fields, 'website', key='value', value=item.website_url) setSubField(fields, 'website', key='link_text', value=item.website) return fields
def to_fields(self, view, item, *args, **kwargs): fields = super(IdolCollection, self).to_fields(view, item, *args, icons=IDOLS_ICONS, images={ 'attribute': staticImageURL(item.i_attribute, folder='i_attribute', extension='png'), 'unit': staticImageURL(item.i_unit, folder='i_unit', extension='png'), 'subunit': staticImageURL(item.i_subunit, folder='i_subunit', extension='png'), 'astrological_sign': staticImageURL( item.i_astrological_sign, folder='i_astrological_sign', extension='png', ), }, **kwargs) if item.japanese_name and get_language() == 'ja': setSubField(fields, 'name', key='value', value=item.japanese_name) setSubField(fields, 'birthday', key='type', value='text') setSubField(fields, 'birthday', key='value', value=lambda f: date_format(item.birthday, format='MONTH_DAY_FORMAT', use_l10n=True)) return fields
def to_fields(self, item, order=None, extra_fields=None, exclude_fields=None, *args, **kwargs): if extra_fields is None: extra_fields = [] if exclude_fields is None: exclude_fields = [] if order is None: order = [] #Add ID Field extra_fields.append(('id', { 'verbose_name': _(u'ID'), 'type': 'text', 'value': u'#{}'.format(item.id), 'icon': 'id', })) # Add Idol field if item.idol: extra_fields.append(('idol_details', { 'verbose_name': _('Idol'), 'type': 'html', 'value': string_concat('<a href="', item.idol.item_url, '"data-ajax-url="', item.idol.ajax_item_url, '"data-ajax-title="', item.idol, '">', item.idol.t_name, '<img class="idol-small-image" src="', item.idol.image_url,'"></img></a>'), 'icon': 'idol', })) # Add skill if item.skill: # Get list of variables to parse through SKILL_REPLACE = models.Card.SKILL_REPLACE if item.idol: SKILL_REPLACE += models.Card.IDOL_REPLACE skill_details = getattr(item, 'skill_details') # Either insert the variable info or ??? for variable in SKILL_REPLACE: if variable in models.Card.IDOL_REPLACE: _item = item.idol else: _item = item og = skill_details if getattr(_item, variable, None) is not None: #If translatable, get translated val instead if variable in models.Card.SKILL_REPLACE_TRANSLATE: var = getattr(_item, 't_{}'.format(variable)) else: var = getattr(_item, variable) else: var = '???' var_re = '{' + variable + '}' skill_details = og.replace(var_re, mark_safe(var)) # Creates skill field skill_sentence=_('{} (Level 1)').format(skill_details) extra_fields.append(('main_skill', { 'verbose_name': _('Skill'), 'type': 'html', 'value': skill_sentence, 'icon': 'sparkle', })) # Add center skill if item.center: leader_skill = getattr(item, 'center_details') leader_skill = leader_skill.format(getattr(item, 't_attribute')) if item.rarity in ['UR', 'SSR']: leader_second = _('plus {group} members\' {} pts. up by {}%') if item.group is not 0 and item.boost_percent is not None: for gvariable, ggvariable in models.Card.GROUP_CHOICES: if ggvariable is item.t_group: if item.t_group is not _('Unit'): og = leader_second var = getattr(item.idol, 't_' + gvariable) leader_second = og.replace('{group}', var) else: og = leader_second leader_second = og.replace('{group}', item.idol.unit) leader_second = leader_second.format(item.t_attribute, item.boost_percent) extra_fields.append(('leader_skill', { 'verbose_name': _('Leader Skill'), 'type': 'text', 'value': leader_skill, 'icon': 'center', })) # Add set if item.in_set: extra_fields.append(('set', { 'verbose_name': _('Set'), 'type': 'link', 'ajax_link': item.in_set.ajax_cards_url, 'link': item.in_set.cards_url, 'link_text': unicode(item.in_set), 'icon': 'scout-box', })) # Add images for image, verbose_name in CARD_IMAGES: #Regular images for each type CARD_IMAGE_TYPES = [ getattr(item, u'{}_url'.format(image)), getattr(item, u'{}_idol_url'.format(image)), ] exclude_fields.append(image) exclude_fields.append(image + '_idol') # Old images if image is not 'transparent': CARD_IMAGE_TYPES += [ getattr(item, u'old_{}_url'.format(image)), getattr(item, u'old_{}_idol_url'.format(image)) ] exclude_fields.append('old_' + image) exclude_fields.append('old_' + image + '_idol') # if type of image, append specific image field if getattr(item, image): extra_fields.append((u'{}s'.format(image), { 'verbose_name': verbose_name, 'type': 'images_links', 'images': [{ 'value': image_url.format(image), 'link': image_url.format(image), 'verbose_name': verbose_name, 'link_text': verbose_name, } for image_url in CARD_IMAGE_TYPES if image_url], 'icon': 'pictures', })) # Exclude certain fields by default for field in CARD_AUTO_EXCLUDE: exclude_fields.append(field) order = CARD_ORDER + order fields = super(CardCollection.ItemView, self).to_fields( item, *args, order=order, extra_fields=extra_fields, exclude_fields=exclude_fields, **kwargs) if item.skill: setSubField(fields, 'main_skill', key='value', value=string_concat( item.skill.card_html(), '<br />', skill_sentence)) if item.center: setSubField(fields, 'leader_skill', key='type', value='title_text') setSubField(fields, 'leader_skill', key='title', value=string_concat(item.t_attribute, ' ', item.t_center)) # if info for 2nd half of center skill is available if item.group is not 0 and item.boost_percent is not None: setSubField(fields, 'leader_skill', key='value', value=string_concat(leader_skill, ', ', leader_second)) return fields
def to_fields(self, item, order=None, extra_fields=None, exclude_fields=None, *args, **kwargs): if extra_fields is None: extra_fields = [] if exclude_fields is None: exclude_fields = [] if order is None: order = [] values = u' ' for fieldName, verbose_name in models.Song.SONGWRITERS: value = getattr(item, fieldName) exclude_fields.append(fieldName) if value: values+=u'<b>{}:</b> {}<br />'.format(verbose_name, value) if values and values is not u' ': extra_fields.append(('songwriters', { 'verbose_name': _('Songwriters'), 'type': 'html', 'value': mark_safe(u'<div class="songwriters-details">{}</div>'.format(values)), 'icon': 'id', })) status = getattr(item, 'status') if status and status != 'ended': start_date = getattr(item, 'b_side_start') end_date = getattr(item, 'b_side_end') if item.b_side_master is True: verbose = string_concat(_('B-Side'), ' - ', _('Countdown'), ' (MASTER)') else: verbose = string_concat(_('B-Side'), ' - ', _('Countdown')) extra_fields += [ ('countdown', { 'verbose_name': verbose, 'value': mark_safe(u'<span class="fontx1-5 countdown" data-date="{date}" data-format="{sentence}"></h4>').format( date=torfc2822(end_date if status == 'current' else start_date), sentence=_('{time} left') if status == 'current' else _('Starts in {time}'), ), 'icon': 'hourglass', 'type': 'html', }), ] else: exclude_fields.append('b_side_start') exclude_fields.append('b_side_end') available = getattr(item, 'available') if available == True: av_value = True else: av_value = False extra_fields += [ ('availability', { 'verbose_name': _('Currently available'), 'value': av_value, 'icon': 'help', 'type': 'bool', }), ] for difficulty, d_verbose in models.Song.DIFFICULTIES: difficulties = u' ' difficultystar = u'{}_difficulty'.format(difficulty) difficultynote = u'{}_notes'.format(difficulty) difficultystars = getattr(item, difficultystar) difficultynotes = getattr(item, difficultynote) temps = u'{} ☆ rating'.format(difficultystars) tempn = u'{} notes'.format(difficultynotes) if difficultystars: if difficultynotes: difficulties += u'{}<br />{}'.format(temps, tempn) if difficulty is 'master' and item.master_swipe is True: difficulties += u'<br />{}'.format(_('with SWIPE notes')) else: difficulties += u'{}'.format(temps) elif difficultynotes: difficulties += u'{}'.format(tempn) if difficulty is 'master' and item.master_swipe is True: difficulties += u'<br />{}'.format(_('with SWIPE notes')) if difficulties is not u' ': extra_fields.append((difficulty, { 'verbose_name': d_verbose, 'type': 'html', 'value': difficulties, })) exclude_fields.append(difficulty) exclude_fields.append(difficultynote) exclude_fields.append(difficultystar) exclude_fields.append('title') exclude_fields.append('romaji') exclude_fields.append('cover') exclude_fields.append('i_attribute') exclude_fields.append('i_unit') exclude_fields.append('i_subunit') exclude_fields.append('c_locations') exclude_fields.append('b_side_master') exclude_fields.append('master_swipe') order = ['itunes_id', 'length', 'bpm', 'c_versions', 'availability', 'unlock', 'daily', 'countdown', 'b_side_start', 'b_side_end', 'easy', 'normal', 'hard', 'expert', 'master', 'songwriters', 'release'] + order fields = super(SongCollection.ItemView, self).to_fields( item, *args, order=order, extra_fields=extra_fields, exclude_fields=exclude_fields, **kwargs) if item.romaji and item.romaji != item.title: setSubField(fields, 'title', key='type', value='title_text') setSubField(fields, 'title', key='title', value=item.title) setSubField(fields, 'title', key='value', value=item.romaji) setSubField(fields, 'unlock', key='type', value='text') setSubField(fields, 'unlock', key='value', value=u'Rank {}'.format(item.unlock)) setSubField(fields, 'easy', key='image', value=staticImageURL('easy', folder='difficulty', extension='png')) setSubField(fields, 'normal', key='image', value=staticImageURL('normal', folder='difficulty', extension='png')) setSubField(fields, 'hard', key='image', value=staticImageURL('hard', folder='difficulty', extension='png')) setSubField(fields, 'expert', key='image', value=staticImageURL('expert', folder='difficulty', extension='png')) setSubField(fields, 'master', key='image', value=staticImageURL('master', folder='difficulty', extension='png')) return fields
def to_fields(self, view, item, *args, **kwargs): fields = super(SIFEventCollection, self).to_fields(view, item, *args, icons=EVENTS_ICONS, images={ 'unit': staticImageURL(item.i_unit, folder='i_unit', extension='png'), }, **kwargs) setSubField(fields, 'jp_start_date', key='timezones', value=['Asia/Tokyo', 'Local time']) setSubField(fields, 'jp_end_date', key='timezones', value=['Asia/Tokyo', 'Local time']) setSubField(fields, 'ww_start_date', key='timezones', value=['UTC', 'Local time']) setSubField(fields, 'ww_end_date', key='timezones', value=['UTC', 'Local time']) setSubField(fields, 'tw_start_date', key='timezones', value=['Asia/Taipei', 'Local time']) setSubField(fields, 'tw_end_date', key='timezones', value=['Asia/Taipei', 'Local time']) setSubField(fields, 'kr_start_date', key='timezones', value=['Asia/Seoul', 'Local time']) setSubField(fields, 'kr_end_date', key='timezones', value=['Asia/Seoul', 'Local time']) setSubField(fields, 'cn_start_date', key='timezones', value=['UTC', 'Local time']) setSubField(fields, 'cn_end_date', key='timezones', value=['UTC', 'Local time']) return fields
def to_fields(self, item, order=None, extra_fields=None, exclude_fields=None, *args, **kwargs): if extra_fields is None: extra_fields = [] if exclude_fields is None: exclude_fields = [] if order is None: order = [] values = [] for fieldName, verbose_name in models.Idol.MEASUREMENT_DETAILS: value = getattr(item, fieldName) exclude_fields.append(fieldName) if value: values.append(mark_safe(u'<b>{}</b>: {} cm'.format(verbose_name, value))) if values: extra_fields.append(('measurements', { 'verbose_name': _('Measurements'), 'type': 'list', 'value': values, 'icon': 'measurements', })) if item.school is not None: exclude_fields.append('i_year') if item.birthday is not None: exclude_fields += ['age', 'i_astrological_sign'] exclude_fields.append('japanese_name') order = IDOL_ORDER + order fields = super(IdolCollection.ItemView, self).to_fields(item, *args, order=order, extra_fields=extra_fields, exclude_fields=exclude_fields, **kwargs) if item.birthday: if item.astrological_sign is not None: setSubField(fields, 'birthday', key='icon', value=None) setSubField(fields, 'birthday', key='image', value=staticImageURL(item.i_astrological_sign, folder='i_astrological_sign', extension='png')) if item.age: setSubField(fields, 'birthday', key='type', value='text_annotation') setSubField(fields, 'birthday', key='annotation', value=_('{age} years old').format(age=item.age)) if item.school and item.year: setSubField(fields, 'school', key='type', value='title_text') setSubField(fields, 'school', key='title', value=item.t_school) setSubField(fields, 'school', key='value', value='{}'.format(unicode(item.t_year))) setSubField(fields, 'description', key='type', value='long_text') if item.japanese_name: if get_language() == 'ja': setSubField(fields, 'name', key='value', value=item.japanese_name) else: setSubField(fields, 'name', key='type', value='text_annotation') setSubField(fields, 'name', key='annotation', value=item.japanese_name) return fields