Fix organization create
This commit is contained in:
parent
124764bee3
commit
9c750ba6d0
1 changed files with 6 additions and 5 deletions
|
@ -5,7 +5,7 @@ from django.db import models
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
from django.utils.text import slugify
|
from django.utils.text import slugify
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django_scopes import ScopedManager
|
from django_scopes import ScopedManager, scopes_disabled
|
||||||
|
|
||||||
from servala.core import rules as perms
|
from servala.core import rules as perms
|
||||||
from servala.core.models.mixins import ServalaModelMixin
|
from servala.core.models.mixins import ServalaModelMixin
|
||||||
|
@ -47,10 +47,11 @@ class Organization(ServalaModelMixin, models.Model):
|
||||||
return self.urls.base
|
return self.urls.base
|
||||||
|
|
||||||
def set_owner(self, user):
|
def set_owner(self, user):
|
||||||
OrganizationMembership.objects.filter(user=user, organization=self).delete()
|
with scopes_disabled():
|
||||||
OrganizationMembership.objects.create(
|
OrganizationMembership.objects.filter(user=user, organization=self).delete()
|
||||||
user=user, organization=self, role=OrganizationRole.OWNER
|
OrganizationMembership.objects.create(
|
||||||
)
|
user=user, organization=self, role=OrganizationRole.OWNER
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_organization(cls, instance, owner):
|
def create_organization(cls, instance, owner):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue