mirror of
https://github.com/daniviga/django-ram.git
synced 2025-12-26 15:28:31 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
c81508bbd5
|
@@ -175,7 +175,12 @@ class RollingStock(BaseModel):
|
||||
def clean(self, *args, **kwargs):
|
||||
if self.featured:
|
||||
MAX = settings.FEATURED_ITEMS_MAX
|
||||
if RollingStock.objects.filter(featured=True).count() > MAX - 1:
|
||||
featured_count = (
|
||||
RollingStock.objects.filter(featured=True)
|
||||
.exclude(uuid=self.uuid)
|
||||
.count()
|
||||
)
|
||||
if featured_count > MAX - 1:
|
||||
raise ValidationError(
|
||||
"There are already {} featured items".format(MAX)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user