oshipka/vm_gen/templates/routes_py

48 lines
1.8 KiB
Plaintext
Raw Normal View History

2020-06-05 12:38:25 +02:00
"""
!!!AUTOGENERATED: DO NOT EDIT!!!
Edit the hooks in webapp/routes/[[ name|camel_to_snake ]]_hooks.py instead
"""
2021-05-10 00:22:29 +02:00
from flask import render_template
from flask_security import login_required
2020-06-05 12:38:25 +02:00
from oshipka.webapp import app
from oshipka.webapp.views import ModelView
from webapp.routes.[[ name|camel_to_snake ]]_hooks import *
2021-05-09 14:44:11 +02:00
[%- if name == "User" %]
from webapp.models import [[ name ]]
[[ name|camel_to_snake ]] = ModelView(app, [[name]])
[%- else %]
from webapp.models import [[ name ]], [[ name ]]Acl
2020-06-05 12:38:25 +02:00
2021-05-08 20:53:50 +02:00
[[ name|camel_to_snake ]] = ModelView(app, [[name]], [[ name ]]Acl)
2021-05-09 14:44:11 +02:00
[%- endif %]
2020-06-25 14:28:20 +02:00
[% for verb, verb_values in _verbs.items() %]
[[ name|camel_to_snake ]].register_verb(view_context=[[ verb ]]_view_context,
verb="[[ verb ]]",
methods=[[ verb_values.methods ]],
per_item=[[ verb_values.per_item ]],
is_login_required=[[ verb_values.is_login_required if verb_values.is_login_required else 'False' ]],
the_roles_required=[[ verb_values.the_roles_required if verb_values.the_roles_required else '[]' ]],
)
[% endfor %]
2021-05-10 00:22:29 +02:00
@app.route("/[[ name|camel_to_snake|pluralize ]]/permissions")
@login_required
def [[ name|camel_to_snake ]]_model_permissions():
return render_template("[[ name|camel_to_snake ]]/permissions_model.html")
@app.route("/[[ name|camel_to_snake|pluralize ]]/<int:instance_id>/permissions")
@login_required
def [[ name|camel_to_snake ]]_instance_permissions(instance_id):
instance = [[ name ]].query.filter_by(id=instance_id).first()
if not instance:
abort(404)
return render_template("[[ name|camel_to_snake ]]/permissions_instance.html", instance=instance)