Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Photo collection #24

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0db2a3f
adding idol model to models.py
erys May 20, 2018
a82454f
Adding IdolCollection to magicollections.py
erys May 20, 2018
b4237f9
Making changes requested by db0
erys May 20, 2018
810a757
Merge branch 'idol-model' of https://github.com/MagiCircles/MajiLove …
erys May 20, 2018
48a33e0
fixing translated fields and commenting out things that are not relev…
erys May 20, 2018
7d4dec9
Adding Photo model, still missing "how to obtain field", will add aft…
erys May 20, 2018
51262f2
Adding basic form and slightly changing display nam for the small ima…
erys May 20, 2018
43eccd5
fixing typo: display_bloody_type -> display_blood_type
erys May 20, 2018
e21fe34
Merge branch 'idol-model' of https://github.com/MagiCircles/MajiLove …
erys May 20, 2018
11035e4
adding hobby as translated field to IdolCollection
erys May 20, 2018
16d270e
slightly modified japanese translation for locker skills
erys May 21, 2018
fcbee14
Merge branch 'master' of https://github.com/MagiCircles/MajiLove into…
erys May 21, 2018
efec8d9
missed a spot when merging
erys May 21, 2018
689a2da
Merge branch 'master' of https://github.com/MagiCircles/MajiLove into…
erys May 21, 2018
5865cac
fixing up photo model
erys May 26, 2018
6bf19d4
Added mic image and idols link to navbar
erys May 26, 2018
79e5a2f
fixed translated_fields
erys May 26, 2018
5ea2c6a
cannot figure out how to put astrological_signs into translated_field…
erys May 26, 2018
6bece87
fixing up some properties a little
erys May 26, 2018
60a1db4
fixing up leader skill functions
erys May 28, 2018
80520fb
Merge branch 'idol-collection' of https://github.com/MagiCircles/Maji…
erys May 28, 2018
6c1c8a7
adding photo collection
erys May 29, 2018
aadf3f7
Merge branch 'master' of https://github.com/MagiCircles/MajiLove into…
erys Jun 30, 2018
fd23c61
missed a bit when merging
erys Jun 30, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions majilove/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ class Meta(AutoForm.Meta):
model = models.Idol
fields = '__all__'
save_owner_on_creation = True

class PhotoForm(AutoForm):
class Meta(AutoForm.Meta):
model = models.Photo
fields = '__all__'
save_owner_on_creation = True
88 changes: 88 additions & 0 deletions majilove/magicollections.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.utils.translation import ugettext_lazy as _
from magi.magicollections import MagiCollection, ActivityCollection as _ActivityCollection, BadgeCollection as _BadgeCollection, StaffConfigurationCollection as _StaffConfigurationCollection, DonateCollection as _DonateCollection
from magi.default_settings import RAW_CONTEXT
from majilove import models, forms

############################################################
Expand Down Expand Up @@ -38,8 +39,95 @@ class IdolCollection(MagiCollection):
translated_fields = ('name', 'description', 'instrument', 'hometown', 'hobby')

form_class = forms.IdolForm
multipart = True

reportable = False
blockable = False

############################################################
# Photo Collection

PHOTO_STATS_FIELDS = [
u'{}{}'.format(_st, _sf) for _sf in [
'_min', '_single_copy_max', '_max_copy_max',
] for _st in [
'dance', 'vocal', 'charm', 'overall',
]
]

PHOTO_ICONS = {
'name': 'id',
'release_date': 'date',
}

PHOTO_IMAGES = {
'idol': 'mic',
}

PHOTOS_EXCLUDE = [
'i_skill_type', 'i_leader_skill_stat', 'leader_skill_percentage', 'skill_note_count', 'skill_percentage', 'i_sub_skill_type', 'sub_skill_amount', 'sub_skill_percentage',
] + [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you have it in 2 concatenated lists instead of a single list? 🤔

'image', 'image_special_shot', 'art', 'art_special_shot', 'transparent', 'transparent_special_shot', 'full_photo', 'full_photo_special_shot',
]


PHOTOS_ORDER = [
'id', 'name', 'idol', 'rarity', 'color', 'release_date', 'skill', 'sub_skill', 'images', 'full_photos', 'arts', 'transparents',
] + PHOTO_STATS_FIELDS

class PhotoCollection(MagiCollection):
queryset = models.Photo.objects.all()
title = _('Photo')
plural_title = _('Photos')
icon = 'cards'
navbar_title = _('Photos')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you don't need to specify the navbar title if it's the same as the plural title, it will just use it.

multipart = True
form_class = forms.PhotoForm

reportable = False
blockable = False
translated_fields = ('name', 'message_translation')

def to_fields(self, view, item, *args, **kwargs):
_photo_images = PHOTO_IMAGES.copy()
_photo_images.update({'color': '{static_url}img/color/{value}.png'.format(**{'value':item.color, 'static_url':RAW_CONTEXT['static_url']}),
'rarity': '{static_url}img/rarity/{value}.png'.format(**{'value':item.rarity, 'static_url':RAW_CONTEXT['static_url']})})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use staticImageURL in magi.utils here!

fields = super(PhotoCollection, self).to_fields(view, item, *args, icons=PHOTO_ICONS, images=_photo_images, **kwargs)
return fields

class ItemView(MagiCollection.ItemView):
def to_fields(self, item, extra_fields=None, exclude_fields=None, order=None, *args, **kwargs):
if extra_fields is None: extra_fields = []
if exclude_fields is None: exclude_fields = []
if order is None: order = PHOTOS_ORDER
exclude_fields += PHOTOS_EXCLUDE
extra_fields.append(('skill', {
'verbose_name': _('Skill'),
'icon': item.skill_icon,
'type': 'text',
'value': item.skill,
}))
extra_fields.append(('sub_skill', {
'verbose_name': _('Sub skill'),
'type': 'text',
'value': item.sub_skill,
}))
# Add images fields
for image, verbose_name in [('image', _('Icon')), ('art', _('Poster')), ('transparent', _('Transparent')), ('full_photo', (_('Photo')))]:
if getattr(item, image):
extra_fields.append((u'{}s'.format(image), {
'verbose_name': verbose_name,
'type': 'images',
'images': [{
'value': image_url,
'verbose_name': verbose_name,
} for image_url in [
getattr(item, u'{}_url'.format(image)),
getattr(item, u'{}_special_shot_url'.format(image)),
] if image_url],
'icon': 'pictures',
}))
return super(PhotoCollection.ItemView, self).to_fields(item, *args, extra_fields=extra_fields, exclude_fields=exclude_fields, order=order, **kwargs)


############################################################
3 changes: 1 addition & 2 deletions majilove/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class Photo(MagiModel):

message_text = models.TextField(string_concat(_('Message text'), ' (', _('Japanese') + ')'), max_length=500, null=True)
message_translation = models.TextField(_('Message translation'), max_length=500, null=True)
MESSAGE_TRANSLATIONs_CHOICES = ALL_ALT_LANGUAGES
MESSAGE_TRANSLATIONS_CHOICES = ALL_ALT_LANGUAGES
d_message_translations = models.TextField(_('Message translation'), null=True)
@property
def t_message_translation(self):
Expand Down Expand Up @@ -405,7 +405,6 @@ def japanese_skill(self):
skill_percentage = models.FloatField('{skill_percentage}', null=True)
skill_percentage_int = property(lambda _a: int(_a.skill_percentage))


# Subskills
SUB_SKILL_TYPES = OrderedDict([
('full_combo', {
Expand Down
Binary file added majilove/static/img/color/dream.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added majilove/static/img/color/shine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added majilove/static/img/color/star.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified majilove/static/img/mic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added majilove/static/img/rarity/N.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added majilove/static/img/rarity/R.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added majilove/static/img/rarity/SR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added majilove/static/img/rarity/UR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.