Mercurial > public > sg101
changeset 145:71cb4208dc98
Tweak to #30, admin dashboard. Because of a bug in Django (9568), my dashboard appears on the login page. To get around this, pass in the user to the templatetag, so it can do a 'if user.is_staff' check. Also tweaked the HTML and CSS to show non-zero pending items in red. Shortened the pending item titles for readability.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 09 Dec 2009 00:03:10 +0000 |
parents | 49b713bca29d |
children | 023132c90021 |
files | gpp/core/templatetags/custom_admin_tags.py gpp/templates/admin/base_site.html gpp/templates/core/admin_dashboard.html |
diffstat | 3 files changed, 23 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/gpp/core/templatetags/custom_admin_tags.py Sun Dec 06 21:44:22 2009 +0000 +++ b/gpp/core/templatetags/custom_admin_tags.py Wed Dec 09 00:03:10 2009 +0000 @@ -17,7 +17,7 @@ @register.inclusion_tag('core/admin_dashboard.html') -def admin_dashboard(): +def admin_dashboard(user): """ This tag is used in the admin to create a dashboard of pending content that an admin must approve. @@ -34,6 +34,7 @@ new_links = Link.objects.filter(is_public=False).count() return { + 'user': user, 'flagged_profiles': flagged_profiles, 'flagged_comments': flagged_comments, 'new_downloads': new_downloads,
--- a/gpp/templates/admin/base_site.html Sun Dec 06 21:44:22 2009 +0000 +++ b/gpp/templates/admin/base_site.html Wed Dec 09 00:03:10 2009 +0000 @@ -14,6 +14,10 @@ margin-right: 10px; margin-bottom: 4px; } + #dashboard-list .alert { + color: #f55; + font-weight: bold; + } </style> {% endblock %} @@ -23,4 +27,4 @@ <h1 id="site-name">{% trans 'SurfGuitar101.com Site Administration' %}</h1> {% endblock %} -{% block nav-global %}{% admin_dashboard %}{% endblock %} +{% block nav-global %}{% admin_dashboard user %}{% endblock %}
--- a/gpp/templates/core/admin_dashboard.html Sun Dec 06 21:44:22 2009 +0000 +++ b/gpp/templates/core/admin_dashboard.html Wed Dec 09 00:03:10 2009 +0000 @@ -1,9 +1,18 @@ +{% if user.is_staff %} <ul id="dashboard-list"> - <li><a href="/admin/forums/flaggedpost/">Flagged Posts</a>: {{ flagged_posts }}</li> - <li><a href="/admin/comments/commentflag/">Flagged Comments</a>: {{ flagged_comments }}</li> - <li><a href="/admin/bio/userprofileflag/">Flagged Profiles</a>: {{ flagged_profiles }}</li> - <li><a href="/admin/gcalendar/event/">Calendar Requests</a>: {{ event_requests }}</li> - <li><a href="/admin/news/pendingstory/">New Stories</a>: {{ new_stories }}</li> - <li><a href="/admin/downloads/download/">New Downloads</a>: {{ new_downloads }}</li> - <li><a href="/admin/weblinks/link/">New Links</a>: {{ new_links }}</li> +<li><a href="/admin/forums/flaggedpost/">Posts</a>: +<span {% if flagged_posts %}class="alert"{% endif %}>{{ flagged_posts }}</span></li> +<li><a href="/admin/comments/commentflag/">Comments</a>: +<span {% if flagged_comments %}class="alert"{% endif %}>{{ flagged_comments }}</span></li> +<li><a href="/admin/bio/userprofileflag/">Profiles</a>: +<span {% if flagged_profiles %}class="alert"{% endif %}>{{ flagged_profiles }}</span></li> +<li><a href="/admin/gcalendar/event/">Calendar</a>: +<span {% if event_requests %}class="alert"{% endif %}>{{ event_requests }}</span></li> +<li><a href="/admin/news/pendingstory/">News</a>: +<span {% if new_stories %}class="alert"{% endif %}>{{ new_stories }}</span></li> +<li><a href="/admin/downloads/download/">Downloads</a>: +<span {% if new_downloads %}class="alert"{% endif %}>{{ new_downloads }}</span></li> +<li><a href="/admin/weblinks/link/">Links</a>: +<span {% if new_links %}class="alert"{% endif %}>{{ new_links }}</span></li> </ul> +{% endif %}