1
0
mirror of https://github.com/Damillora/Altessimo synced 2024-11-24 14:47:33 +00:00
Altessimo/idols/models.py

34 lines
1.1 KiB
Python
Raw Normal View History

2021-07-09 18:25:07 +00:00
from django.db import models
# Create your models here.
# Create your models here.
class IdolManager(models.Manager):
def comma_to_qs(self, idols_str):
final_ids = []
if idols_str:
for idol in idols_str.split(','):
obj, created = self.get_or_create(romanized_name=idol.strip())
final_ids.append(obj.id)
qs = self.get_queryset().filter(id__in=final_ids).distinct()
return qs
return self.none()
class Idol(models.Model):
branch = models.ForeignKey("categories.Branch", on_delete=models.PROTECT)
name = models.CharField(max_length=255, blank=True)
romanized_name = models.CharField(max_length=255)
voice_actor_name = models.CharField(max_length=255, blank=True)
romanized_voice_actor_name = models.CharField(max_length=255, blank=True)
objects = IdolManager()
2021-07-09 18:48:51 +00:00
class Meta:
ordering = [ 'romanized_name','name' ]
2021-07-09 18:25:07 +00:00
def __str__(self):
2021-07-09 18:48:51 +00:00
return self.romanized_name+" "+"["+self.branch.acronym+"] "+" (CV: "+self.romanized_voice_actor_name+")"