|
1 | 1 | # -*- coding: utf-8 -*-
|
2 | 2 | from collections import OrderedDict
|
3 | 3 | from django.utils.translation import ugettext_lazy as _, string_concat, get_language
|
| 4 | +from django.core.validators import MaxValueValidator, MinValueValidator |
4 | 5 | from django.db import models
|
5 | 6 | from django.conf import settings as django_settings
|
6 | 7 | from magi.models import User, uploadItem
|
@@ -492,3 +493,63 @@ def __unicode__(self):
|
492 | 493 | name=self.t_name,
|
493 | 494 | )
|
494 | 495 | return u''
|
| 496 | + |
| 497 | +############################################################ |
| 498 | +# Songs |
| 499 | + |
| 500 | +class Song(MagiModel): |
| 501 | + collection_name = 'song' |
| 502 | + |
| 503 | + owner = models.ForeignKey(User, related_name='added_songs') |
| 504 | + |
| 505 | + name = models.CharField(string_concat(_('Title'), ' (', _('Translation'), ')'), max_length=100, null=True) |
| 506 | + japanese_name = models.CharField(_('Title'), max_length=100, null=True) |
| 507 | + NAMES_CHOICES = ALL_ALT_LANGUAGES |
| 508 | + d_names = models.TextField(_('Title'), null=True) |
| 509 | + @property |
| 510 | + def t_name(self): |
| 511 | + if get_language() == 'ja': return self.japanese_name |
| 512 | + return self.names.get(get_language(), self.name) |
| 513 | + |
| 514 | + image = models.ImageField('Album cover', upload_to=uploadItem('song'), null=True) |
| 515 | + |
| 516 | + composer = models.CharField(_('Composer'), max_length=100, null=True) |
| 517 | + COMPOSERS_CHOICES = LANGUAGES_NEED_OWN_NAME |
| 518 | + d_composers = models.TextField(_('Composer'), null=True) |
| 519 | + lyricist = models.CharField(_('Lyricist'), max_length=100, null=True) |
| 520 | + LYRICISTS_CHOICES = LANGUAGES_NEED_OWN_NAME |
| 521 | + d_lyricists = models.TextField(_('Lyricist'), null=True) |
| 522 | + arranger = models.CharField(_('Arranger'), max_length=100, null=True) |
| 523 | + ARRANGERS_CHOICES = LANGUAGES_NEED_OWN_NAME |
| 524 | + d_arrangers = models.TextField(_('Arranger'), null=True) |
| 525 | + |
| 526 | + singers = models.ManyToManyField(Idol, related_name="sung_songs", verbose_name=_('Singers')) |
| 527 | + |
| 528 | + COLOR_CHOICES = Photo.COLOR_CHOICES |
| 529 | + i_color = models.PositiveIntegerField(_('Color'), choices=i_choices(COLOR_CHOICES)) |
| 530 | + |
| 531 | + DIFFICULTY_VALIDATORS = [ |
| 532 | + MinValueValidator(1), |
| 533 | + MaxValueValidator(13), |
| 534 | + ] |
| 535 | + |
| 536 | + easy_notes = models.PositiveIntegerField(string_concat(_('Easy'), ' - ', _('Notes')), null=True) |
| 537 | + easy_difficulty = models.PositiveIntegerField(string_concat(_('Easy'), ' - ', _('Difficulty')), validators=DIFFICULTY_VALIDATORS, null=True) |
| 538 | + normal_notes = models.PositiveIntegerField(string_concat(_('Normal'), ' - ', _('Notes')), null=True) |
| 539 | + normal_difficulty = models.PositiveIntegerField(string_concat(_('Normal'), ' - ', _('Difficulty')), validators=DIFFICULTY_VALIDATORS, null=True) |
| 540 | + hard_notes = models.PositiveIntegerField(string_concat(_('Hard'), ' - ', _('Notes')), null=True) |
| 541 | + hard_difficulty = models.PositiveIntegerField(string_concat(_('Hard'), ' - ', _('Difficulty')), validators=DIFFICULTY_VALIDATORS, null=True) |
| 542 | + pro_notes = models.PositiveIntegerField(string_concat(_('Pro'), ' - ', _('Notes')), null=True) |
| 543 | + pro_difficulty = models.PositiveIntegerField(string_concat(_('Pro'), ' - ', _('Difficulty')), validators=DIFFICULTY_VALIDATORS, null=True) |
| 544 | + |
| 545 | + length = models.PositiveIntegerField(_('Length'), null=True) |
| 546 | + |
| 547 | + # just going to have unlock method for regular permanent songs for now |
| 548 | + unlock_chapter = models.CharField(_('Unlock Chapter'), max_length=100, null=True) |
| 549 | + UNLOCK_CHAPTERS_CHOICES = ALL_ALT_LANGUAGES |
| 550 | + d_unlock_chapters = models.TextField(_('Unlock Chapter'), null=True) |
| 551 | + |
| 552 | + #TODO: other unlock methods |
| 553 | + |
| 554 | + def __unicode__(self): |
| 555 | + return unicode(self.t_name) |
0 commit comments