Skip to content

Commit

Permalink
start
Browse files Browse the repository at this point in the history
  • Loading branch information
jzbahrai committed Jan 20, 2025
1 parent dbd5e6e commit eb56118
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/main/views/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def create_template(service_id, template_type="all", template_folder_id=None):
@main.route("/services/<service_id>/templates/copy/from-service/<uuid:from_service>")
@main.route("/services/<service_id>/templates/copy/from-service/<uuid:from_service>/from-folder/<uuid:from_folder>")
@main.route("/services/<service_id>/templates/all/folders/<uuid:from_folder>/copy")
@user_has_permissions("manage_templates")
# @user_has_permissions("manage_templates")
def choose_template_to_copy(
service_id,
from_service=None,
Expand All @@ -585,7 +585,7 @@ def choose_template_to_copy(
template_folder_path=service.get_template_folder_path(from_folder),
from_service=service,
search_form=SearchByNameForm(),
example_service_templates=TemplateList(example_service),
example_service=TemplateList(example_service),
)

else:
Expand Down
2 changes: 2 additions & 0 deletions app/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ def belongs_to_service(self, service_id):
return str(service_id) in self.service_ids

def belongs_to_service_or_403(self, service_id):
if service_id == "66a4ae1b-653f-4699-8675-fe86e6b147e7":
return
if not self.belongs_to_service(service_id):
abort(403)

Expand Down
2 changes: 1 addition & 1 deletion app/templates/views/templates/copy.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1 class="heading-large">{{ _('Copy an existing template') }} {{ _("into") }} {
{{ copy_folder_path(template_folder_path, current_service.id, from_service, current_user) }}
</div>
<h1 class="heading-medium">{{ _('Example Service') }}</h1>
{% for item in example_service_templates %}
{% for item in example_service %}
<div class="template-list-item {% if item.ancestors %}template-list-item-hidden-by-default{% endif %} {% if not item.ancestors %}template-list-item-without-ancestors{% endif %}">
<h2 class="message-name">
{% for ancestor in item.ancestors %}
Expand Down
3 changes: 3 additions & 0 deletions app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ def wrap_func(*args, **kwargs):
if not current_user.is_authenticated:
return current_app.login_manager.unauthorized()

if current_user.has_permissions(*permissions, **permission_kwargs):
return func(*args, **kwargs)

service_id = kwargs.get("service_id") or request.view_args.get("service_id")
if service_id == "66a4ae1b-653f-4699-8675-fe86e6b147e7":
if request.method in ["GET", "HEAD", "OPTIONS"]:
Expand Down

0 comments on commit eb56118

Please sign in to comment.