Improve the Poser Setup page; allow poser dir refresh
This commit is contained in:
parent
128657810b
commit
33abeb1aca
|
@ -6,42 +6,116 @@
|
||||||
<%def name="page_content()">
|
<%def name="page_content()">
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<p class="block">
|
% if not poser_dir_exists:
|
||||||
Before you can use Poser features, ${app_title} must create the
|
|
||||||
file structure for it.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p class="block">
|
<p class="block">
|
||||||
A new folder will be created at this location:
|
Before you can use Poser features, ${app_title} must create the
|
||||||
<span class="is-family-monospace has-text-weight-bold">
|
file structure for it.
|
||||||
${poser_dir}
|
</p>
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p class="block">
|
<p class="block">
|
||||||
Once set up, ${app_title} can generate code for certain features,
|
A new folder will be created at this location:
|
||||||
in the Poser folder. You can then access these features from
|
<span class="is-family-monospace has-text-weight-bold">
|
||||||
within ${app_title}.
|
${poser_dir}
|
||||||
</p>
|
</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p class="block">
|
<p class="block">
|
||||||
You are free to edit most files in the Poser folder as well.
|
Once set up, ${app_title} can generate code for certain features,
|
||||||
When you do so ${app_title} should pick up on the changes with no
|
in the Poser folder. You can then access these features from
|
||||||
need for app restart.
|
within ${app_title}.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class="block">
|
<p class="block">
|
||||||
Proceed?
|
You are free to edit most files in the Poser folder as well.
|
||||||
</p>
|
When you do so ${app_title} should pick up on the changes with no
|
||||||
|
need for app restart.
|
||||||
|
</p>
|
||||||
|
|
||||||
${h.form(request.current_route_url(), **{'@submit': 'setupSubmitting = true'})}
|
<p class="block">
|
||||||
${h.csrf_token(request)}
|
Proceed?
|
||||||
<b-button type="is-primary"
|
</p>
|
||||||
native-type="submit"
|
|
||||||
:disabled="setupSubmitting">
|
${h.form(request.current_route_url(), **{'@submit': 'setupSubmitting = true'})}
|
||||||
{{ setupSubmitting ? "Working, please wait..." : "Go for it!" }}
|
${h.csrf_token(request)}
|
||||||
</b-button>
|
<b-button type="is-primary"
|
||||||
${h.end_form()}
|
native-type="submit"
|
||||||
|
:disabled="setupSubmitting">
|
||||||
|
{{ setupSubmitting ? "Working, please wait..." : "Go for it!" }}
|
||||||
|
</b-button>
|
||||||
|
${h.end_form()}
|
||||||
|
|
||||||
|
% else:
|
||||||
|
|
||||||
|
<h3 class="is-size-3 block">Root Folder</h3>
|
||||||
|
|
||||||
|
<p class="block">
|
||||||
|
Poser folder already exists at:
|
||||||
|
<span class="is-family-monospace has-text-weight-bold">
|
||||||
|
${poser_dir}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
${h.form(request.current_route_url(), class_='block', **{'@submit': 'setupSubmitting = true'})}
|
||||||
|
${h.csrf_token(request)}
|
||||||
|
${h.hidden('action', value='refresh')}
|
||||||
|
<b-button type="is-primary"
|
||||||
|
native-type="submit"
|
||||||
|
:disabled="setupSubmitting"
|
||||||
|
icon-pack="fas"
|
||||||
|
icon-left="redo">
|
||||||
|
{{ setupSubmitting ? "Working, please wait..." : "Refresh Folder" }}
|
||||||
|
</b-button>
|
||||||
|
${h.end_form()}
|
||||||
|
|
||||||
|
<h3 class="is-size-3 block">Modules</h3>
|
||||||
|
|
||||||
|
<ul class="list" style="max-width: 80%;">
|
||||||
|
<li class="list-item">
|
||||||
|
<span class="is-family-monospace">poser</span>
|
||||||
|
<span class="is-pulled-right">
|
||||||
|
% if poser_imported['poser']:
|
||||||
|
<span class="is-family-monospace">
|
||||||
|
${poser_imported['poser'].__file__}
|
||||||
|
</span>
|
||||||
|
% else:
|
||||||
|
<span class="has-background-warning">
|
||||||
|
${poser_import_errors['poser']}
|
||||||
|
</span>
|
||||||
|
% endif
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
<li class="list-item">
|
||||||
|
<span class="is-family-monospace">poser.reports</span>
|
||||||
|
<span class="is-pulled-right">
|
||||||
|
% if poser_imported['reports']:
|
||||||
|
<span class="is-family-monospace">
|
||||||
|
${poser_imported['reports'].__file__}
|
||||||
|
</span>
|
||||||
|
% else:
|
||||||
|
<span class="has-background-warning">
|
||||||
|
${poser_import_errors['reports']}
|
||||||
|
</span>
|
||||||
|
% endif
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
<li class="list-item">
|
||||||
|
<span class="is-family-monospace">poser.web.views</span>
|
||||||
|
<span class="is-pulled-right">
|
||||||
|
% if poser_imported['views']:
|
||||||
|
<span class="is-family-monospace">
|
||||||
|
${poser_imported['views'].__file__}
|
||||||
|
</span>
|
||||||
|
% else:
|
||||||
|
<span class="has-background-warning">
|
||||||
|
${poser_import_errors['views']}
|
||||||
|
</span>
|
||||||
|
% endif
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
% endif
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="modify_this_page_vars()">
|
<%def name="modify_this_page_vars()">
|
||||||
|
|
|
@ -26,6 +26,7 @@ Various common views
|
||||||
|
|
||||||
from __future__ import unicode_literals, absolute_import
|
from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
|
import os
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from rattail.db import model
|
from rattail.db import model
|
||||||
|
@ -206,22 +207,67 @@ class CommonView(View):
|
||||||
app = self.get_rattail_app()
|
app = self.get_rattail_app()
|
||||||
app_title = self.rattail_config.app_title()
|
app_title = self.rattail_config.app_title()
|
||||||
poser_handler = app.get_poser_handler()
|
poser_handler = app.get_poser_handler()
|
||||||
|
poser_dir = poser_handler.get_default_poser_dir()
|
||||||
|
poser_dir_exists = os.path.isdir(poser_dir)
|
||||||
|
|
||||||
if self.request.method == 'POST':
|
if self.request.method == 'POST':
|
||||||
try:
|
|
||||||
path = poser_handler.make_poser_dir()
|
# maybe refresh poser dir
|
||||||
except Exception as error:
|
if self.request.POST.get('action') == 'refresh':
|
||||||
self.request.session.flash(simple_error(error), 'error')
|
poser_handler.refresh_poser_dir()
|
||||||
else:
|
self.request.session.flash("Poser folder has been refreshed.")
|
||||||
self.request.session.flash("Poser folder created at: {}".format(path))
|
|
||||||
self.request.session.flash("Please restart the web app!", 'warning')
|
else: # otherwise make poser dir
|
||||||
return self.redirect(self.request.route_url('home'))
|
|
||||||
|
if poser_dir_exists:
|
||||||
|
self.request.session.flash("Poser folder already exists!", 'error')
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
path = poser_handler.make_poser_dir()
|
||||||
|
except Exception as error:
|
||||||
|
self.request.session.flash(simple_error(error), 'error')
|
||||||
|
else:
|
||||||
|
self.request.session.flash("Poser folder created at: {}".format(path))
|
||||||
|
self.request.session.flash("Please restart the web app!", 'warning')
|
||||||
|
return self.redirect(self.request.route_url('home'))
|
||||||
|
|
||||||
|
try:
|
||||||
|
from poser import reports
|
||||||
|
reports_error = None
|
||||||
|
except Exception as error:
|
||||||
|
reports = None
|
||||||
|
reports_error = simple_error(error)
|
||||||
|
|
||||||
|
try:
|
||||||
|
from poser.web import views
|
||||||
|
views_error = None
|
||||||
|
except Exception as error:
|
||||||
|
views = None
|
||||||
|
views_error = simple_error(error)
|
||||||
|
|
||||||
|
try:
|
||||||
|
import poser
|
||||||
|
poser_error = None
|
||||||
|
except Exception as error:
|
||||||
|
poser = None
|
||||||
|
poser_error = simple_error(error)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'use_buefy': use_buefy,
|
'use_buefy': use_buefy,
|
||||||
'app_title': app_title,
|
'app_title': app_title,
|
||||||
'index_title': app_title,
|
'index_title': app_title,
|
||||||
'poser_dir': poser_handler.get_default_poser_dir(),
|
'poser_dir': poser_dir,
|
||||||
|
'poser_dir_exists': poser_dir_exists,
|
||||||
|
'poser_imported': {
|
||||||
|
'poser': poser,
|
||||||
|
'reports': reports,
|
||||||
|
'views': views,
|
||||||
|
},
|
||||||
|
'poser_import_errors': {
|
||||||
|
'poser': poser_error,
|
||||||
|
'reports': reports_error,
|
||||||
|
'views': views_error,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in a new issue