Skip to content

Commit

Permalink
New Better operations
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Jun 18, 2019
1 parent 7bb899f commit 60c7e56
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/appier_extras/parts/admin/models/role.py
Expand Up @@ -162,13 +162,24 @@ def duplicate_s(self, suffix = "-new"):
role.save()
return role

@appier.operation(
name = "Set Parent",
parameters = (("Name", "name", str),)
)
def set_parent_s(self, name):
cls = self.__class__
parent = cls.get(name = name)
if self in parent.children: return
parent.children.append(self)
parent.save()

@appier.operation(
name = "Add Child",
parameters = (("Name", "name", str),)
)
def add_child_s(self, name):
cls = self.__class__
role = cls.get(name = name)
if role in self.children: return
self.children.append(role)
child = cls.get(name = name)
if child in self.children: return
self.children.append(child)
self.save()

0 comments on commit 60c7e56

Please sign in to comment.