tailbone/tailbone/views/brands.py

78 lines
2 KiB
Python
Raw Normal View History

# -*- coding: utf-8; -*-
2012-09-24 17:39:54 -05:00
################################################################################
#
# Rattail -- Retail Software Framework
2018-02-04 10:46:27 -06:00
# Copyright © 2010-2018 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 General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
2012-09-24 17:39:54 -05:00
#
# 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 General Public License for more
# details.
2012-09-24 17:39:54 -05:00
#
# You should have received a copy of the GNU General Public License along with
# Rattail. If not, see <http://www.gnu.org/licenses/>.
2012-09-24 17:39:54 -05:00
#
################################################################################
"""
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
2012-09-24 17:39:54 -05:00
class BrandsView(MasterView):
"""
Master view for the Brand class.
"""
model_class = model.Brand
has_versions = True
grid_columns = [
'name',
'confirmed',
]
2012-09-24 17:39:54 -05:00
2017-08-17 20:20:15 -05:00
form_fields = [
'name',
'confirmed',
2017-08-17 20:20:15 -05:00
]
def configure_grid(self, g):
super(BrandsView, self).configure_grid(g)
# name
g.filters['name'].default_active = True
g.filters['name'].default_verb = 'contains'
g.set_sort_defaults('name')
g.set_link('name')
2012-09-24 17:39:54 -05:00
# confirmed
g.set_type('confirmed', 'boolean')
2012-09-24 17:39:54 -05:00
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)