create a user_can
method in template context, to check against user permissions
add user permissions list to template context
This commit is contained in:
parent
9c951f3864
commit
610a7898bb
@ -12,10 +12,11 @@ from atst.domain.workspaces import Workspaces
|
|||||||
from atst.domain.projects import Projects
|
from atst.domain.projects import Projects
|
||||||
from atst.forms.new_project import NewProjectForm
|
from atst.forms.new_project import NewProjectForm
|
||||||
from atst.forms.new_member import NewMemberForm
|
from atst.forms.new_member import NewMemberForm
|
||||||
|
from atst.domain.authz import Authorization
|
||||||
|
from atst.models.permissions import Permissions
|
||||||
|
|
||||||
bp = Blueprint("workspaces", __name__)
|
bp = Blueprint("workspaces", __name__)
|
||||||
|
|
||||||
|
|
||||||
@bp.context_processor
|
@bp.context_processor
|
||||||
def workspace():
|
def workspace():
|
||||||
workspace = None
|
workspace = None
|
||||||
@ -26,8 +27,17 @@ def workspace():
|
|||||||
)
|
)
|
||||||
except UnauthorizedError:
|
except UnauthorizedError:
|
||||||
pass
|
pass
|
||||||
return {"workspace": workspace}
|
|
||||||
|
|
||||||
|
def user_can(permission):
|
||||||
|
if workspace:
|
||||||
|
return Authorization.has_workspace_permission(g.current_user, workspace, permission)
|
||||||
|
return false
|
||||||
|
|
||||||
|
return {
|
||||||
|
"workspace": workspace,
|
||||||
|
"permissions": Permissions,
|
||||||
|
"user_can": user_can
|
||||||
|
}
|
||||||
|
|
||||||
@bp.route("/workspaces")
|
@bp.route("/workspaces")
|
||||||
def workspaces():
|
def workspaces():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user