*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Verified Commit df8ab36d authored by Tsepelakis, Sotirios's avatar Tsepelakis, Sotirios 🎯
Browse files

Views: add status code in guards

parent 4c47c44f
No related branches found
No related tags found
1 merge request!80Add test cases
......@@ -51,8 +51,9 @@ def fetch_schemaorg_jsonld(doi_url):
def guarded_deposit_create(*args, **kwargs):
"""Guard the creation page for records, based on permissions."""
if not rec_service.check_permission(g.identity, "create"):
return render_template(
"invenio_theme_tuw/guards/deposit.html", user=current_user
return (
render_template("invenio_theme_tuw/guards/deposit.html", user=current_user),
403,
)
return deposit_create(*args, **kwargs)
......@@ -67,8 +68,9 @@ def guarded_deposit_edit(*args, **kwargs):
kwargs["pid_value"], registered_only=False
)
if not rec_service.check_permission(g.identity, "update_draft", record=draft):
return render_template(
"invenio_theme_tuw/guards/deposit.html", user=current_user
return (
render_template("invenio_theme_tuw/guards/deposit.html", user=current_user),
403,
)
return deposit_edit(*args, **kwargs)
......@@ -78,8 +80,11 @@ def guarded_deposit_edit(*args, **kwargs):
def guarded_communities_create(*args, **kwargs):
"""Guard the communities creation page, based on permissions."""
if not current_communities.service.check_permission(g.identity, "create"):
return render_template(
"invenio_theme_tuw/guards/community.html", user=current_user
return (
render_template(
"invenio_theme_tuw/guards/community.html", user=current_user
),
403,
)
return communities_new(*args, **kwargs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment