Changeset 5889b86
- Timestamp:
- 02/08/10 17:14:23 (3 years ago)
- Branches:
- master, crem, crem2, dev, diadems, forma, generic, instru_search, lam, nlivemulti, production, release/1.4.4, security, social, storage, test, video
- Children:
- 792cd0d
- Parents:
- 653e7d2
- git-author:
- olivier <> (02/08/10 17:14:23)
- git-committer:
- olivier <> (02/08/10 17:14:23)
- Location:
- telemeta
- Files:
-
- 4 added
- 8 edited
-
htdocs/js/resourcemap.js (modified) (3 diffs)
-
models/cremquery.py (modified) (1 diff)
-
templates/telemeta/country_info.html (added)
-
templates/telemeta/geo_country_items.html (added)
-
templates/telemeta_default/country_info.html (added)
-
templates/telemeta_default/geo_continents.html (modified) (2 diffs)
-
templates/telemeta_default/geo_country_items.html (added)
-
templates/telemeta_default/inc/collection_list.html (modified) (1 diff)
-
templates/telemeta_default/inc/mediaitem_list.html (modified) (1 diff)
-
templatetags/telemeta_utils.py (modified) (2 diffs)
-
urls.py (modified) (1 diff)
-
web/base.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
telemeta/htdocs/js/resourcemap.js
r7365a0d r5889b86 6 6 7 7 that.init = function(list, cfg) { 8 that.cfg = cfg; 8 9 $(document).ready(function() { 9 10 that.log("init"); … … 67 68 } 68 69 70 that.showResourceInfo = function(marker, resourceElement) { 71 var info = $('<div/>').addClass('resourcemap-info'); 72 marker.openInfoWindowHtml(info.get(0)); 73 var re = /^resource-/; 74 var id = resourceElement.attr('id').replace(re, ''); 75 var uri = that.cfg.countryInfoUri.replace('RESOURCEID', id); 76 77 $.get(uri, function(data) { 78 info.html(data); 79 }); 80 } 81 69 82 that.parseResources = function() { 70 83 $('.resourcemap-element').each(function(i, e) { … … 74 87 var lat = parseFloat(input.attr('value')); 75 88 var lng = parseFloat(e.find('.resourcemap-lng').attr('value')); 76 var name = $.trim(e.find('.resourcemap-name').text());77 var link = e.find('a').attr('href');78 var linktitle = e.find('a').attr('title');89 //var name = $.trim(e.find('.resourcemap-name').text()); 90 //var link = e.find('a').attr('href'); 91 //var linktitle = e.find('a').attr('title'); 79 92 var marker = new google.maps.Marker(new GLatLng(lat, lng), {title: name}); 80 var info = that.makeInfoBox(name, link, linktitle);93 //var info = that.makeInfoBox(name, link, linktitle); 81 94 google.maps.Event.addListener(marker, "click", function() { 82 marker.openInfoWindowHtml(info); 95 that.showResourceInfo(marker, e); 96 //marker.openInfoWindowHtml(info); 83 97 }); 84 98 that.map.addOverlay(marker); -
telemeta/models/cremquery.py
rbe51b23 r5889b86 252 252 descendants = LocationRelation.objects.filter(ancestor_location=location) 253 253 return self.filter(Q(location=location) | Q(location__in=descendants)) 254 255 @staticmethod 256 def __name_cmp(obj1, obj2): 257 return unaccent_icmp(obj1.name, obj2.name) 258 259 def countries(self, group_by_continent=False): 260 from telemeta.models import Location 261 countries = [] 262 for id in self.filter(location__isnull=False).values_list('location', flat=True).distinct(): 263 location = Location.objects.get(pk=id) 264 for l in location.countries(): 265 if not l in countries: 266 countries.append(l) 267 268 if group_by_continent: 269 grouped = {} 270 271 for country in countries: 272 for continent in country.continents(): 273 if not grouped.has_key(continent): 274 grouped[continent] = [] 275 276 grouped[continent].append(country) 277 278 keys = grouped.keys() 279 keys.sort(self.__name_cmp) 280 ordered = [] 281 for c in keys: 282 grouped[c].sort(self.__name_cmp) 283 ordered.append({'continent': c, 'countries': grouped[c]}) 254 284 285 countries = ordered 286 287 return countries 288 255 289 class MediaItemManager(CoreManager): 256 290 "Manage media items queries" -
telemeta/templates/telemeta_default/geo_continents.html
r7365a0d r5889b86 8 8 <script src="{% url telemeta-js "resourcemap.js" %}" type="text/javascript"></script> 9 9 <script type="text/javascript"> 10 var resourceMap = new ResourceMap('.continents'); 10 var resourceMap = new ResourceMap('.continents', { 11 'countryInfoUri': '{% url telemeta-country-info "RESOURCEID" %}' 12 }); 11 13 </script> 12 14 {% endif %} … … 23 25 {% if continents %} 24 26 <ul class="continents"> 25 {% for continentin continents %}26 <li class="name"><b><a href="{% url telemeta-geo-countries continent.location.flatname %}">{{ continent.location}}</a></b>27 {% for group in continents %} 28 <li class="name"><b><a href="{% url telemeta-geo-countries group.continent.flatname %}">{{ group.continent }}</a></b> 27 29 <ul> 28 {% for country in continent.countries %} 29 <li class="country_name resourcemap-element"> 30 <a href="{% url telemeta-geo-country-collections continent.location.flatname,country.location.flatname %}" 31 title="{{ country.count }} {% trans "collections" %}"> 32 <span class="resourcemap-name">{{ country.location }}</span></a> 33 {% if not country.location.latitude|is_none and not country.location.longitude|is_none %} 34 <input type="hidden" class="resourcemap-lat" value="{{country.location.latitude}}" /> 35 <input type="hidden" class="resourcemap-lng" value="{{country.location.longitude}}" /> 30 {% for country in group.countries %} 31 <li id="resource-{{country.id}}" class="country_name resourcemap-element"> 32 <a href="{% url telemeta-geo-country-collections group.continent.flatname,country.flatname %}"> 33 <span class="resourcemap-name">{{ country }}</span></a> 34 {% if not country.latitude|is_none and not country.longitude|is_none %} 35 <input type="hidden" class="resourcemap-lat" value="{{country.latitude}}" /> 36 <input type="hidden" class="resourcemap-lng" value="{{country.longitude}}" /> 36 37 {% endif %} 37 38 </li> 38 39 {% endfor %} 39 {% if continent.countries.10 %}40 <li><a href="{% url telemeta-geo-countries continent.location.flatname %}">More..</a></li>40 {% if group.countries.10 %} 41 <li><a href="{% url telemeta-geo-countries group.continent.flatname %}">More..</a></li> 41 42 {% endif %} 42 43 </ul> -
telemeta/templates/telemeta_default/inc/collection_list.html
ra2e58a9 r5889b86 2 2 {% if collections %} 3 3 {% if hits %} 4 <p class="pagination"> Records {{ first_on_page }} to {{ last_on_page }} on {{ hits }}4 <p class="pagination">Collections {{ first_on_page }} to {{ last_on_page }} on {{ hits }} 5 5 6 6 {% if has_previous %} <a href="?page={{ previous }}&{{criteria|build_query_string}}"><<</a> {% endif %} -
telemeta/templates/telemeta_default/inc/mediaitem_list.html
ra2e58a9 r5889b86 2 2 {% if items %} 3 3 {% if hits %} 4 <p class="pagination"> Records {{ first_on_page }} to {{ last_on_page }} on {{ hits }}4 <p class="pagination">Items {{ first_on_page }} to {{ last_on_page }} on {{ hits }} 5 5 6 6 {% if has_previous %} <a href="?page={{ previous }}&{{criteria|build_query_string}}"><<</a> {% endif %} -
telemeta/templatetags/telemeta_utils.py
r7365a0d r5889b86 7 7 from django import template 8 8 from django.utils.text import capfirst 9 from telemeta import models 10 from django.utils.translation import ungettext 9 11 10 12 register = template.Library() … … 173 175 def is_none(value): 174 176 return value is None 177 178 @register.filter 179 def resources_num(value): 180 model = value.model 181 count = value.count() 182 label = str(count) 183 if model == models.MediaItem: 184 label = ungettext('%(count)d item', '%(count)d items', count) % { 185 'count': count, } 186 elif model == models.MediaCollection: 187 label = ungettext('%(count)d collection', '%(count)d collections', count) % { 188 'count': count, } 189 190 return label 191 -
telemeta/urls.py
rfc6b123 r5889b86 139 139 url(r'^geo/(?P<continent>[a-z_]+)/$', web_view.list_countries, 140 140 name="telemeta-geo-countries"), 141 url(r'^geo/ (?P<continent>[a-z_]+)/(?P<country>[a-z_]+)/$',141 url(r'^geo/collections/(?P<continent>[a-z_]+)/(?P<country>[a-z_]+)/$', 142 142 web_view.list_country_collections, 143 143 name="telemeta-geo-country-collections"), 144 url(r'^geo/items/(?P<continent>[a-z_]+)/(?P<country>[a-z_]+)/$', 145 web_view.list_country_items, 146 name="telemeta-geo-country-items"), 144 147 url(r'^dynjs/continents.js$', web_view.get_continents_js, name="telemeta-continents-js"), 148 url(r'^geo/country_info/(?P<id>[0-9A-Z]+)/$', 149 web_view.country_info, name="telemeta-country-info"), 145 150 146 151 # CSS+Images (FIXME: for developement only) -
telemeta/web/base.py
r7365a0d r5889b86 338 338 339 339 def list_continents(self, request): 340 continents = Media Collection.objects.stat_continents()340 continents = MediaItem.objects.all().countries(group_by_continent=True) 341 341 return render_to_response('telemeta/geo_continents.html', 342 342 {'continents': continents, 'gmap_key': settings.TELEMETA_GMAP_KEY }) 343 344 def country_info(self, request, id): 345 country = Location.objects.get(pk=id) 346 return render_to_response('telemeta/country_info.html', { 347 'country': country, 'continent': country.continents()[0]}) 343 348 344 349 def get_continents_js(self, request): … … 359 364 return list_detail.object_list(request, objects, 360 365 template_name='telemeta/geo_country_collections.html', paginate_by=20, 366 extra_context={'country': country, 'continent': continent}) 367 368 def list_country_items(self, request, continent, country): 369 continent = Location.objects.by_flatname(continent)[0] 370 country = Location.objects.by_flatname(country)[0] 371 objects = MediaItem.objects.by_location(country) 372 return list_detail.object_list(request, objects, 373 template_name='telemeta/geo_country_items.html', paginate_by=20, 361 374 extra_context={'country': country, 'continent': continent}) 362 375
Note: See TracChangeset
for help on using the changeset viewer.
