Cleanup some view modules per conventions etc.
Mainly this makes extending them easier..
This commit is contained in:
parent
eedbc5fb9a
commit
0455e472f5
|
@ -1,9 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2012 Lance Edgar
|
||||
# Copyright © 2010-2015 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -21,15 +20,16 @@
|
|||
# along with Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
"""
|
||||
Category Views
|
||||
"""
|
||||
|
||||
from . import SearchableAlchemyGridView, CrudView
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from rattail.db.model import Category
|
||||
|
||||
from . import SearchableAlchemyGridView, CrudView
|
||||
|
||||
|
||||
class CategoriesGrid(SearchableAlchemyGridView):
|
||||
|
||||
|
@ -85,28 +85,27 @@ class CategoryCrud(CrudView):
|
|||
return fs
|
||||
|
||||
|
||||
def includeme(config):
|
||||
|
||||
config.add_route('categories', '/categories')
|
||||
config.add_view(CategoriesGrid, route_name='categories',
|
||||
renderer='/categories/index.mako',
|
||||
permission='categories.list')
|
||||
|
||||
def add_routes(config):
|
||||
config.add_route('categories', '/categories')
|
||||
config.add_route('category.create', '/categories/new')
|
||||
config.add_view(CategoryCrud, attr='create', route_name='category.create',
|
||||
renderer='/categories/crud.mako',
|
||||
permission='categories.create')
|
||||
|
||||
config.add_route('category.read', '/categories/{uuid}')
|
||||
config.add_view(CategoryCrud, attr='read', route_name='category.read',
|
||||
renderer='/categories/crud.mako',
|
||||
permission='categories.read')
|
||||
|
||||
config.add_route('category.read', '/categories/{uuid}')
|
||||
config.add_route('category.update', '/categories/{uuid}/edit')
|
||||
config.add_view(CategoryCrud, attr='update', route_name='category.update',
|
||||
renderer='/categories/crud.mako',
|
||||
permission='categories.update')
|
||||
|
||||
config.add_route('category.delete', '/categories/{uuid}/delete')
|
||||
|
||||
|
||||
def includeme(config):
|
||||
add_routes(config)
|
||||
|
||||
# list
|
||||
config.add_view(CategoriesGrid, route_name='categories',
|
||||
renderer='/categories/index.mako', permission='categories.list')
|
||||
|
||||
# crud
|
||||
config.add_view(CategoryCrud, attr='create', route_name='category.create',
|
||||
renderer='/categories/crud.mako', permission='categories.create')
|
||||
config.add_view(CategoryCrud, attr='read', route_name='category.read',
|
||||
renderer='/categories/crud.mako', permission='categories.read')
|
||||
config.add_view(CategoryCrud, attr='update', route_name='category.update',
|
||||
renderer='/categories/crud.mako', permission='categories.update')
|
||||
config.add_view(CategoryCrud, attr='delete', route_name='category.delete',
|
||||
permission='categories.delete')
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2012 Lance Edgar
|
||||
# Copyright © 2010-2015 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -21,16 +20,16 @@
|
|||
# along with Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
"""
|
||||
Department Views
|
||||
"""
|
||||
|
||||
|
||||
from . import SearchableAlchemyGridView, CrudView, AlchemyGridView, AutocompleteView
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from rattail.db.model import Department, Product, ProductCost, Vendor
|
||||
|
||||
from . import SearchableAlchemyGridView, CrudView, AlchemyGridView, AutocompleteView
|
||||
|
||||
|
||||
class DepartmentsGrid(SearchableAlchemyGridView):
|
||||
|
||||
|
@ -117,44 +116,37 @@ class DepartmentsAutocomplete(AutocompleteView):
|
|||
fieldname = 'name'
|
||||
|
||||
|
||||
def add_routes(config):
|
||||
config.add_route('departments', '/departments')
|
||||
config.add_route('departments.autocomplete', '/departments/autocomplete')
|
||||
config.add_route('departments.by_vendor', '/departments/by-vendor')
|
||||
config.add_route('department.create', '/departments/new')
|
||||
config.add_route('department.read', '/departments/{uuid}')
|
||||
config.add_route('department.update', '/departments/{uuid}/edit')
|
||||
config.add_route('department.delete', '/departments/{uuid}/delete')
|
||||
|
||||
|
||||
def includeme(config):
|
||||
add_routes(config)
|
||||
|
||||
config.add_route('departments', '/departments')
|
||||
config.add_view(DepartmentsGrid,
|
||||
route_name='departments',
|
||||
renderer='/departments/index.mako',
|
||||
# list
|
||||
config.add_view(DepartmentsGrid, route_name='departments',
|
||||
renderer='/departments/index.mako', permission='departments.list')
|
||||
|
||||
# autocomplete
|
||||
config.add_view(DepartmentsAutocomplete, route_name='departments.autocomplete',
|
||||
renderer='json', permission='departments.list')
|
||||
|
||||
# departments by vendor list
|
||||
config.add_view(DepartmentsByVendorGrid,route_name='departments.by_vendor',
|
||||
permission='departments.list')
|
||||
|
||||
config.add_route('departments.autocomplete', '/departments/autocomplete')
|
||||
config.add_view(DepartmentsAutocomplete,
|
||||
route_name='departments.autocomplete',
|
||||
renderer='json',
|
||||
permission='departments.list')
|
||||
|
||||
config.add_route('departments.by_vendor', '/departments/by-vendor')
|
||||
config.add_view(DepartmentsByVendorGrid,
|
||||
route_name='departments.by_vendor',
|
||||
permission='departments.list')
|
||||
|
||||
config.add_route('department.create', '/departments/new')
|
||||
config.add_view(DepartmentCrud, attr='create',
|
||||
route_name='department.create',
|
||||
renderer='/departments/crud.mako',
|
||||
permission='departments.create')
|
||||
|
||||
config.add_route('department.read', '/departments/{uuid}')
|
||||
config.add_view(DepartmentCrud, attr='read',
|
||||
route_name='department.read',
|
||||
renderer='/departments/crud.mako',
|
||||
permission='departments.read')
|
||||
|
||||
config.add_route('department.update', '/departments/{uuid}/edit')
|
||||
config.add_view(DepartmentCrud, attr='update',
|
||||
route_name='department.update',
|
||||
renderer='/departments/crud.mako',
|
||||
permission='departments.update')
|
||||
|
||||
config.add_route('department.delete', '/departments/{uuid}/delete')
|
||||
config.add_view(DepartmentCrud, attr='delete',
|
||||
route_name='department.delete',
|
||||
# crud
|
||||
config.add_view(DepartmentCrud, attr='create', route_name='department.create',
|
||||
renderer='/departments/crud.mako', permission='departments.create')
|
||||
config.add_view(DepartmentCrud, attr='read', route_name='department.read',
|
||||
renderer='/departments/crud.mako', permission='departments.read')
|
||||
config.add_view(DepartmentCrud, attr='update', route_name='department.update',
|
||||
renderer='/departments/crud.mako', permission='departments.update')
|
||||
config.add_view(DepartmentCrud, attr='delete', route_name='department.delete',
|
||||
permission='departments.delete')
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2012 Lance Edgar
|
||||
# Copyright © 2010-2015 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -21,15 +20,16 @@
|
|||
# along with Rattail. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
"""
|
||||
Subdepartment Views
|
||||
"""
|
||||
|
||||
from . import SearchableAlchemyGridView, CrudView
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from rattail.db.model import Subdepartment
|
||||
|
||||
from . import SearchableAlchemyGridView, CrudView
|
||||
|
||||
|
||||
class SubdepartmentsGrid(SearchableAlchemyGridView):
|
||||
|
||||
|
@ -85,32 +85,27 @@ class SubdepartmentCrud(CrudView):
|
|||
return fs
|
||||
|
||||
|
||||
def add_routes(config):
|
||||
config.add_route('subdepartments', '/subdepartments')
|
||||
config.add_route('subdepartment.create', '/subdepartments/new')
|
||||
config.add_route('subdepartment.read', '/subdepartments/{uuid}')
|
||||
config.add_route('subdepartment.update', '/subdepartments/{uuid}/edit')
|
||||
config.add_route('subdepartment.delete', '/subdepartments/{uuid}/delete')
|
||||
|
||||
|
||||
def includeme(config):
|
||||
add_routes(config)
|
||||
|
||||
config.add_route('subdepartments', '/subdepartments')
|
||||
# list
|
||||
config.add_view(SubdepartmentsGrid, route_name='subdepartments',
|
||||
renderer='/subdepartments/index.mako',
|
||||
permission='subdepartments.list')
|
||||
renderer='/subdepartments/index.mako', permission='subdepartments.list')
|
||||
|
||||
config.add_route('subdepartment.create', '/subdepartments/new')
|
||||
config.add_view(SubdepartmentCrud, attr='create',
|
||||
route_name='subdepartment.create',
|
||||
renderer='/subdepartments/crud.mako',
|
||||
permission='subdepartments.create')
|
||||
|
||||
config.add_route('subdepartment.read', '/subdepartments/{uuid}')
|
||||
config.add_view(SubdepartmentCrud, attr='read',
|
||||
route_name='subdepartment.read',
|
||||
renderer='/subdepartments/crud.mako',
|
||||
permission='subdepartments.read')
|
||||
|
||||
config.add_route('subdepartment.update', '/subdepartments/{uuid}/edit')
|
||||
config.add_view(SubdepartmentCrud, attr='update',
|
||||
route_name='subdepartment.update',
|
||||
renderer='/subdepartments/crud.mako',
|
||||
permission='subdepartments.update')
|
||||
|
||||
config.add_route('subdepartment.delete', '/subdepartments/{uuid}/delete')
|
||||
config.add_view(SubdepartmentCrud, attr='delete',
|
||||
route_name='subdepartment.delete',
|
||||
# crud
|
||||
config.add_view(SubdepartmentCrud, attr='create', route_name='subdepartment.create',
|
||||
renderer='/subdepartments/crud.mako', permission='subdepartments.create')
|
||||
config.add_view(SubdepartmentCrud, attr='read', route_name='subdepartment.read',
|
||||
renderer='/subdepartments/crud.mako', permission='subdepartments.read')
|
||||
config.add_view(SubdepartmentCrud, attr='update', route_name='subdepartment.update',
|
||||
renderer='/subdepartments/crud.mako', permission='subdepartments.update')
|
||||
config.add_view(SubdepartmentCrud, attr='delete', route_name='subdepartment.delete',
|
||||
permission='subdepartments.delete')
|
||||
|
|
Loading…
Reference in a new issue