Default ordering models and "full_title" for Song.

This commit is contained in:
Josh Washburne 2018-01-12 16:34:43 -05:00
parent 126c4684d9
commit d8379fe198

View file

@ -17,6 +17,9 @@ class Album(Disableable, Publishable, Timestampable, models.Model):
editable=False, editable=False,
max_length=255) max_length=255)
class Meta:
ordering = ['sorted_title', ]
def __str__(self): def __str__(self):
return self.title return self.title
@ -34,6 +37,9 @@ class Artist(Disableable, Publishable, Timestampable, models.Model):
editable=False, editable=False,
max_length=255) max_length=255)
class Meta:
ordering = ['sorted_full_name', ]
@property @property
def full_name(self): def full_name(self):
if not self.alias: if not self.alias:
@ -61,6 +67,9 @@ class Game(Disableable, Publishable, Timestampable, models.Model):
editable=False, editable=False,
max_length=255) max_length=255)
class Meta:
ordering = ['sorted_title', ]
def __str__(self): def __str__(self):
return self.title return self.title
@ -110,7 +119,11 @@ class Song(Disableable, Publishable, Timestampable, models.Model):
objects = models.Manager() objects = models.Manager()
music = SongManager() music = SongManager()
def __str__(self): class Meta:
ordering = ['sorted_title', ]
@property
def full_title(self):
if self.song_type == 'J': if self.song_type == 'J':
return self.title return self.title
else: else:
@ -118,3 +131,6 @@ class Song(Disableable, Publishable, Timestampable, models.Model):
return '{} - {} ({})'.format(self.game.title, return '{} - {} ({})'.format(self.game.title,
self.title, self.title,
all_artists) all_artists)
def __str__(self):
return self.title