mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
__magic__
This commit is contained in:
parent
e6ebee3c6a
commit
f57ec497a0
2 changed files with 21 additions and 12 deletions
|
@ -11,8 +11,6 @@ class ApiWikiStar(rca.ApiStar):
|
||||||
|
|
||||||
tags = ["wiki"]
|
tags = ["wiki"]
|
||||||
|
|
||||||
methods = ["GET", "POST", "PUT", "DELETE"]
|
|
||||||
|
|
||||||
parameters = {
|
parameters = {
|
||||||
"get": {
|
"get": {
|
||||||
"page_id": "The id of the wiki page to get the details of."
|
"page_id": "The id of the wiki page to get the details of."
|
||||||
|
@ -62,11 +60,12 @@ class ApiWikiStar(rca.ApiStar):
|
||||||
if lr.role_to_view == "*":
|
if lr.role_to_view == "*":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if lr.role_to_view:
|
if user is None:
|
||||||
|
return False
|
||||||
|
|
||||||
if lr.role_to_view in user.roles or self.admin_role in user.roles:
|
if lr.role_to_view in user.roles or self.admin_role in user.roles:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def default_edit_role(self) -> str:
|
def default_edit_role(self) -> str:
|
||||||
|
@ -76,11 +75,12 @@ class ApiWikiStar(rca.ApiStar):
|
||||||
if lr.role_to_edit == "*":
|
if lr.role_to_edit == "*":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if lr.role_to_edit:
|
if user is None:
|
||||||
|
return False
|
||||||
|
|
||||||
if lr.role_to_edit in user.roles or self.admin_role in user.roles:
|
if lr.role_to_edit in user.roles or self.admin_role in user.roles:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def create_role(self) -> str:
|
def create_role(self) -> str:
|
||||||
|
@ -90,6 +90,9 @@ class ApiWikiStar(rca.ApiStar):
|
||||||
if self.create_role == "*":
|
if self.create_role == "*":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
if user is None:
|
||||||
|
return False
|
||||||
|
|
||||||
if self.create_role in user.roles or self.admin_role in user.roles:
|
if self.create_role in user.roles or self.admin_role in user.roles:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -102,6 +105,9 @@ class ApiWikiStar(rca.ApiStar):
|
||||||
if self.delete_role == "*":
|
if self.delete_role == "*":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
if user is None:
|
||||||
|
return False
|
||||||
|
|
||||||
if self.delete_role in user.roles or self.admin_role in user.roles:
|
if self.delete_role in user.roles or self.admin_role in user.roles:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -128,6 +134,7 @@ class ApiWikiStar(rca.ApiStar):
|
||||||
|
|
||||||
return lr
|
return lr
|
||||||
|
|
||||||
|
@rca.magic
|
||||||
async def get(self, data: rca.ApiData) -> ru.JSON:
|
async def get(self, data: rca.ApiData) -> ru.JSON:
|
||||||
"""Get the details of a specific Wiki page."""
|
"""Get the details of a specific Wiki page."""
|
||||||
lr = await self.find_lr(data)
|
lr = await self.find_lr(data)
|
||||||
|
@ -142,6 +149,7 @@ class ApiWikiStar(rca.ApiStar):
|
||||||
|
|
||||||
return lr.json()
|
return lr.json()
|
||||||
|
|
||||||
|
@rca.magic
|
||||||
async def post(self, data: rca.ApiData) -> ru.JSON:
|
async def post(self, data: rca.ApiData) -> ru.JSON:
|
||||||
"""Create a new Wiki page."""
|
"""Create a new Wiki page."""
|
||||||
WikiRevisionT = self.alchemy.get(WikiRevision)
|
WikiRevisionT = self.alchemy.get(WikiRevision)
|
||||||
|
@ -177,6 +185,7 @@ class ApiWikiStar(rca.ApiStar):
|
||||||
|
|
||||||
return nr.json()
|
return nr.json()
|
||||||
|
|
||||||
|
@rca.magic
|
||||||
async def put(self, data: rca.ApiData) -> ru.JSON:
|
async def put(self, data: rca.ApiData) -> ru.JSON:
|
||||||
"""Edit a specific Wiki page, creating a new revision."""
|
"""Edit a specific Wiki page, creating a new revision."""
|
||||||
WikiRevisionT = self.alchemy.get(WikiRevision)
|
WikiRevisionT = self.alchemy.get(WikiRevision)
|
||||||
|
@ -215,6 +224,7 @@ class ApiWikiStar(rca.ApiStar):
|
||||||
|
|
||||||
return nr.json()
|
return nr.json()
|
||||||
|
|
||||||
|
@rca.magic
|
||||||
async def delete(self, data: rca.ApiData) -> ru.JSON:
|
async def delete(self, data: rca.ApiData) -> ru.JSON:
|
||||||
"""Delete a specific Wiki page and all its revisions."""
|
"""Delete a specific Wiki page and all its revisions."""
|
||||||
WikiRevisionT = self.alchemy.get(WikiRevision)
|
WikiRevisionT = self.alchemy.get(WikiRevision)
|
||||||
|
|
|
@ -12,8 +12,6 @@ class ApiWikiListStar(rca.ApiStar):
|
||||||
|
|
||||||
tags = ["wiki"]
|
tags = ["wiki"]
|
||||||
|
|
||||||
methods = ["GET"]
|
|
||||||
|
|
||||||
parameters = {
|
parameters = {
|
||||||
"get": {},
|
"get": {},
|
||||||
}
|
}
|
||||||
|
@ -22,6 +20,7 @@ class ApiWikiListStar(rca.ApiStar):
|
||||||
"get": False,
|
"get": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@rca.magic
|
||||||
async def get(self, data: rca.ApiData) -> ru.JSON:
|
async def get(self, data: rca.ApiData) -> ru.JSON:
|
||||||
"""Get the details of a specific Wiki page."""
|
"""Get the details of a specific Wiki page."""
|
||||||
WikiRevisionT = self.alchemy.get(WikiRevision)
|
WikiRevisionT = self.alchemy.get(WikiRevision)
|
||||||
|
|
Loading…
Reference in a new issue