0004-rbac-perform-soft-deletion-of-roleparenting-pairings.patch
src/django_rbac/models.py | ||
---|---|---|
193 | 193 | |
194 | 194 |
def add_child(self, child): |
195 | 195 |
RoleParenting = utils.get_role_parenting_model() |
196 |
RoleParenting.objects.get_or_create(parent=self, child=child) |
|
196 |
rp, dummy = RoleParenting.objects.get_or_create(parent=self, child=child) |
|
197 |
rp.soft_create() |
|
197 | 198 | |
198 | 199 |
def remove_child(self, child): |
199 | 200 |
RoleParenting = utils.get_role_parenting_model() |
200 |
RoleParenting.objects.filter(parent=self, child=child, direct=True).delete() |
|
201 |
for rp in RoleParenting.objects.filter(parent=self, child=child, direct=True): |
|
202 |
rp.soft_delete() |
|
201 | 203 | |
202 | 204 |
def add_parent(self, parent): |
203 | 205 |
RoleParenting = utils.get_role_parenting_model() |
204 |
RoleParenting.objects.get_or_create(parent=parent, child=self) |
|
206 |
rp, dummy = RoleParenting.objects.get_or_create(parent=parent, child=self) |
|
207 |
rp.soft_create() |
|
205 | 208 | |
206 | 209 |
def remove_parent(self, parent): |
207 | 210 |
RoleParenting = utils.get_role_parenting_model() |
208 |
RoleParenting.objects.filter(child=self, parent=parent, direct=True).delete() |
|
211 |
for rp in RoleParenting.objects.filter(child=self, parent=parent, direct=True): |
|
212 |
rp.soft_delete() |
|
209 | 213 | |
210 | 214 |
def parents(self, include_self=True, annotate=False): |
211 | 215 |
return self.__class__.objects.filter(pk=self.pk).parents(include_self=include_self, annotate=annotate) |
212 |
- |