Coverage for src/sideshow/web/menus.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.6.10, created at 2025-01-09 12:06 -0600

1# -*- coding: utf-8; -*- 

2################################################################################ 

3# 

4# Sideshow -- Case/Special Order Tracker 

5# Copyright © 2024 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""" 

24Sideshow Menu 

25""" 

26 

27from wuttaweb import menus as base 

28 

29 

30class SideshowMenuHandler(base.MenuHandler): 

31 """ 

32 Sideshow menu handler 

33 """ 

34 

35 def make_menus(self, request, **kwargs): 

36 """ """ 

37 return [ 

38 self.make_orders_menu(request), 

39 self.make_customers_menu(request), 

40 self.make_products_menu(request), 

41 self.make_batch_menu(request), 

42 self.make_admin_menu(request), 

43 ] 

44 

45 def make_orders_menu(self, request, **kwargs): 

46 """ 

47 Generate the Orders menu. 

48 """ 

49 return { 

50 'title': "Orders", 

51 'type': 'menu', 

52 'items': [ 

53 { 

54 'title': "Create New Order", 

55 'route': 'orders.create', 

56 'perm': 'orders.create', 

57 }, 

58 {'type': 'sep'}, 

59 { 

60 'title': "All Order Items", 

61 'route': 'order_items', 

62 'perm': 'order_items.list', 

63 }, 

64 { 

65 'title': "All Orders", 

66 'route': 'orders', 

67 'perm': 'orders.list', 

68 }, 

69 ], 

70 } 

71 

72 def make_customers_menu(self, request, **kwargs): 

73 """ 

74 Generate the Customers menu. 

75 """ 

76 return { 

77 'title': "Customers", 

78 'type': 'menu', 

79 'items': [ 

80 { 

81 'title': "Local Customers", 

82 'route': 'local_customers', 

83 'perm': 'local_customers.list', 

84 }, 

85 { 

86 'title': "Pending Customers", 

87 'route': 'pending_customers', 

88 'perm': 'pending_customers.list', 

89 }, 

90 ], 

91 } 

92 

93 def make_products_menu(self, request, **kwargs): 

94 """ 

95 Generate the Products menu. 

96 """ 

97 return { 

98 'title': "Products", 

99 'type': 'menu', 

100 'items': [ 

101 { 

102 'title': "Local Products", 

103 'route': 'local_products', 

104 'perm': 'local_products.list', 

105 }, 

106 { 

107 'title': "Pending Products", 

108 'route': 'pending_products', 

109 'perm': 'pending_products.list', 

110 }, 

111 ], 

112 } 

113 

114 def make_batch_menu(self, request, **kwargs): 

115 """ 

116 Generate the Batch menu. 

117 """ 

118 return { 

119 'title': "Batches", 

120 'type': 'menu', 

121 'items': [ 

122 { 

123 'title': "New Orders", 

124 'route': 'neworder_batches', 

125 'perm': 'neworder_batches.list', 

126 }, 

127 ], 

128 } 

129 

130 def make_admin_menu(self, request, **kwargs): 

131 """ """ 

132 kwargs['include_people'] = True 

133 return super().make_admin_menu(request, **kwargs)