Commit e6baed0c authored by Paul Brown's avatar Paul Brown

move request.args.get('modal') into base, only use 'modal' in templates

parent 353e644e
...@@ -661,7 +661,8 @@ class FileAdmin(BaseView, ActionsMixin): ...@@ -661,7 +661,8 @@ class FileAdmin(BaseView, ActionsMixin):
flash(gettext('Failed to save file: %(error)s', error=ex), 'error') flash(gettext('Failed to save file: %(error)s', error=ex), 'error')
return self.render(self.upload_template, form=form, return self.render(self.upload_template, form=form,
header_text=gettext('Upload File')) header_text=gettext('Upload File'),
modal=request.args.get('modal'))
@expose('/download/<path:path>') @expose('/download/<path:path>')
def download(self, path=None): def download(self, path=None):
...@@ -721,7 +722,8 @@ class FileAdmin(BaseView, ActionsMixin): ...@@ -721,7 +722,8 @@ class FileAdmin(BaseView, ActionsMixin):
helpers.flash_errors(form, message='Failed to create directory: %(error)s') helpers.flash_errors(form, message='Failed to create directory: %(error)s')
return self.render(self.mkdir_template, form=form, dir_url=dir_url, return self.render(self.mkdir_template, form=form, dir_url=dir_url,
header_text=gettext('Create Directory')) header_text=gettext('Create Directory'),
modal=request.args.get('modal'))
@expose('/delete/', methods=('POST',)) @expose('/delete/', methods=('POST',))
def delete(self): def delete(self):
...@@ -819,7 +821,8 @@ class FileAdmin(BaseView, ActionsMixin): ...@@ -819,7 +821,8 @@ class FileAdmin(BaseView, ActionsMixin):
form=form, form=form,
path=op.dirname(path), path=op.dirname(path),
name=op.basename(path), name=op.basename(path),
dir_url=return_url) dir_url=return_url,
modal=request.args.get('modal'))
@expose('/edit/', methods=('GET', 'POST')) @expose('/edit/', methods=('GET', 'POST'))
def edit(self): def edit(self):
...@@ -887,7 +890,8 @@ class FileAdmin(BaseView, ActionsMixin): ...@@ -887,7 +890,8 @@ class FileAdmin(BaseView, ActionsMixin):
form.content.data = content form.content.data = content
return self.render(self.edit_template, dir_url=dir_url, path=path, return self.render(self.edit_template, dir_url=dir_url, path=path,
form=form, error=error) form=form, error=error,
modal=request.args.get('modal'))
@expose('/action/', methods=('POST',)) @expose('/action/', methods=('POST',))
def action_view(self): def action_view(self):
......
...@@ -1611,7 +1611,8 @@ class BaseModelView(BaseView, ActionsMixin): ...@@ -1611,7 +1611,8 @@ class BaseModelView(BaseView, ActionsMixin):
return self.render(self.create_template, return self.render(self.create_template,
form=form, form=form,
form_opts=form_opts, form_opts=form_opts,
return_url=return_url) return_url=return_url,
modal=request.args.get('modal'))
@expose('/edit/', methods=('GET', 'POST')) @expose('/edit/', methods=('GET', 'POST'))
def edit_view(self): def edit_view(self):
...@@ -1654,7 +1655,8 @@ class BaseModelView(BaseView, ActionsMixin): ...@@ -1654,7 +1655,8 @@ class BaseModelView(BaseView, ActionsMixin):
model=model, model=model,
form=form, form=form,
form_opts=form_opts, form_opts=form_opts,
return_url=return_url) return_url=return_url,
modal=request.args.get('modal'))
@expose('/delete/', methods=('POST',)) @expose('/delete/', methods=('POST',))
def delete_view(self): def delete_view(self):
......
{%- if not request.args.get('modal') -%} {%- if not modal -%}
{% extends 'admin/master.html' %} {% extends 'admin/master.html' %}
{%- endif -%} {%- endif -%}
{% import 'admin/lib.html' as lib with context %} {% import 'admin/lib.html' as lib with context %}
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
{% block body %} {% block body %}
{% call check_error(error) %} {% call check_error(error) %}
{%- if request.args.get('modal') -%} {%- if modal -%}
{# content added to modal-content #} {# content added to modal-content #}
{{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }} {{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }}
{%- else -%} {%- else -%}
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
{% endblock %} {% endblock %}
{% block tail %} {% block tail %}
{%- if request.args.get('modal') -%} {%- if modal -%}
<script> <script>
// fill the header of modal dynamically // fill the header of modal dynamically
$('.modal-header h3').html('{{ self.header_text() }}'); $('.modal-header h3').html('{{ self.header_text() }}');
......
{%- if not request.args.get('modal') -%} {%- if not modal -%}
{% extends 'admin/master.html' %} {% extends 'admin/master.html' %}
{%- endif -%} {%- endif -%}
{% import 'admin/lib.html' as lib with context %} {% import 'admin/lib.html' as lib with context %}
{% block body %} {% block body %}
{%- if request.args.get('modal') -%} {%- if modal -%}
{{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }} {{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }}
{%- else -%} {%- else -%}
<h3>{{ header_text }}</h3> <h3>{{ header_text }}</h3>
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
{% endblock %} {% endblock %}
{% block tail %} {% block tail %}
{%- if request.args.get('modal') -%} {%- if modal -%}
<script> <script>
// fill the header of modal dynamically // fill the header of modal dynamically
$('.modal-header h3').html('{{ header_text }}'); $('.modal-header h3').html('{{ header_text }}');
......
{%- if not request.args.get('modal') -%} {%- if not modal -%}
{% extends 'admin/master.html' %} {% extends 'admin/master.html' %}
{%- endif -%} {%- endif -%}
{% import 'admin/lib.html' as lib with context %} {% import 'admin/lib.html' as lib with context %}
{% block body %} {% block body %}
{%- if request.args.get('modal') -%} {%- if modal -%}
{# content added to modal-content #} {# content added to modal-content #}
{{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }} {{ lib.render_form(form, dir_url, action=request.url, is_modal=True) }}
{%- else -%} {%- else -%}
{% block header_text -%} <h3>{% block header_text -%}
{{ _gettext('Rename %(name)s', name=name) }} {{ _gettext('Rename %(name)s', name=name) }}
{%- endblock %} {%- endblock %}</h3>
{{ lib.render_form(form, dir_url) }} {{ lib.render_form(form, dir_url) }}
{%- endif -%} {%- endif -%}
{% endblock %} {% endblock %}
{% block tail %} {% block tail %}
{%- if request.args.get('modal') -%} {%- if modal -%}
<script> <script>
// fill the header of modal dynamically // fill the header of modal dynamically
$('.modal-header h3').html('{{ self.header_text() }}'); $('.modal-header h3').html('{{ self.header_text() }}');
......
{%- if not request.args.get('modal') -%} {%- if not modal -%}
{% extends 'admin/master.html' %} {% extends 'admin/master.html' %}
{%- endif -%} {%- endif -%}
{% import 'admin/lib.html' as lib with context %} {% import 'admin/lib.html' as lib with context %}
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
{% endmacro %} {% endmacro %}
{% block head %} {% block head %}
{%- if not request.args.get('modal') -%} {%- if not modal -%}
{{ super() }} {{ super() }}
{{ lib.form_css() }} {{ lib.form_css() }}
{%- endif -%} {%- endif -%}
{% endblock %} {% endblock %}
{% block body %} {% block body %}
{%- if request.args.get('modal') -%} {%- if modal -%}
{{ lib.render_form(form, return_url, extra=None, form_opts=form_opts, {{ lib.render_form(form, return_url, extra=None, form_opts=form_opts,
action=request.url, is_modal=True) }} action=request.url, is_modal=True) }}
{%- else -%} {%- else -%}
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
{% endblock %} {% endblock %}
{% block tail %} {% block tail %}
{%- if request.args.get('modal') -%} {%- if modal -%}
<script> <script>
// fill the header of modal dynamically // fill the header of modal dynamically
$('.modal-header h3').html('{% block header_text %}<h3>{{ _gettext('Create New Record') }}</h3>{% endblock %}'); $('.modal-header h3').html('{% block header_text %}<h3>{{ _gettext('Create New Record') }}</h3>{% endblock %}');
......
{%- if not request.args.get('modal') -%} {%- if not modal -%}
{% extends 'admin/master.html' %} {% extends 'admin/master.html' %}
{%- endif -%} {%- endif -%}
{% import 'admin/lib.html' as lib with context %} {% import 'admin/lib.html' as lib with context %}
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
{% endmacro %} {% endmacro %}
{% block head %} {% block head %}
{%- if not request.args.get('modal') -%} {%- if not modal -%}
{{ super() }} {{ super() }}
{{ lib.form_css() }} {{ lib.form_css() }}
{%- endif -%} {%- endif -%}
{% endblock %} {% endblock %}
{% block body %} {% block body %}
{%- if request.args.get('modal') -%} {%- if modal -%}
{# remove save and continue button for modal (it won't function properly) #} {# remove save and continue button for modal (it won't function properly) #}
{{ lib.render_form(form, return_url, extra=None, form_opts=form_opts, {{ lib.render_form(form, return_url, extra=None, form_opts=form_opts,
action=request.url, is_modal=True) }} action=request.url, is_modal=True) }}
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
{% endblock %} {% endblock %}
{% block tail %} {% block tail %}
{%- if request.args.get('modal') -%} {%- if modal -%}
<script> <script>
// fill the header of modal dynamically // fill the header of modal dynamically
$('.modal-header h3').html('{% block header_text -%} $('.modal-header h3').html('{% block header_text -%}
......
{%- if not request.args.get('modal') -%} {%- if not modal -%}
{% extends 'admin/master.html' %} {% extends 'admin/master.html' %}
{%- endif -%} {%- endif -%}
{% import 'admin/lib.html' as lib with context %} {% import 'admin/lib.html' as lib with context %}
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
{% endmacro %} {% endmacro %}
{% block body %} {% block body %}
{%- if request.args.get('modal') -%} {%- if modal -%}
{# content added to modal-content #} {# content added to modal-content #}
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
{% endblock %} {% endblock %}
{% block tail %} {% block tail %}
{%- if request.args.get('modal') -%} {%- if modal -%}
<script> <script>
// fixes "remote modal shows same content every time", avoiding the flicker // fixes "remote modal shows same content every time", avoiding the flicker
$('body').on('hidden.bs.modal', '.modal', function() { $('body').on('hidden.bs.modal', '.modal', function() {
......
{%- if not request.args.get('modal') -%} {%- if not modal -%}
{% extends 'admin/master.html' %} {% extends 'admin/master.html' %}
{%- endif -%} {%- endif -%}
{% import 'admin/lib.html' as lib with context %} {% import 'admin/lib.html' as lib with context %}
{% block body %} {% block body %}
{%- if request.args.get('modal') -%} {%- if modal -%}
{# content added to modal-content #} {# content added to modal-content #}
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
{% endblock %} {% endblock %}
{% block tail %} {% block tail %}
{%- if request.args.get('modal') -%} {%- if modal -%}
<script> <script>
// fixes "remote modal shows same content every time", avoiding the flicker // fixes "remote modal shows same content every time", avoiding the flicker
$('body').on('hidden.bs.modal', '.modal', function() { $('body').on('hidden.bs.modal', '.modal', function() {
......
{%- if not request.args.get('modal') -%} {%- if not modal -%}
{% extends 'admin/master.html' %} {% extends 'admin/master.html' %}
{%- endif -%} {%- endif -%}
{% import 'admin/lib.html' as lib with context %} {% import 'admin/lib.html' as lib with context %}
{% block body %} {% block body %}
{%- if request.args.get('modal') -%} {%- if modal -%}
{# content added to modal-content #} {# content added to modal-content #}
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
{% endblock %} {% endblock %}
{% block tail %} {% block tail %}
{%- if request.args.get('modal') -%} {%- if modal -%}
<script> <script>
// fixes "remote modal shows same content every time", avoiding the flicker // fixes "remote modal shows same content every time", avoiding the flicker
$('body').on('hidden.bs.modal', '.modal', function() { $('body').on('hidden.bs.modal', '.modal', function() {
......
{%- if not request.args.get('modal') -%} {%- if not modal -%}
{% extends 'admin/master.html' %} {% extends 'admin/master.html' %}
{%- endif -%} {%- endif -%}
{% import 'admin/lib.html' as lib with context %} {% import 'admin/lib.html' as lib with context %}
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
{% endmacro %} {% endmacro %}
{% block head %} {% block head %}
{%- if not request.args.get('modal') -%} {%- if not modal -%}
{{ super() }} {{ super() }}
{{ lib.form_css() }} {{ lib.form_css() }}
{%- endif -%} {%- endif -%}
{% endblock %} {% endblock %}
{% block body %} {% block body %}
{%- if request.args.get('modal') -%} {%- if modal -%}
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
{% block header_text %}<h3>{{ _gettext('Create New Record') }}</h3>{% endblock %} {% block header_text %}<h3>{{ _gettext('Create New Record') }}</h3>{% endblock %}
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
{% endblock %} {% endblock %}
{% block tail %} {% block tail %}
{%- if request.args.get('modal') -%} {%- if modal -%}
<script> <script>
// fixes "remote modal shows same content every time", avoiding the flicker // fixes "remote modal shows same content every time", avoiding the flicker
$('body').on('hidden.bs.modal', '.modal', function () { $('body').on('hidden.bs.modal', '.modal', function () {
......
{%- if not request.args.get('modal') -%} {%- if not modal -%}
{% extends 'admin/master.html' %} {% extends 'admin/master.html' %}
{%- endif -%} {%- endif -%}
{% import 'admin/lib.html' as lib with context %} {% import 'admin/lib.html' as lib with context %}
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
{% endmacro %} {% endmacro %}
{% block head %} {% block head %}
{%- if not request.args.get('modal') -%} {%- if not modal -%}
{{ super() }} {{ super() }}
{{ lib.form_css() }} {{ lib.form_css() }}
{%- endif -%} {%- endif -%}
{% endblock %} {% endblock %}
{% block body %} {% block body %}
{%- if request.args.get('modal') -%} {%- if modal -%}
{# content added to modal-content #} {# content added to modal-content #}
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
{% endblock %} {% endblock %}
{% block tail %} {% block tail %}
{%- if request.args.get('modal') -%} {%- if modal -%}
<script> <script>
// fixes "remote modal shows same content every time", avoiding the flicker // fixes "remote modal shows same content every time", avoiding the flicker
$('body').on('hidden.bs.modal', '.modal', function () { $('body').on('hidden.bs.modal', '.modal', function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment