2015-02-09 15:33:16 -06:00
|
|
|
# -*- coding: utf-8 -*-
|
2012-09-24 17:39:54 -05:00
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# Rattail -- Retail Software Framework
|
2015-02-09 15:33:16 -06:00
|
|
|
# Copyright © 2010-2015 Lance Edgar
|
2012-09-24 17:39:54 -05:00
|
|
|
#
|
|
|
|
# This file is part of Rattail.
|
|
|
|
#
|
|
|
|
# Rattail is free software: you can redistribute it and/or modify it under the
|
|
|
|
# terms of the GNU Affero General Public License as published by the Free
|
|
|
|
# Software Foundation, either version 3 of the License, or (at your option)
|
|
|
|
# any later version.
|
|
|
|
#
|
|
|
|
# Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
|
|
|
|
# more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with Rattail. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
"""
|
2013-09-01 09:27:47 -05:00
|
|
|
Brand Views
|
2012-09-24 17:39:54 -05:00
|
|
|
"""
|
|
|
|
|
2015-12-07 15:08:14 -06:00
|
|
|
from __future__ import unicode_literals, absolute_import
|
2012-09-24 17:39:54 -05:00
|
|
|
|
2015-02-09 15:33:16 -06:00
|
|
|
from rattail.db import model
|
2012-09-24 17:39:54 -05:00
|
|
|
|
2015-12-07 15:08:14 -06:00
|
|
|
from tailbone.views import MasterView, AutocompleteView
|
|
|
|
from tailbone.views.continuum import VersionView, version_defaults
|
2015-02-09 15:33:16 -06:00
|
|
|
|
2012-09-24 17:39:54 -05:00
|
|
|
|
2015-12-07 15:08:14 -06:00
|
|
|
class BrandsView(MasterView):
|
|
|
|
"""
|
|
|
|
Master view for the Brand class.
|
|
|
|
"""
|
|
|
|
model_class = model.Brand
|
2012-09-24 17:39:54 -05:00
|
|
|
|
2015-12-07 15:08:14 -06:00
|
|
|
def configure_grid(self, g):
|
|
|
|
g.filters['name'].default_active = True
|
|
|
|
g.filters['name'].default_verb = 'contains'
|
|
|
|
g.default_sortkey = 'name'
|
2012-09-24 17:39:54 -05:00
|
|
|
g.configure(
|
|
|
|
include=[
|
|
|
|
g.name,
|
2015-12-07 15:08:14 -06:00
|
|
|
],
|
2012-09-24 17:39:54 -05:00
|
|
|
readonly=True)
|
|
|
|
|
2015-12-07 15:08:14 -06:00
|
|
|
def configure_fieldset(self, fs):
|
2012-09-24 17:39:54 -05:00
|
|
|
fs.configure(
|
|
|
|
include=[
|
|
|
|
fs.name,
|
2015-12-07 15:08:14 -06:00
|
|
|
])
|
2012-09-24 17:39:54 -05:00
|
|
|
return fs
|
|
|
|
|
|
|
|
|
2015-02-09 15:33:16 -06:00
|
|
|
class BrandVersionView(VersionView):
|
|
|
|
"""
|
|
|
|
View which shows version history for a brand.
|
|
|
|
"""
|
|
|
|
parent_class = model.Brand
|
2015-12-07 15:08:14 -06:00
|
|
|
route_model_view = 'brands.view'
|
2015-02-09 15:33:16 -06:00
|
|
|
|
|
|
|
|
2012-10-04 10:40:07 -05:00
|
|
|
class BrandsAutocomplete(AutocompleteView):
|
|
|
|
|
2015-12-07 15:08:14 -06:00
|
|
|
mapped_class = model.Brand
|
2012-10-04 10:40:07 -05:00
|
|
|
fieldname = 'name'
|
|
|
|
|
|
|
|
|
2012-09-24 17:39:54 -05:00
|
|
|
def includeme(config):
|
2015-02-09 15:33:16 -06:00
|
|
|
|
2015-12-07 15:08:14 -06:00
|
|
|
# autocomplete
|
|
|
|
config.add_route('brands.autocomplete', '/brands/autocomplete')
|
|
|
|
config.add_view(BrandsAutocomplete, route_name='brands.autocomplete',
|
|
|
|
renderer='json', permission='brands.list')
|
|
|
|
|
|
|
|
BrandsView.defaults(config)
|
2015-02-09 15:33:16 -06:00
|
|
|
version_defaults(config, BrandVersionView, 'brand')
|