Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
45b8a953
Commit
45b8a953
authored
May 24, 2015
by
Petrus J.v.Rensburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Override default flask-security templates.
parent
b5833775
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
88 additions
and
1 deletion
+88
-1
app.py
examples/auth/app.py
+11
-1
_macros.html
examples/auth/templates/security/_macros.html
+16
-0
_menu.html
examples/auth/templates/security/_menu.html
+15
-0
_messages.html
examples/auth/templates/security/_messages.html
+9
-0
login_user.html
examples/auth/templates/security/login_user.html
+18
-0
register_user.html
examples/auth/templates/security/register_user.html
+19
-0
No files found.
examples/auth/app.py
View file @
45b8a953
...
@@ -6,7 +6,7 @@ from flask_security import Security, SQLAlchemyUserDatastore, \
...
@@ -6,7 +6,7 @@ from flask_security import Security, SQLAlchemyUserDatastore, \
from
flask_security.utils
import
encrypt_password
from
flask_security.utils
import
encrypt_password
import
flask_admin
as
admin
import
flask_admin
as
admin
from
flask_admin.contrib
import
sqla
from
flask_admin.contrib
import
sqla
from
sqlalchemy
import
event
from
flask_admin
import
helpers
as
admin_helpers
# Create Flask application
# Create Flask application
...
@@ -82,6 +82,16 @@ admin = admin.Admin(app, 'Example: Auth', base_template='my_master.html')
...
@@ -82,6 +82,16 @@ admin = admin.Admin(app, 'Example: Auth', base_template='my_master.html')
admin
.
add_view
(
MyModelView
(
Role
,
db
.
session
))
admin
.
add_view
(
MyModelView
(
Role
,
db
.
session
))
admin
.
add_view
(
MyModelView
(
User
,
db
.
session
))
admin
.
add_view
(
MyModelView
(
User
,
db
.
session
))
# define a context processor for merging flask-admin's template context into the
# flask-security views.
@
security
.
context_processor
def
security_context_processor
():
return
dict
(
admin_base_template
=
admin
.
base_template
,
admin_view
=
admin
.
index_view
,
h
=
admin_helpers
,
)
def
build_sample_db
():
def
build_sample_db
():
"""
"""
...
...
examples/auth/templates/security/_macros.html
0 → 100644
View file @
45b8a953
{% macro render_field_with_errors(field) %}
<p>
{{ field.label }} {{ field(**kwargs)|safe }}
{% if field.errors %}
<ul>
{% for error in field.errors %}
<li>
{{ error }}
</li>
{% endfor %}
</ul>
{% endif %}
</p>
{% endmacro %}
{% macro render_field(field) %}
<p>
{{ field(**kwargs)|safe }}
</p>
{% endmacro %}
\ No newline at end of file
examples/auth/templates/security/_menu.html
0 → 100644
View file @
45b8a953
{% if security.registerable or security.recoverable or security.confirmable %}
<h2>
Menu
</h2>
<ul>
<li><a
href=
"{{ url_for_security('login') }}{% if 'next' in request.args %}?next={{ request.args.next|urlencode }}{% endif %}"
>
Login
</a></li>
{% if security.registerable %}
<li><a
href=
"{{ url_for_security('register') }}{% if 'next' in request.args %}?next={{ request.args.next|urlencode }}{% endif %}"
>
Register
</a><br/></li>
{% endif %}
{% if security.recoverable %}
<li><a
href=
"{{ url_for_security('forgot_password') }}"
>
Forgot password
</a><br/></li>
{% endif %}
{% if security.confirmable %}
<li><a
href=
"{{ url_for_security('send_confirmation') }}"
>
Confirm account
</a></li>
{% endif %}
</ul>
{% endif %}
examples/auth/templates/security/_messages.html
0 → 100644
View file @
45b8a953
{%- with messages = get_flashed_messages(with_categories=true) -%}
{% if messages %}
<ul
class=
"flashes"
>
{% for category, message in messages %}
<li
class=
"{{ category }}"
>
{{ message }}
</li>
{% endfor %}
</ul>
{% endif %}
{%- endwith %}
\ No newline at end of file
examples/auth/templates/security/login_user.html
0 → 100644
View file @
45b8a953
{% extends 'admin/master.html' %}
{% from "security/_macros.html" import render_field_with_errors, render_field %}
{% include "security/_messages.html" %}
{% block body %}
{{ super() }}
<div
class=
"row-fluid"
>
<h1>
Login
</h1>
<form
action=
"{{ url_for_security('login') }}"
method=
"POST"
name=
"login_user_form"
>
{{ login_user_form.hidden_tag() }}
{{ render_field_with_errors(login_user_form.email) }}
{{ render_field_with_errors(login_user_form.password) }}
{{ render_field_with_errors(login_user_form.remember) }}
{{ render_field(login_user_form.next) }}
{{ render_field(login_user_form.submit, class="btn btn-primary") }}
</form>
{% include "security/_menu.html" %}
</div>
{% endblock body %}
\ No newline at end of file
examples/auth/templates/security/register_user.html
0 → 100644
View file @
45b8a953
{% extends 'admin/master.html' %}
{% from "security/_macros.html" import render_field_with_errors, render_field %}
{% include "security/_messages.html" %}
{% block body %}
{{ super() }}
<div
class=
"row-fluid"
>
<h1>
Register
</h1>
<form
action=
"{{ url_for_security('register') }}"
method=
"POST"
name=
"register_user_form"
>
{{ register_user_form.hidden_tag() }}
{{ render_field_with_errors(register_user_form.email) }}
{{ render_field_with_errors(register_user_form.password) }}
{% if register_user_form.password_confirm %}
{{ render_field_with_errors(register_user_form.password_confirm) }}
{% endif %}
{{ render_field(register_user_form.submit, class="btn btn-primary") }}
</form>
{% include "security/_menu.html" %}
</div>
{% endblock body %}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment