Skip to content

Commit dc81d10

Browse files
author
Rebecca Lovewell
committed
Use a template include for extra_nav
1 parent 026bc6e commit dc81d10

File tree

6 files changed

+25
-62
lines changed

6 files changed

+25
-62
lines changed

docs/settings.rst

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,6 @@ Settings
44
All django-timepiece settings are optional. Default values are given in
55
``timepiece.defaults`` and can be overriden in your project's settings.
66

7-
.. _TIMEPIECE_EXTRA_NAV:
8-
9-
TIMEPIECE_EXTRA_NAV
10-
-------------------
11-
12-
:Default: ``{}``
13-
14-
This is an optional setting that is used to add extra navigation items to the
15-
global navigation bar displayed at the top of each django-timepiece page. The
16-
setting uses `Twitter Bootstrap's <http://twitter.github.com/bootstrap/>`_
17-
dropdown navigation. The setting can be declared as follows:
18-
19-
.. code-block:: python
20-
21-
TIMEPIECE_EXTRA_NAV = {
22-
'Dropdown Text': [
23-
('named_url_1', 'Dropdown Item #1',),
24-
('named_url_2', 'Dropdown Item #2',),
25-
], ...
26-
}
27-
28-
For example, the following would add a "Paste Bin" dropdown menu with the two
29-
links "Make a Paste" and "View my Pastes" as menu items in that dropdown.
30-
31-
.. code-block:: python
32-
33-
TIMEPIECE_EXTRA_NAV = {
34-
'Paste Bin': [
35-
('create_paste_view', 'Make a Paste',),
36-
('user_paste_view', 'View my Pastes',),
37-
],
38-
}
39-
40-
You can add as many menu items as you wish and are only limited by the space
41-
available in the navigation bar. Any navigation item that you add will appear
42-
following the django-timepiece related navigation items.
43-
44-
Note: To take advantage of this feature, you must have the context processor
45-
`timepiece.context_processors.extra_nav` listed in Django's
46-
`TEMPLATE_CONTEXT_PROCESSORS` setting.
47-
487
.. _TIMEPIECE_DEFAULT_LOCATION_SLUG:
498

509
TIMEPIECE_DEFAULT_LOCATION_SLUG

example_project/settings/base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
'django.contrib.messages.context_processors.messages',
9595
'django.core.context_processors.request',
9696
'timepiece.context_processors.quick_search',
97-
'timepiece.context_processors.extra_nav',
9897
'timepiece.context_processors.quick_clock_in',
9998
)
10099

@@ -172,5 +171,4 @@
172171

173172
# django-timepiece settings
174173
TIMEPIECE_DEFAULT_LOCATION_SLUG = None
175-
TIMEPIECE_PROJECTS = {}
176-
EXTRA_NAV = {}
174+
TIMEPIECE_PAID_LEAVE_PROJECTS = {}

timepiece/context_processors.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,3 @@ def quick_clock_in(request):
5050
'leave_projects': leave_projects,
5151
'work_projects': work_projects,
5252
}
53-
54-
55-
def extra_nav(request):
56-
return {
57-
'timepiece_extra_nav': utils.get_setting('TIMEPIECE_EXTRA_NAV'),
58-
}

timepiece/defaults.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
class TimepieceDefaults(object):
55

6-
TIMEPIECE_EXTRA_NAV = {}
7-
86
TIMEPIECE_DEFAULT_LOCATION_SLUG = None
97

108
TIMEPIECE_PAID_LEAVE_PROJECTS = {}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{% comment %}
2+
You can override this template to include extra, custom items in the timepiece
3+
navigation bar.
4+
We use Bootstrap styling so you can use both plain navigation items and
5+
dropdown navigation items.
6+
7+
For example:
8+
9+
<!-- A dropdown menu item. -->
10+
<li class="dropdown">
11+
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Paste Bin <b class="caret"></b></a>
12+
<ul class="dropdown-menu">
13+
<li><a href="{% url 'create_paste' %}">Create Paste</a></li>
14+
<li><a href="{% url 'list_pastes' %}">View Pastes</a></li>
15+
</ul>
16+
</li>
17+
18+
<!-- A plain menu item. -->
19+
<li>
20+
<a href="http://example.com/">Example</a>
21+
</li>
22+
23+
{% endcomment %}

timepiece/templates/timepiece/navigation.html

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,7 @@
8181
</li>
8282
{% endif %}
8383

84-
{% for name, links in timepiece_extra_nav.items %}
85-
<li class="dropdown">
86-
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ name }} <b class="caret"></b></a>
87-
<ul class="dropdown-menu">
88-
{% for url_name, link_text in links %}
89-
<li><a href="{% url url_name %}">{{ link_text }}</a></li>
90-
{% endfor %}
91-
</ul>
92-
</li>
93-
{% endfor %}
84+
{% include "timepiece/extra_nav.html" %}
9485
</ul>
9586
{% endblock %}
9687

0 commit comments

Comments
 (0)