tailbone/tailbone/views/brands.py

82 lines
2.3 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
2012-09-24 17:39:54 -05:00
################################################################################
#
# Rattail -- Retail Software Framework
# 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
"""
from __future__ import unicode_literals, absolute_import
2012-09-24 17:39:54 -05:00
from rattail.db import model
2012-09-24 17:39:54 -05:00
from tailbone.views import MasterView, AutocompleteView
from tailbone.views.continuum import VersionView, version_defaults
2012-09-24 17:39:54 -05:00
class BrandsView(MasterView):
"""
Master view for the Brand class.
"""
model_class = model.Brand
2012-09-24 17:39:54 -05: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,
],
2012-09-24 17:39:54 -05:00
readonly=True)
def configure_fieldset(self, fs):
2012-09-24 17:39:54 -05:00
fs.configure(
include=[
fs.name,
])
2012-09-24 17:39:54 -05:00
return fs
class BrandVersionView(VersionView):
"""
View which shows version history for a brand.
"""
parent_class = model.Brand
route_model_view = 'brands.view'
2012-10-04 10:40:07 -05:00
class BrandsAutocomplete(AutocompleteView):
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):
# autocomplete
config.add_route('brands.autocomplete', '/brands/autocomplete')
config.add_view(BrandsAutocomplete, route_name='brands.autocomplete',
renderer='json', permission='brands.list')
BrandsView.defaults(config)
version_defaults(config, BrandVersionView, 'brand')