some fixes on roles service
parent
b2fa4672b4
commit
7393ecbf03
|
@ -5,6 +5,7 @@ from django.dispatch import receiver
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.contrib.auth.models import UserManager, AbstractUser
|
from django.contrib.auth.models import UserManager, AbstractUser
|
||||||
|
|
||||||
|
from taiga.base.utils.slug import slugify_uniquely
|
||||||
from taiga.base.notifications.models import WatcherMixin
|
from taiga.base.notifications.models import WatcherMixin
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,6 +54,12 @@ class Role(models.Model):
|
||||||
related_name="roles", verbose_name=_("project"))
|
related_name="roles", verbose_name=_("project"))
|
||||||
computable = models.BooleanField(default=True)
|
computable = models.BooleanField(default=True)
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
if not self.slug:
|
||||||
|
self.slug = slugify_uniquely(self.name, self.__class__)
|
||||||
|
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "role"
|
verbose_name = "role"
|
||||||
verbose_name_plural = "roles"
|
verbose_name_plural = "roles"
|
||||||
|
|
|
@ -168,4 +168,4 @@ class ProjectDetailSerializer(ProjectSerializer):
|
||||||
class RoleSerializer(serializers.ModelSerializer):
|
class RoleSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Role
|
model = Role
|
||||||
fields = ('id', 'name', 'slug', 'permissions', 'computable')
|
fields = ('id', 'name', 'permissions', 'computable', 'project', 'order')
|
||||||
|
|
Loading…
Reference in New Issue