mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Change stuff
This commit is contained in:
parent
cfe09a7db2
commit
6e8d963f99
1 changed files with 14 additions and 7 deletions
|
@ -1,9 +1,9 @@
|
||||||
from typing import *
|
from typing import *
|
||||||
|
import datetime
|
||||||
import royalnet.constellation.api as rca
|
import royalnet.constellation.api as rca
|
||||||
import royalnet.utils as ru
|
import royalnet.utils as ru
|
||||||
from royalnet.backpack.tables import *
|
import royalnet.backpack.tables as rbt
|
||||||
from ..tables import *
|
from ..tables import *
|
||||||
import datetime
|
|
||||||
|
|
||||||
|
|
||||||
class ApiWikiStar(rca.ApiStar):
|
class ApiWikiStar(rca.ApiStar):
|
||||||
|
@ -39,11 +39,18 @@ class ApiWikiStar(rca.ApiStar):
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auth = {
|
||||||
|
"get": True,
|
||||||
|
"post": True,
|
||||||
|
"put": True,
|
||||||
|
"delete": True
|
||||||
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def default_view_role(self) -> str:
|
def default_view_role(self) -> str:
|
||||||
return self.config["wikipack"]["roles"]["view"]
|
return self.config["wikipack"]["roles"]["view"]
|
||||||
|
|
||||||
async def can_view(self, user: User, page: WikiPage) -> bool:
|
async def can_view(self, user: rbt.User, page: WikiPage) -> bool:
|
||||||
lr = page.latest_revision
|
lr = page.latest_revision
|
||||||
|
|
||||||
if lr.role_to_view == "":
|
if lr.role_to_view == "":
|
||||||
|
@ -59,7 +66,7 @@ class ApiWikiStar(rca.ApiStar):
|
||||||
def default_edit_role(self) -> str:
|
def default_edit_role(self) -> str:
|
||||||
return self.config["wikipack"]["roles"]["edit"]
|
return self.config["wikipack"]["roles"]["edit"]
|
||||||
|
|
||||||
async def can_edit(self, user: User, page: WikiPage) -> bool:
|
async def can_edit(self, user: rbt.User, page: WikiPage) -> bool:
|
||||||
lr = page.latest_revision
|
lr = page.latest_revision
|
||||||
|
|
||||||
if lr.role_to_edit == "":
|
if lr.role_to_edit == "":
|
||||||
|
@ -75,7 +82,7 @@ class ApiWikiStar(rca.ApiStar):
|
||||||
def create_role(self) -> str:
|
def create_role(self) -> str:
|
||||||
return self.config["wikipack"]["roles"]["create"]
|
return self.config["wikipack"]["roles"]["create"]
|
||||||
|
|
||||||
async def can_create(self, user: User) -> bool:
|
async def can_create(self, user: rbt.User) -> bool:
|
||||||
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
|
||||||
|
@ -84,7 +91,7 @@ class ApiWikiStar(rca.ApiStar):
|
||||||
def delete_role(self) -> str:
|
def delete_role(self) -> str:
|
||||||
return self.config["wikipack"]["roles"]["delete"]
|
return self.config["wikipack"]["roles"]["delete"]
|
||||||
|
|
||||||
async def can_delete(self, user: User) -> bool:
|
async def can_delete(self, user: rbt.User) -> bool:
|
||||||
if self.delete_role == "":
|
if self.delete_role == "":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue