Improve the Poser Setup page; allow poser dir refresh
This commit is contained in:
parent
128657810b
commit
33abeb1aca
|
@ -6,6 +6,8 @@
|
|||
<%def name="page_content()">
|
||||
<br />
|
||||
|
||||
% if not poser_dir_exists:
|
||||
|
||||
<p class="block">
|
||||
Before you can use Poser features, ${app_title} must create the
|
||||
file structure for it.
|
||||
|
@ -42,6 +44,78 @@
|
|||
{{ 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 name="modify_this_page_vars()">
|
||||
|
|
|
@ -26,6 +26,7 @@ Various common views
|
|||
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
import os
|
||||
import six
|
||||
|
||||
from rattail.db import model
|
||||
|
@ -206,8 +207,21 @@ class CommonView(View):
|
|||
app = self.get_rattail_app()
|
||||
app_title = self.rattail_config.app_title()
|
||||
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':
|
||||
|
||||
# maybe refresh poser dir
|
||||
if self.request.POST.get('action') == 'refresh':
|
||||
poser_handler.refresh_poser_dir()
|
||||
self.request.session.flash("Poser folder has been refreshed.")
|
||||
|
||||
else: # otherwise make poser dir
|
||||
|
||||
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:
|
||||
|
@ -217,11 +231,43 @@ class CommonView(View):
|
|||
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 {
|
||||
'use_buefy': use_buefy,
|
||||
'app_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
|
||||
|
|
Loading…
Reference in a new issue