Changeset 573 for tags/telemeta-0.5.0

Show
Ignore:
Timestamp:
02/16/10 22:24:31 (7 months ago)
Author:
olivier
Message:

merge r572 into telemeta 0.5.0 tag

Location:
tags/telemeta-0.5.0
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • tags/telemeta-0.5.0

    • Property svn:mergeinfo changed
      /trunkmerged: 572
  • tags/telemeta-0.5.0/telemeta/models/query.py

    r564 r573  
    123123             
    124124            countries = ordered 
     125        else: 
     126            countries.sort(self.__name_cmp) 
    125127             
    126128        return countries                     
     
    327329        return unaccent_icmp(obj1.name, obj2.name) 
    328330 
    329     def stat_continents(self, only_continent=None):       
    330         "Return the number of collections by continents and countries as a tree" 
    331  
    332         from telemeta.models.media import MediaItem 
    333         from telemeta.models.location import Location 
    334  
    335         countries = [] 
    336         for lid in MediaItem.objects.filter(location__isnull=False).values_list('location', flat=True).distinct(): 
    337             location = Location.objects.get(pk=lid) 
    338             if not only_continent or (only_continent in location.continents()): 
    339                 for l in location.countries(): 
    340                     if not l in countries: 
    341                         countries.append(l) 
    342                  
    343         stat = {} 
    344  
    345         for country in countries: 
    346             count = country.collections().count() 
    347             for continent in country.continents(): 
    348                 if not stat.has_key(continent): 
    349                     stat[continent] = {} 
    350  
    351                 stat[continent][country] = count 
    352                  
    353         keys1 = stat.keys() 
    354         keys1.sort(self.__name_cmp) 
    355         ordered = [] 
    356         for c in keys1: 
    357             keys2 = stat[c].keys() 
    358             keys2.sort(self.__name_cmp) 
    359             sub = [{'location': d, 'count': stat[c][d]} for d in keys2] 
    360             ordered.append({'location': c, 'countries': sub}) 
    361          
    362         return ordered 
    363  
    364331class LocationQuerySet(CoreQuerySet): 
    365332    __flatname_map = None 
  • tags/telemeta-0.5.0/telemeta/templates/telemeta_default/geo_countries.html

    r571 r573  
    33{% load i18n %} 
    44 
    5 {% block head_title %}{{ continent.location.name }} - {% trans "Geographic Navigator" %} - {{ block.super }}{% endblock %} 
     5{% block head_title %}{{ continent }} - {% trans "Geographic Navigator" %} - {{ block.super }}{% endblock %} 
    66 
    77{% block content %} 
    88<h3><a href="{% url telemeta-geo-continents %}">{% trans "World" %}</a> / 
    9   {{ continent.location.name }}</h3> 
    10 <ul> 
    11 {% for country in continent.countries %} 
    12   <li><a href="{% url telemeta-geo-country-collections continent.location.flatname,country.location.flatname %}"> 
    13     {{ country.location.name }} ({{ country.count }})</a></li> 
     9  {{ continent }}</h3> 
     10<table class="listing"> 
     11<tr> 
     12    <th>{% trans "Country" %}</th> 
     13    <th>{% trans "Number of collections" %}</th> 
     14    <th>{% trans "Number of items" %}</th> 
     15</tr> 
     16{% for country in countries %} 
     17<tr> 
     18  <td>{{ country }}</td> 
     19  <td> 
     20  {% with country.collections.count as num %} 
     21  <a href="{% url telemeta-geo-country-collections continent.flatname,country.flatname %}"> 
     22  {% blocktrans count num as counter %}1 collection{% plural %}{{ counter }} collections{% endblocktrans %} 
     23  </a> 
     24  {% endwith %} 
     25  </td> 
     26  <td> 
     27  {% with country.items.count as num %} 
     28  <a href="{% url telemeta-geo-country-items continent.flatname,country.flatname %}"> 
     29  {% blocktrans count num as counter %}1 item{% plural %}{{ counter }} items {% endblocktrans %} 
     30  </a> 
     31  {% endwith %} 
     32  </td> 
     33</tr>   
    1434{% endfor %} 
    15 </ul> 
     35</table> 
    1636{% endblock %} 
  • tags/telemeta-0.5.0/telemeta/web/base.py

    r561 r573  
    388388    def list_countries(self, request, continent):                     
    389389        continent = Location.objects.by_flatname(continent)[0] 
    390         data = MediaCollection.objects.stat_continents(only_continent=continent) 
    391  
    392         return render_to_response('telemeta/geo_countries.html', {'continent': data[0] }) 
     390        countries = MediaItem.objects.by_location(continent).countries() 
     391 
     392        return render_to_response('telemeta/geo_countries.html', { 
     393            'continent': continent, 
     394            'countries': countries 
     395        }) 
    393396 
    394397    def list_country_collections(self, request, continent, country):