From: olivier <> Date: Sun, 20 May 2007 14:12:24 +0000 (+0000) Subject: add geographic navigator, coverage dc mapping to collection + other fixes X-Git-Tag: 1.1~934 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=294e691e6fe3ee67d7206fb7375fc8e7fcf0bc91;p=telemeta.git add geographic navigator, coverage dc mapping to collection + other fixes --- diff --git a/telemeta/htdocs/css/telemeta.css b/telemeta/htdocs/css/telemeta.css index caaaad4e..8c46e471 100644 --- a/telemeta/htdocs/css/telemeta.css +++ b/telemeta/htdocs/css/telemeta.css @@ -46,6 +46,14 @@ a img { border: none; } .item_visualization select { width: 200px; } .item_visualization img { width: 300px; border: solid 1px black; } +/* Geographic navigator */ +ul.continents, ul.continents ul { list-style: none; margin: 0; padding: 0;} +ul.continents { margin: 1em 1em; } +ul.continents ul {margin-left: 0; margin-bottom: 0.9em; padding: 0 1em 1em 0;} +ul.continents li.name { width: 480px; float: left;} +ul.continents li.name b { font-size: 120%; font-weight: bold; } +ul.continents ul li { display: inline; padding-right: 1ex;} + /* Styles for tabular listings (stolen from trac) */ table.listing { clear: both; diff --git a/telemeta/models.py b/telemeta/models.py index 689dde5b..661628b0 100644 --- a/telemeta/models.py +++ b/telemeta/models.py @@ -56,6 +56,36 @@ class MediaCollectionManager(models.Manager): Q(creator__icontains=pattern) ) + def by_country(self, country): + qs = super(MediaCollectionManager, self).get_query_set() + return qs.extra(where = ["id IN (SELECT collection_id " + "FROM telemeta_item WHERE etat = %s)"], + params=[country]); + + def stat_continents(self): + from django.db import connection + cursor = connection.cursor() + cursor.execute("SELECT continent, etat, count(*) AS items_num " + "FROM telemeta_collection INNER JOIN telemeta_item " + "ON telemeta_collection.id = telemeta_item.collection_id " + "WHERE (continent IN " + " ('EUROPE', 'OCEANIE', 'ASIE', 'AMERIQUE', 'AFRIQUE')) " + "AND etat <> '' " + "GROUP BY etat ORDER BY continent, items_num desc;") + result_set = cursor.fetchall() + stat = {} + for continent, country, count in result_set: + if stat.has_key(continent): + stat[continent].append({'name':country, 'count':count}) + else: + stat[continent] = [{'name':country, 'count':count}] + + keys = stat.keys() + keys.sort() + ordered = [{'name': k, 'countries': stat[k]} for k in keys] + return ordered + + class MediaCollection(models.Model, MediaCore): "Group related media items" @@ -221,6 +251,7 @@ class MediaItem(models.Model, MediaCore): dc.Element('title', 'title', self.title), dc.Element('creator', value=creator), dc.Element('publisher', value=self.collection.publisher), + dc.Element('coverage', value=self.etat), ) return resource diff --git a/telemeta/templates/base.html b/telemeta/templates/base.html index 0fb1e10e..7acd536b 100644 --- a/telemeta/templates/base.html +++ b/telemeta/templates/base.html @@ -26,8 +26,9 @@
diff --git a/telemeta/templates/collection_list.html b/telemeta/templates/collection_list.html index e02ad1dc..6d975df4 100644 --- a/telemeta/templates/collection_list.html +++ b/telemeta/templates/collection_list.html @@ -1,20 +1,11 @@ {% extends "base.html" %} {% load telemeta_utils %} + {% block content %}Records {{ first_on_page }} to {{ last_on_page }} on {{ hits }} - - {% if has_previous %} << {% endif %} - {% if has_next %} >> {% endif %} -
-No pieces are available.
-{% endif %} + +{% with object_list as collections %} +{% include "inc/collection_list.html" %} +{% endwith %} + {% endblock %} diff --git a/telemeta/templates/geo_continents.html b/telemeta/templates/geo_continents.html new file mode 100644 index 00000000..d59e9faa --- /dev/null +++ b/telemeta/templates/geo_continents.html @@ -0,0 +1,26 @@ +{% extends "base.html" %} +{% load telemeta_utils %} + +{% block content %} +No data
+{% endif %} +{% endblock %} diff --git a/telemeta/templates/geo_countries.html b/telemeta/templates/geo_countries.html new file mode 100644 index 00000000..b7f90a04 --- /dev/null +++ b/telemeta/templates/geo_countries.html @@ -0,0 +1,13 @@ +{% extends "base.html" %} +{% load telemeta_utils %} + +{% block content %} +Records {{ first_on_page }} to {{ last_on_page }} on {{ hits }} + + {% if has_previous %} << {% endif %} + {% if has_next %} >> {% endif %} +
+ {% endif %} +No collection
+{% endif %} diff --git a/telemeta/templates/inc/mediaitem_list.html b/telemeta/templates/inc/mediaitem_list.html new file mode 100644 index 00000000..a74c8543 --- /dev/null +++ b/telemeta/templates/inc/mediaitem_list.html @@ -0,0 +1,16 @@ +{% if items %} + {% if hits %} +Records {{ first_on_page }} to {{ last_on_page }} on {{ hits }} + + {% if has_previous %} << {% endif %} + {% if has_next %} >> {% endif %} +
+ {% endif %} +No piece
+{% endif %} diff --git a/telemeta/templates/mediaitem_list.html b/telemeta/templates/mediaitem_list.html index b0522771..d94e3e96 100644 --- a/telemeta/templates/mediaitem_list.html +++ b/telemeta/templates/mediaitem_list.html @@ -2,18 +2,7 @@ {% block content %}Records {{ first_on_page }} to {{ last_on_page }} on {{ hits }} - - {% if has_previous %} << {% endif %} - {% if has_next %} >> {% endif %} -
-No pieces are available.
-{% endif %} +{% with object_list as items %} +{% include "inc/mediaitem_list.html" %} +{% endwith %} {% endblock %} diff --git a/telemeta/templates/search_results.html b/telemeta/templates/search_results.html index e0aba8bb..45bbe182 100644 --- a/telemeta/templates/search_results.html +++ b/telemeta/templates/search_results.html @@ -4,32 +4,11 @@- - {{ c.title }} - - | -- [{{c.id}}] - | -