1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
from django.template.loader import render_to_string
from django.conf import settings
from django.template import Context
from django.db.models import get_model
from locations.models import Region,Country
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:6]}
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()
c = Context({'object_list':qs, 'country_list':cl,'region_list':rl})
t = render_to_string('includes/map_entry_list_template.html',c)
fpath = '%s%s' %(settings.PROJ_ROOT,'templates/includes/map_entry_list.html')
file = codecs.open(fpath, 'w','utf8')
file.write(t)
file.close()
c = Context({'country_list':cl,'region_list':rl})
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()
|