Skip to content

Commit

Permalink
Make category slug field editable
Browse files Browse the repository at this point in the history
  • Loading branch information
bartjkdp committed Aug 5, 2023
1 parent 501e05f commit 130349d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
1 change: 0 additions & 1 deletion app/signals/apps/signals/admin/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class CategoryAdmin(admin.ModelAdmin):
inlines = (ServiceLevelObjectiveInline, CategoryDepartmentInline, StatusMessageCategoryInline)
fields = ('name', 'slug', 'parent', 'is_active', 'description', 'handling_message', 'public_name',
'is_public_accessible', 'icon',)
readonly_fields = ('slug',)
view_on_site = True

search_fields = ('name', 'public_name',)
Expand Down
6 changes: 1 addition & 5 deletions app/signals/apps/signals/models/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Category(TrackFields, models.Model):
null=True, blank=True)

# SIG-1135, the slug is auto populated using the django-extensions "AutoSlugField"
slug = AutoSlugField(populate_from=['name', ], blank=False, overwrite=False, editable=False)
slug = AutoSlugField(populate_from=['name', ], blank=False, overwrite=False, editable=True)

name = models.CharField(max_length=255)

Expand Down Expand Up @@ -185,10 +185,6 @@ def has_icon(self):
def clean(self):
super().clean()

if self.pk and self.slug:
if not Category.objects.filter(id=self.pk, slug=self.slug).exists():
raise ValidationError('Category slug cannot be changed')

if self.is_parent() and self.is_child() or self.is_child() and self.parent.is_child():
raise ValidationError('Category hierarchy can only go one level deep')

Expand Down

0 comments on commit 130349d

Please sign in to comment.