diff --git a/external_links/admin.py b/external_links/admin.py
new file mode 100644
index 0000000..c7c6479
--- /dev/null
+++ b/external_links/admin.py
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+
+from django.conf.urls import patterns, url
+from django.contrib import admin
+from django.db.models import Count
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+from django.utils.translation import ugettext as _
+
+from external_links.models import LinkClick
+
+class LinkClickAdmin(admin.ModelAdmin):
+ search_fields = ('link', 'referer', 'ip_addr' )
+ date_hierarchy = 'date'
+ list_filter = ('site', )
+ list_display = ('link', 'referer', 'ip_addr', 'date', 'time')
+
+ change_list_template = 'external_links/change_list.html'
+
+ def has_add_permission(self, request):
+ return False
+
+ def top_links(self, request):
+ """
+ This view shows the top clicked external links
+ """
+ context = {
+ 'objects': LinkClick.objects.values('link').annotate(Count('link')).order_by('-link__count'),
+ 'title': _('Top clicked links'),
+ 'app_label': self.model._meta.app_label,
+ 'model_label': self.model._meta.verbose_name_plural,
+ }
+ return render_to_response('external_links/top_links.html',
+ context,
+ context_instance=RequestContext(request))
+
+ def get_urls(self):
+ urls = super(LinkClickAdmin, self).get_urls()
+ my_urls = patterns('',
+ url(r'^top/$',
+ self.admin_site.admin_view(self.top_links),
+ name='external_link_top_clicks')
+ )
+
+ return my_urls + urls
+admin.site.register(LinkClick, LinkClickAdmin)
+
diff --git a/external_links/admin/__init__.py b/external_links/admin/__init__.py
deleted file mode 100644
index d2300b9..0000000
--- a/external_links/admin/__init__.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# -*- coding: utf-8 -*-
-
-from django.contrib import admin
-from django.db.models import Count
-from django.conf.urls.defaults import patterns, url
-from django.views.generic.list_detail import object_list
-
-from external_links.models import LinkClick
-
-class LinkClickAdmin(admin.ModelAdmin):
- search_fields = ('link', 'referer', 'ip_addr' )
- date_hierarchy = 'date'
- list_filter = ('site', )
- list_display = ('link', 'referer', 'ip_addr', 'date', 'time')
-
- change_list_template = 'external_links/change_list.html'
-
- def top_links(self, request):
- """
- This view shows the top clicked external links
- """
- summary = LinkClick.objects.values('link').annotate(
- Count('link')).order_by('-link__count')
-
- return object_list(request, summary,
- template_name='external_links/top_links.html')
-
-
- def get_urls(self):
- urls = super(LinkClickAdmin, self).get_urls()
- my_urls = patterns('',
- url(r'^top/$',
- self.admin_site.admin_view(self.top_links),
- name='external_link_top_clicks')
- )
-
- return my_urls + urls
-
-
diff --git a/external_links/templates/external_links/change_list.html b/external_links/templates/external_links/change_list.html
index 3ec1449..0f3aff1 100644
--- a/external_links/templates/external_links/change_list.html
+++ b/external_links/templates/external_links/change_list.html
@@ -1,96 +1,9 @@
-{% extends "admin/base_site.html" %}
-{% load adminmedia admin_list i18n %}
-
-{% block extrastyle %}
- {{ block.super }}
-
- {% if cl.formset %}
-
-
- {% endif %}
- {{ media }}
- {% if not actions_on_top and not actions_on_bottom %}
-
- {% endif %}
-
-{% endblock %}
-
-{% block bodyclass %}change-list{% endblock %}
-
-{% if not is_popup %}
- {% block breadcrumbs %}
-
- {% endblock %}
-{% endif %}
-
-{% block coltype %}flex{% endblock %}
-
-{% block content %}
-
- {% block object-tools %}
- {% if has_add_permission %}
-
- {% endif %}
- {% endblock %}
- {% if cl.formset.errors %}
-
- {% blocktrans count cl.formset.errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
-
-
{% for error in cl.formset.non_field_errors %}- {{ error }}
{% endfor %}
- {% endif %}
-
-
-
-
- {% block search %}{% search_form cl %}{% endblock %}
- {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}
-
- {% block filters %}
- {% if cl.has_filters %}
-
-
{% trans 'Filter' %}
- {% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %}
-
- {% endif %}
- {% endblock %}
-
-
-
-
+{% extends "admin/change_list.html" %}
+{% load i18n %}
+{% block object-tools %}
+
{% endblock %}
diff --git a/external_links/templates/external_links/top_links.html b/external_links/templates/external_links/top_links.html
index 75bd3c2..a1dc578 100644
--- a/external_links/templates/external_links/top_links.html
+++ b/external_links/templates/external_links/top_links.html
@@ -1,63 +1,36 @@
-{% extends "admin/base_site.html" %}
-{% load adminmedia admin_list i18n %}
-{% block title %}
-{% trans "Top clicked links" %} {{block.super}}
-{% endblock %}
-
-{% block extrastyle %}
- {{ block.super }}
-
- {% if cl.formset %}
-
-
- {% endif %}
- {{ media }}
- {% if not actions_on_top and not actions_on_bottom %}
-
- {% endif %}
-{% endblock %}
-
-{% block bodyclass %}change-list{% endblock %}
+{% extends "admin/change_list.html" %}
+{% load i18n %}
{% if not is_popup %}
-{% block breadcrumbs %}
-
-{% endblock %}
+ {% block breadcrumbs %}
+
+ {% endblock %}
{% endif %}
-{% block coltype %}flex{% endblock %}
-
{% block content %}
-
-{% trans "Top clicked links" %}
-
-
-
-
-
-Link | Count |
-
-
-
-{% for link in object_list %}
-{{link.link}} | {{link.link__count}} |
-{% endfor %}
-
-
-
-
-{% if pagination_required %}
-{# how to paginate a valuesqueryset?? #}
-
-
-{% endif %}
-
+
+
+
+
+
+ Click |
+ Link |
+
+
+
+ {% for obj in objects %}
+
+ {{ obj.link__count }} |
+ {{ obj.link }} |
+
+ {% endfor %}
+
+
+
+
{% endblock %}
diff --git a/external_links/urls.py b/external_links/urls.py
index 0b3ba7c..c4578be 100644
--- a/external_links/urls.py
+++ b/external_links/urls.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-from django.conf.urls.defaults import url, patterns
+from django.conf.urls import url, patterns
urlpatterns = patterns('external_links.views',
url(r'^$',