comparison MoinMoin/themes/__init__.py @ 2393:0cb9f75fb9ba

Refactored local_panel rendering code, almost everything processed on python side
author sharky93 <rishabhr123@gmail.com>
date Sun, 18 Aug 2013 02:08:46 +0530
parents 9bf41329f031
children 2e84d4574332
comparison
equal deleted inserted replaced
2392:c515adfb6b69 2393:0cb9f75fb9ba
86 if self.user.may.write(item_name): 86 if self.user.may.write(item_name):
87 navtabs.append('frontend.modify_item') 87 navtabs.append('frontend.modify_item')
88 return navtabs 88 return navtabs
89 89
90 def get_local_panel(self, item_name): 90 def get_local_panel(self, item_name):
91 user_actions = ['frontend.quicklink_item', 'frontend.subscribe_item', ] 91 user_actions_endpoints = ['frontend.quicklink_item', 'frontend.subscribe_item', ]
92 item_navigation = ['frontend.index', 'frontend.sitemap', ] 92 item_navigation_endpoints = ['frontend.index', 'frontend.sitemap', ]
93 item_actions = ['frontend.rename_item', 'frontend.delete_item', 'frontend.destroy_item', 93 item_actions_endpoints = ['frontend.rename_item', 'frontend.delete_item', 'frontend.destroy_item',
94 'frontend.similar_names', 'frontend.download_item', 'frontend.copy_item',] if self.user.may.write(item_name) else [] 94 'frontend.similar_names', 'frontend.download_item',
95 'frontend.copy_item', 'special.supplementation'] if self.user.may.write(item_name) else []
96
97 user_actions = []
98 item_navigation = []
99 item_actions = []
100
101 icon = self.get_endpoint_iconmap()
102 exists = flaskg.storage.has_item(item_name)
103
104 for endpoint, label, title, check_exists in app.cfg.item_views:
105 if endpoint not in app.cfg.endpoints_excluded:
106 if not check_exists or exists:
107 if endpoint in user_actions_endpoints:
108 print user_actions
109 if flaskg.user.valid:
110 href = url_for(endpoint, item_name=item_name)
111 iconcls = icon[endpoint]
112 #endpoint = iconcls = label = None
113
114 if endpoint == 'frontend.quicklink_item':
115 if not flaskg.user.is_quicklinked_to([item_name]):
116 label = _('Add Link')
117 user_actions.append((endpoint, href, iconcls, label, title))
118 elif endpoint == 'frontend.subscribe_item':
119 if flaskg.user.is_subscribed_to([item_name]):
120 label = _('Unsubscribe')
121 else:
122 label = _('Subscribe')
123 user_actions.append((endpoint, href, iconcls, label, title))
124
125 elif endpoint in item_actions_endpoints:
126
127 iconcls = icon[endpoint]
128
129 if endpoint == 'special.supplementation':
130 for sub_item_name in app.cfg.supplementation_item_names:
131 current_sub = item_name.rsplit('/', 1)[-1]
132 if current_sub not in app.cfg.supplementation_item_names:
133 supp_name = '%s/%s' % (item_name, sub_item_name)
134 if flaskg.storage.has_item(supp_name) or flaskg.user.may.write(supp_name):
135 href = url_for('frontend.show_item', item_name=supp_name)
136 label = _(sub_item_name)
137 title = None
138
139 item_actions.append((endpoint, href, iconcls, label, title))
140 else:
141 href = url_for(endpoint, item_name=item_name)
142 item_actions.append((endpoint, href, iconcls, label, title))
143
144 elif endpoint in item_navigation_endpoints:
145
146 iconcls = icon[endpoint]
147 href = url_for(endpoint, item_name=item_name)
148
149 item_navigation.append((endpoint, href, iconcls, label, title))
150
151 print user_actions
152
95 return user_actions, item_navigation, item_actions 153 return user_actions, item_navigation, item_actions
96 154
97 def get_endpoint_iconmap(self): 155 def get_endpoint_iconmap(self):
98 icon = {'frontend.quicklink_item' : "icon-star-empty", 156 icon = {'frontend.quicklink_item' : "icon-star-empty",
99 'frontend.subscribe_item' : "icon-envelope", 157 'frontend.subscribe_item' : "icon-envelope",