Add view for consuming new batch ID; misc. tweaks for grids etc.
This commit is contained in:
parent
6ae129ea24
commit
8186366b69
5 changed files with 76 additions and 38 deletions
|
@ -29,6 +29,7 @@ from __future__ import unicode_literals, absolute_import
|
|||
import six
|
||||
|
||||
import rattail
|
||||
from rattail.batch import consume_batch_id
|
||||
from rattail.mail import send_email
|
||||
from rattail.util import OrderedDict
|
||||
from rattail.files import resource_path
|
||||
|
@ -40,6 +41,7 @@ from pyramid_simpleform import Form
|
|||
|
||||
import tailbone
|
||||
from tailbone import forms
|
||||
from tailbone.db import Session
|
||||
from tailbone.views import View
|
||||
|
||||
|
||||
|
@ -124,6 +126,14 @@ class CommonView(View):
|
|||
return httpexceptions.HTTPFound(location=form.data['referrer'])
|
||||
return {'form': forms.FormRenderer(form)}
|
||||
|
||||
def consume_batch_id(self):
|
||||
"""
|
||||
Consume next batch ID from the PG sequence, and display via flash message.
|
||||
"""
|
||||
batch_id = consume_batch_id(Session())
|
||||
self.request.session.flash("Batch ID has been consumed: {:08d}".format(batch_id))
|
||||
return self.redirect(self.request.get_referrer())
|
||||
|
||||
def bogus_error(self):
|
||||
"""
|
||||
A special view which simply raises an error, for the sake of testing
|
||||
|
@ -133,6 +143,10 @@ class CommonView(View):
|
|||
|
||||
@classmethod
|
||||
def defaults(cls, config):
|
||||
cls._defaults(config)
|
||||
|
||||
@classmethod
|
||||
def _defaults(cls, config):
|
||||
rattail_config = config.registry.settings.get('rattail_config')
|
||||
|
||||
# auto-correct URLs which require trailing slash
|
||||
|
@ -142,6 +156,9 @@ class CommonView(View):
|
|||
if rattail_config and rattail_config.production():
|
||||
config.add_exception_view(cls, attr='exception', renderer='/exception.mako')
|
||||
|
||||
# permissions
|
||||
config.add_tailbone_permission_group('common', "(common)", overwrite=False)
|
||||
|
||||
# home
|
||||
config.add_route('home', '/')
|
||||
config.add_view(cls, attr='home', route_name='home', renderer='/home.mako')
|
||||
|
@ -162,6 +179,12 @@ class CommonView(View):
|
|||
config.add_route('feedback', '/feedback')
|
||||
config.add_view(cls, attr='feedback', route_name='feedback', renderer='/feedback.mako')
|
||||
|
||||
# consume batch ID
|
||||
config.add_tailbone_permission('common', 'common.consume_batch_id',
|
||||
"Consume new Batch ID")
|
||||
config.add_route('consume_batch_id', '/consume-batch-id')
|
||||
config.add_view(cls, attr='consume_batch_id', route_name='consume_batch_id')
|
||||
|
||||
# bogus error
|
||||
config.add_route('bogus_error', '/bogus-error')
|
||||
config.add_view(cls, attr='bogus_error', route_name='bogus_error', permission='errors.bogus')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue