Commit c6d50802 authored by ibuler's avatar ibuler

[Bugfix] Fix perm name unique

parent f7fb36a1
......@@ -92,9 +92,6 @@ urlpatterns = [
url(r'^captcha/', include('captcha.urls')),
]
urlpatterns += app_view_patterns
# urlpatterns = wrapper_patterns_with_org(urlpatterns)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
......
......@@ -29,8 +29,7 @@ class AssetPermissionForm(OrgModelForm):
return
users_field = self.fields.get('users')
if hasattr(users_field, 'queryset'):
# users_field.queryset = User.objects.filter(orgs=current_org)
users_field.queryset = current_org.get_org_users().exclude(role=User.ROLE_APP)
users_field.queryset = current_org.get_org_users()
class Meta:
model = AssetPermission
......
......@@ -25,7 +25,7 @@ class AssetPermissionManager(OrgManager):
class AssetPermission(OrgModelMixin):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
name = models.CharField(max_length=128, unique=True, verbose_name=_('Name'))
name = models.CharField(max_length=128, verbose_name=_('Name'))
users = models.ManyToManyField('users.User', related_name='asset_permissions', blank=True, verbose_name=_("User"))
user_groups = models.ManyToManyField('users.UserGroup', related_name='asset_permissions', blank=True, verbose_name=_("User group"))
assets = models.ManyToManyField('assets.Asset', related_name='granted_by_permissions', blank=True, verbose_name=_("Asset"))
......@@ -40,6 +40,9 @@ class AssetPermission(OrgModelMixin):
objects = AssetPermissionManager.from_queryset(AssetPermissionQuerySet)()
class Meta:
unique_together = [('org_id', 'name')]
def __str__(self):
return self.name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment