mirror of
https://github.com/Damillora/Altessimo
synced 2024-11-23 22:27:32 +00:00
Do not add blank string artists and categories if comma-separated string is empty
This commit is contained in:
parent
c184dc3534
commit
2cc9a7bd31
@ -6,11 +6,13 @@ from django.utils.text import slugify
|
||||
class ArtistManager(models.Manager):
|
||||
def comma_to_qs(self, artists_str):
|
||||
final_ids = []
|
||||
for artist in artists_str.split(','):
|
||||
obj, created = self.get_or_create(romanized_name=artist.strip())
|
||||
final_ids.append(obj.id)
|
||||
qs = self.get_queryset().filter(id__in=final_ids).distinct()
|
||||
return qs
|
||||
if artists_str:
|
||||
for artist in artists_str.split(','):
|
||||
obj, created = self.get_or_create(romanized_name=artist.strip())
|
||||
final_ids.append(obj.id)
|
||||
qs = self.get_queryset().filter(id__in=final_ids).distinct()
|
||||
return qs
|
||||
return self.none()
|
||||
|
||||
class Artist(models.Model):
|
||||
name = models.CharField(max_length=255,blank=True)
|
||||
|
@ -14,11 +14,13 @@ class Branch(models.Model):
|
||||
class CategoryManager(models.Manager):
|
||||
def comma_to_qs(self, categories_str):
|
||||
final_ids = []
|
||||
for category in categories_str.split(','):
|
||||
obj, created = self.get_or_create(name=category.strip())
|
||||
final_ids.append(obj.id)
|
||||
qs = self.get_queryset().filter(id__in=final_ids).distinct()
|
||||
return qs
|
||||
if categories_str:
|
||||
for category in categories_str.split(','):
|
||||
obj, created = self.get_or_create(name=category.strip())
|
||||
final_ids.append(obj.id)
|
||||
qs = self.get_queryset().filter(id__in=final_ids).distinct()
|
||||
return qs
|
||||
return self.none()
|
||||
|
||||
class Category(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
|
Loading…
Reference in New Issue
Block a user