Coverage for .tox/coverage/lib/python3.11/site-packages/sideshow/web/views/common.py: 100%
15 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-16 07:16 -0500
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-16 07:16 -0500
1# -*- coding: utf-8; -*-
2################################################################################
3#
4# Sideshow -- Case/Special Order Tracker
5# Copyright © 2024-2025 Lance Edgar
6#
7# This file is part of Sideshow.
8#
9# Sideshow is free software: you can redistribute it and/or modify it
10# under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# Sideshow is distributed in the hope that it will be useful, but
15# WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17# General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with Sideshow. If not, see <http://www.gnu.org/licenses/>.
21#
22################################################################################
23"""
24Common Views
25"""
27from wuttaweb.views import common as base
30class CommonView(base.CommonView):
31 """
32 Sideshow overrides for common view logic.
33 """
35 def setup_enhance_admin_user(self, user):
36 """
37 Adds the "Order Admin" role with all relevant permissions.
39 The default logic for creating a new user will create the
40 "Site Admin" role with permissions for app and user account
41 maintenance etc. Sideshow needs another role for the order
42 maintenance.
43 """
44 model = self.app.model
45 session = self.app.get_session(user)
46 auth = self.app.get_auth_handler()
48 admin = model.Role(name="Order Admin")
49 admin.notes = ("this role was auto-created; "
50 "you can change or remove it as needed.")
52 session.add(admin)
53 user.roles.append(admin)
55 order_admin_perms = [
56 'local_customers.list',
57 'local_customers.view',
58 'local_products.list',
59 'local_products.view',
60 'neworder_batches.list',
61 'neworder_batches.view',
62 'order_items.add_note',
63 'order_items.change_status',
64 'order_items.list',
65 'order_items.view',
66 'order_items_contact.add_note',
67 'order_items_contact.change_status',
68 'order_items_contact.list',
69 'order_items_contact.process_contact',
70 'order_items_contact.view',
71 'order_items_delivery.add_note',
72 'order_items_delivery.change_status',
73 'order_items_delivery.list',
74 'order_items_delivery.process_delivery',
75 'order_items_delivery.process_restock',
76 'order_items_delivery.view',
77 'order_items_placement.add_note',
78 'order_items_placement.change_status',
79 'order_items_placement.list',
80 'order_items_placement.process_placement',
81 'order_items_placement.view',
82 'order_items_receiving.add_note',
83 'order_items_receiving.change_status',
84 'order_items_receiving.list',
85 'order_items_receiving.process_receiving',
86 'order_items_receiving.process_reorder',
87 'order_items_receiving.view',
88 'orders.configure',
89 'orders.create',
90 'orders.create_unknown_product',
91 'orders.list',
92 'orders.view',
93 'pending_customers.list',
94 'pending_customers.view',
95 'pending_products.list',
96 'pending_products.view',
97 ]
99 for perm in order_admin_perms:
100 auth.grant_permission(admin, perm)
103def includeme(config):
104 base.defaults(config, **{'CommonView': CommonView})