Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Now top clicked links works with the ModelAdmin.get_urls() method, de…

…moved unused admn.views and admin.urls
  • Loading branch information...
commit 37effd99c97705b3ecd90d8c579dca449b248a4c 1 parent 019fa4c
jj authored
View
27 LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2009, Jesús Del Carpio individual contributors.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. Neither the name of Django nor the names of its contributors may be used
+ to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
6 external_links/admin/urls.py
@@ -1,6 +0,0 @@
-from django.conf.urls.defaults import url, patterns
-
-urlpatterns = patterns('external_links.admin.views',
- url(r'^top/$',
- 'top_links', name='external_link_top_links'),
-)
View
17 external_links/admin/views.py
@@ -1,17 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from django.db.models import Count
-from django.template import RequestContext
-from django.views.generic.list_detail import object_list
-from django.contrib.admin.views.decorators import staff_member_required
-
-from external_links.models import LinkClick
-
-@staff_member_required
-def top_links(request):
- summary = \
- LinkClick.objects.values('link').annotate(Count('link')).order_by('-link__count')
-
- return object_list(request, summary,
- template_name='external_links/links_report.html')
-
View
96 external_links/templates/external_links/change_list.html
@@ -0,0 +1,96 @@
+{% extends "admin/base_site.html" %}
+{% load adminmedia admin_list i18n %}
+
+{% block extrastyle %}
+ {{ block.super }}
+ <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/changelists.css" />
+ {% if cl.formset %}
+ <link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/forms.css" />
+ <script type="text/javascript" src="../../jsi18n/"></script>
+ {% endif %}
+ {{ media }}
+ {% if not actions_on_top and not actions_on_bottom %}
+ <style>
+ #changelist table thead th:first-child {width: inherit}
+ </style>
+ {% endif %}
+ <style>
+ #top-links table { width:100% !important; }
+ </style>
+{% endblock %}
+
+{% block bodyclass %}change-list{% endblock %}
+
+{% if not is_popup %}
+ {% block breadcrumbs %}
+ <div class="breadcrumbs">
+ <a href="../../">
+ {% trans "Home" %}
+ </a>
+ &rsaquo;
+ <a href="../">
+ {{ app_label|capfirst }}
+ </a>
+ &rsaquo;
+ {{ cl.opts.verbose_name_plural|capfirst }}
+ </div>
+ {% endblock %}
+{% endif %}
+
+{% block coltype %}flex{% endblock %}
+
+{% block content %}
+ <div id="content-main">
+ {% block object-tools %}
+ {% if has_add_permission %}
+ <ul class="object-tools">
+ <li>
+ <a href="add/{% if is_popup %}?_popup=1{% endif %}" class="addlink">
+ {% blocktrans with cl.opts.verbose_name as name %}Add {{ name }}{% endblocktrans %}
+ </a>
+ </li>
+ </ul>
+ {% endif %}
+ {% endblock %}
+ {% if cl.formset.errors %}
+ <p class="errornote">
+ {% blocktrans count cl.formset.errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
+ </p>
+ <ul class="errorlist">{% for error in cl.formset.non_field_errors %}<li>{{ error }}</li>{% endfor %}</ul>
+ {% endif %}
+
+ <div class="module" id="top-links">
+ <table>
+ <caption>{% trans "Top clicked links"%}</caption>
+ <tbody><tr><th><a href="{% url external_link_top_links %}" title="{% trans "Top clicked links"%}">{% trans "Top clicked links"%}</a></th><td></td><td></td></tr></tbody>
+ </table>
+ </div>
+
+ <div class="module{% if cl.has_filters %} filtered{% endif %}" id="changelist">
+ {% block search %}{% search_form cl %}{% endblock %}
+ {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}
+
+ {% block filters %}
+ {% if cl.has_filters %}
+ <div id="changelist-filter">
+ <h2>{% trans 'Filter' %}</h2>
+ {% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
+ </div>
+ {% endif %}
+ {% endblock %}
+
+ <form action="" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %}>
+ {% if cl.formset %}
+ {{ cl.formset.management_form }}
+ {% endif %}
+
+ {% block result_list %}
+ {% if action_form and actions_on_top and cl.full_result_count %}{% admin_actions %}{% endif %}
+ {% result_list cl %}
+ {% if action_form and actions_on_bottom and cl.full_result_count %}{% admin_actions %}{% endif %}
+ {% endblock %}
+ {% block pagination %}{% pagination cl %}{% endblock %}
+ </form>
+ </div>
+ </div>
+{% endblock %}
Please sign in to comment.
Something went wrong with that request. Please try again.