diff options
author | luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f <luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f> | 2010-08-18 15:49:08 +0000 |
---|---|---|
committer | luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f <luxagraf@c63593aa-01b0-44d9-8516-4b9c7e931d7f> | 2010-08-18 15:49:08 +0000 |
commit | 432e39917fe226630abf4d3c314a765fc8ff9e61 (patch) | |
tree | dfb035a583a247bf0e94ae752547f368c2b3c8f3 /apps/blog | |
parent | 8f978c65b17f8c41d977b60bf2530e99d76dd591 (diff) |
optimized some html
Diffstat (limited to 'apps/blog')
-rw-r--r-- | apps/blog/signals.py | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/apps/blog/signals.py b/apps/blog/signals.py index 23e6d3f..7134239 100644 --- a/apps/blog/signals.py +++ b/apps/blog/signals.py @@ -6,30 +6,31 @@ from django.db.models import get_model from locations.models import Region,Country,Route def update_recent(sender, instance, signal, *args, **kwargs): - # Update recent entries static file - model = get_model('blog', 'entry') - qs = {'object_list': model.objects.filter(status__exact=1).order_by('-pub_date')[1:4]} - c = Context(qs) - t = render_to_string('includes/recent_entries_template.html',c) - fpath = '%s%s' %(settings.PROJ_ROOT,'templates/includes/recent_entries.html') - file = open(fpath, 'w') - file.write(t) - file.close() - # Update map template - import codecs - qs = model.objects.filter(status__exact=1) - cl = Country.objects.filter(visited=True).exclude(name='default') - rl = Region.objects.all() - rtl = Route.objects.all() - c = Context({'object_list':qs, 'country_list':cl,'region_list':rl, 'route_list':rtl}) - t = render_to_string('includes/map_entry_list_template.html',c) - fpath = '%s%s' %(settings.PROJ_ROOT,'media/js/mainmap.js') - file = codecs.open(fpath, 'w','utf8') - file.write(t) - file.close() - c = Context({'country_list':cl,'region_list':rl,'route_list':rtl}) - t = render_to_string('includes/map_sidebar_template.html',c) - fpath = '%s%s' %(settings.PROJ_ROOT,'templates/includes/map_sidebar.html') - file = codecs.open(fpath, 'w','utf8') - file.write(t) - file.close()
\ No newline at end of file + if not settings.DEVELOPMENT: + # Update recent entries static file + model = get_model('blog', 'entry') + qs = {'object_list': model.objects.filter(status__exact=1).order_by('-pub_date')[1:4]} + c = Context(qs) + t = render_to_string('includes/recent_entries_template.html',c) + fpath = '%s%s' %(settings.PROJ_ROOT,'templates/includes/recent_entries.html') + file = open(fpath, 'w') + file.write(t) + file.close() + # Update map template + import codecs + qs = model.objects.filter(status__exact=1) + cl = Country.objects.filter(visited=True).exclude(name='default') + rl = Region.objects.all() + rtl = Route.objects.all() + c = Context({'object_list':qs, 'country_list':cl,'region_list':rl, 'route_list':rtl}) + t = render_to_string('includes/map_entry_list_template.html',c) + fpath = '%s%s' %(settings.PROJ_ROOT,'media/js/mainmap.js') + file = codecs.open(fpath, 'w','utf8') + file.write(t) + file.close() + c = Context({'country_list':cl,'region_list':rl,'route_list':rtl}) + t = render_to_string('includes/map_sidebar_template.html',c) + fpath = '%s%s' %(settings.PROJ_ROOT,'templates/includes/map_sidebar.html') + file = codecs.open(fpath, 'w','utf8') + file.write(t) + file.close()
\ No newline at end of file |