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):
|
class ArtistManager(models.Manager):
|
||||||
def comma_to_qs(self, artists_str):
|
def comma_to_qs(self, artists_str):
|
||||||
final_ids = []
|
final_ids = []
|
||||||
for artist in artists_str.split(','):
|
if artists_str:
|
||||||
obj, created = self.get_or_create(romanized_name=artist.strip())
|
for artist in artists_str.split(','):
|
||||||
final_ids.append(obj.id)
|
obj, created = self.get_or_create(romanized_name=artist.strip())
|
||||||
qs = self.get_queryset().filter(id__in=final_ids).distinct()
|
final_ids.append(obj.id)
|
||||||
return qs
|
qs = self.get_queryset().filter(id__in=final_ids).distinct()
|
||||||
|
return qs
|
||||||
|
return self.none()
|
||||||
|
|
||||||
class Artist(models.Model):
|
class Artist(models.Model):
|
||||||
name = models.CharField(max_length=255,blank=True)
|
name = models.CharField(max_length=255,blank=True)
|
||||||
|
@ -14,11 +14,13 @@ class Branch(models.Model):
|
|||||||
class CategoryManager(models.Manager):
|
class CategoryManager(models.Manager):
|
||||||
def comma_to_qs(self, categories_str):
|
def comma_to_qs(self, categories_str):
|
||||||
final_ids = []
|
final_ids = []
|
||||||
for category in categories_str.split(','):
|
if categories_str:
|
||||||
obj, created = self.get_or_create(name=category.strip())
|
for category in categories_str.split(','):
|
||||||
final_ids.append(obj.id)
|
obj, created = self.get_or_create(name=category.strip())
|
||||||
qs = self.get_queryset().filter(id__in=final_ids).distinct()
|
final_ids.append(obj.id)
|
||||||
return qs
|
qs = self.get_queryset().filter(id__in=final_ids).distinct()
|
||||||
|
return qs
|
||||||
|
return self.none()
|
||||||
|
|
||||||
class Category(models.Model):
|
class Category(models.Model):
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
|
Loading…
Reference in New Issue
Block a user