Merge lp:~veebers/sloecode/yui-menu into lp:sloecode

Proposed by Thomi Richards
Status: Merged
Merged at revision: 43
Proposed branch: lp:~veebers/sloecode/yui-menu
Merge into: lp:sloecode
Diff against target: 280 lines (+184/-32)
4 files modified
sloecode/controllers/person.py (+6/-6)
sloecode/lib/helpers.py (+1/-1)
sloecode/templates/base.html (+4/-2)
sloecode/templates/macros/nav.html (+173/-23)
To merge this branch: bzr merge lp:~veebers/sloecode/yui-menu
Reviewer Review Type Date Requested Status
Thomi Richards Pending
Review via email: mp+47938@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

A few tweaks that I think are worth doing:

 * Once logged in as admin, the 'Admin' menu has a menu entry called "Manage Sloecode" that always seems to point to the current page, and does nothing.

 * We should get rid of the "Manage Projects" and "Manage Users" pages. Remove the links and delete the template files. These pages are there as temporary navigation, and were never destined to stick around long term.

    * Given the above point, there will on;y be two entries in each submenu of the "admin" main menu. is it worth having a sub menu at all? Maybe, maybe not. I leave that to your discretion. It *might* be better to just have all four links under the 'Admin' menu.

Other than that, it looks great!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sloecode/controllers/person.py'
2--- sloecode/controllers/person.py 2011-01-22 22:13:38 +0000
3+++ sloecode/controllers/person.py 2011-01-30 19:22:01 +0000
4@@ -19,7 +19,7 @@
5 class PersonController(BaseController):
6 """PersonController renders pages for the person model.
7 """
8-
9+
10 @ActionProtector(Any(has_site_role(role=USER_ADMIN), owns_page()))
11 def index(self, person_name):
12 """Render the person details page.
13@@ -28,16 +28,16 @@
14 person = None
15 if len(ppl):
16 person = ppl[0]
17-
18+
19 return self.render('/person-details.html', {'person' : person})
20-
21+
22 # allow anonymous action, since all we do is redirect to a page with
23 # checks:
24 def me(self):
25 """Redirect to the main user page.
26 """
27 user = request.environ['repoze.who.identity'].get('user')
28- return redirect(url_for(controller='/person', action='index',
29+ return redirect(url_for(controller='/person', action='index',
30 person_name=user.login))
31-
32-
33\ No newline at end of file
34+
35+
36
37=== modified file 'sloecode/lib/helpers.py'
38--- sloecode/lib/helpers.py 2011-01-22 23:30:57 +0000
39+++ sloecode/lib/helpers.py 2011-01-30 19:22:01 +0000
40@@ -8,7 +8,7 @@
41 # in the future use the formencode field functions, wrapping them up in simple
42 # functions here. That way we can add a bit more intelligence in our web forms.
43 from webhelpers.html.tags import form, end_form, text, password, submit
44-from webhelpers.html.tags import stylesheet_link, ModelTags, hidden, select
45+from webhelpers.html.tags import stylesheet_link, javascript_link, ModelTags, hidden, select
46 from webhelpers.html.tags import checkbox, image
47
48 # url_for allows us to generate URLs for specific controllers on disk, which
49
50=== modified file 'sloecode/templates/base.html'
51--- sloecode/templates/base.html 2011-01-22 08:49:50 +0000
52+++ sloecode/templates/base.html 2011-01-30 19:22:01 +0000
53@@ -21,8 +21,10 @@
54 }
55 -->
56 </script>
57+ {# Navigation Include #}
58+ {{ nav.display_nav_includes() }}
59 </head>
60- <body>
61+ <body class="yui-skin-sam">
62 <div id="doc4" class="yui-t6" style="background-color: white; padding-left: 5px;">
63 <!-- style="background-color: #1845BA; padding-bottom: 5px;" -->
64 <div class="hd">
65@@ -32,7 +34,7 @@
66 {% endblock %}
67 </div>
68 <!-- Nav may go into the header (especially the site-wide stuff) -->
69- <div id="navbar">
70+ <div id="navbarx">
71 {{ nav.display_nav() }}
72 </div>
73
74
75=== modified file 'sloecode/templates/macros/nav.html'
76--- sloecode/templates/macros/nav.html 2011-01-07 09:08:54 +0000
77+++ sloecode/templates/macros/nav.html 2011-01-30 19:22:01 +0000
78@@ -1,29 +1,179 @@
79-
80 {# Macros to show the page navigation URLs. Ideally we'd somehow highlight the current
81 location, but this is good enough for now:
82 #}
83
84-{% macro display_nav() -%}
85-
86-
87- {# First - login OR logout link: #}
88- <span class="login_logout" style="padding-right: 25px;">
89- {% if identity is none %}
90- {{ h.link_to('Login', '/auth/login', class='login') }}
91- </span>
92- {% else %}
93- {{ h.link_to('Logout', '/auth/logout', class='login') }}
94- </span>
95- {# Then the user portal link: #}
96- {{ h.link_to(identity['user'].name, '/me', class='portal') }}
97-
98- {# User is logged in. If they're an admin, show the admin links: #}
99- {% if h.has_site_role(h.USER_ADMIN) %}
100- {{ h.link_to('Manage Users', '/a/person/index') }}
101- {%endif%}
102- {% if h.has_site_role(h.PROJECT_ADMIN) %}
103- {{ h.link_to('Manage Projects', '/a/project/manage') }}
104- {% endif %}
105- {% endif %}
106+{% macro display_nav_includes() %}
107+<!-- Core + Skin CSS -->
108+{{ h.stylesheet_link('/yui/2.8.2/menu/assets/skins/sam/menu.css') }}
109+<!-- Dependencies -->
110+{{ h.javascript_link('/yui/2.8.2/yahoo-dom-event/yahoo-dom-event.js')}}
111+{{ h.javascript_link('/yui/2.8.2/container/container_core-min.js')}}
112+<!-- Source File -->
113+{{ h.javascript_link('/yui/2.8.2/menu/menu-min.js')}}
114+
115+ {%- endmacro %}
116+
117+ {% macro display_nav() -%}
118+ <script type="text/javascript">
119+ YAHOO.util.Event.onContentReady("main_menubar", function () {
120+
121+ // Instantiate a Menu. The first argument passed to the
122+ // constructor is the id of the element in the DOM that represents
123+ // the Menu instance.
124+ var main_menu = new YAHOO.widget.MenuBar("main_menubar", { autosubmenudisplay: true });
125+ main_menu.render();
126+
127+ });
128+
129+</script>
130+
131+ {# Grab details for the user if available, so we can display relevant info for them #}
132+ {% if request.environ.get('repoze.who.identity') %}
133+ {% set user_details = request.environ['repoze.who.identity'].get('user') %}
134+ {% else %}
135+ {# Not entirely sure if required, but feel its good behaviour :) #}
136+ {% set user_details = none %}
137+ {% endif %}
138+
139+<div id="main_menubar" class="yuimenubar yuimenubarnav">
140+ <div class="bd">
141+ <ul class="first-of-type">
142+ {% if identity is none %}
143+ <li class="yuimenuitem">
144+ {{ h.link_to('Login',
145+ h.url_for(controller='/auth/login'),
146+ class='yuimenuitemlabel') }}
147+ </li>
148+ {% else %}
149+
150+ {% if user_details %}
151+ <li class="yuimenuitem">
152+ {{ h.link_to('Home',
153+ h.url_for(controller='/u/%s' % user_details.login),
154+ class='yuimenuitemlabel') }}
155+ </li>
156+ {% endif %}
157+
158+ {% if user_details and user_details.projects|length %}
159+ <li class="yuimenubaritem first-of-type">
160+ <a class="yuimenubaritemlabel" href="#proj_list" style="padding-left: 3px;">
161+ Projects
162+ </a>
163+
164+ <div id="proj_list" class="yuimenu">
165+ <div class="bd">
166+
167+ <ul>
168+ {# List of projects that this user is in #}
169+ {% if user_details %}
170+ {% for membership in user_details.projects %}
171+ <li class="yuimenuitem">
172+ {{ h.link_to(membership.project.name + ' project',
173+ h.url_for(controller='/project',
174+ project_name=membership.project.name)) }}
175+ </li>
176+ {% endfor %}
177+ {% endif %}
178+ </ul>
179+
180+ </div>
181+ </div>
182+ </li>
183+ {% endif %}
184+
185+ {% if h.has_site_role(h.PROJECT_ADMIN) %}
186+ <li class="yuimenubaritem first-of-type">
187+ <a class="yuimenubaritemlabel" href="#menu_admin">Admin</a>
188+
189+ <div id="menu_admin" class="yuimenu">
190+ <div class="bd">
191+ <ul>
192+
193+ <!-- Manage Projects + sub -->
194+ <li>
195+ <a class="yuimenuitemlabel" href="#">Manage Projects</a>
196+ <div id="menu_manage_proj" class="yuimenu">
197+ <div class="bd">
198+ <ul class="first-of-type">
199+ <li class="yuimenuitem">
200+ {{ h.link_to('Manage Projects',
201+ h.url_for(controller='/a/project/manage'),
202+ class='yuimenuitemlabel')
203+ }}
204+ </li>
205+ <li class="yuimenuitem">
206+ {{ h.link_to('List/Edit Projects',
207+ h.url_for(controller='/a/project/retrieve'),
208+ class='yuimenuitemlabel')
209+ }}
210+ </li>
211+ <li class="yuimenuitem">
212+ {{ h.link_to('Create Project',
213+ h.url_for(controller='/a/project/create'),
214+ class='yuimenuitemlabel')
215+ }}
216+ </li>
217+ <!-- <a class="yuimenuitemlabel" href="#">Create Project</a> -->
218+ <!-- <a class="yuimenuitemlabel" href="#">List Project</a> -->
219+ </ul>
220+ </div>
221+ </div>
222+ </li>
223+
224+ <!-- Manage Users + sub -->
225+ <li>
226+ <a class="yuimenuitemlabel" href="#">Manage Users</a>
227+ <div id="menu_manage_users" class="yuimenu">
228+ <div class="bd">
229+ <ul class="first-of-type">
230+ {% if h.has_site_role(h.USER_ADMIN) %}
231+ <li class="yuimenuitem">
232+ {{ h.link_to('Manage Users',
233+ h.url_for(controller='/a/person/index'),
234+ class='yuimenuitemlabel')
235+ }}
236+ </li>
237+
238+ <li class="yuimenuitem">
239+ {{ h.link_to('Create User',
240+ h.url_for(controller='/a/person/create'),
241+ class='yuimenuitemlabel')
242+ }}
243+ </li>
244+ <li class="yuimenuitem">
245+ {{ h.link_to('List/Edit Users',
246+ h.url_for(controller='/a/person/retrieve'),
247+ class='yuimenuitemlabel')
248+ }}
249+ </li>
250+ {%endif%}
251+ </ul>
252+ </div>
253+ </div>
254+ </li>
255+
256+ <li>
257+ <a class="yuimenuitemlabel" href="#">Manage Sloecode</a>
258+ </li>
259+ </ul>
260+ </div>
261+ </div>
262+
263+ </li>
264+ {% endif %}
265+
266+ <li class="yuimenubaritem first-of-type">
267+ {{ h.link_to('Logout',
268+ h.url_for('/auth/logout'),
269+ class='yuimenubaritemlabel')
270+ }}
271+ </li>
272+
273+ {% endif %}
274+ </ul>
275+ </div>
276+
277+</div>
278+
279
280 {%- endmacro %}

Subscribers

People subscribed via source and target branches