diff --git a/emencia/django/newsletter/management/commands/newsletter_create_announce.py b/emencia/django/newsletter/management/commands/newsletter_create_announce.py
index eccc1db5..998f1967 100644
--- a/emencia/django/newsletter/management/commands/newsletter_create_announce.py
+++ b/emencia/django/newsletter/management/commands/newsletter_create_announce.py
@@ -10,5 +10,5 @@ class Command(NoArgsCommand):
def handle(self, *args, **options):
announce_list = MailingList.objects.get(id=1)
- day = date.today() - timedelta(days=1)
+ day = date.today()
announce_list.generate_announce_newsletter(day)
\ No newline at end of file
diff --git a/emencia/django/newsletter/management/commands/send_newsletter.py b/emencia/django/newsletter/management/commands/send_newsletter.py
index b583bdea..d608a358 100644
--- a/emencia/django/newsletter/management/commands/send_newsletter.py
+++ b/emencia/django/newsletter/management/commands/send_newsletter.py
@@ -15,9 +15,6 @@ class Command(NoArgsCommand):
from emencia.django.newsletter.models import Newsletter
verbose = int(options['verbosity'])
- if verbose:
- print 'Starting sending newsletters...'
-
activate(settings.LANGUAGE_CODE)
for newsletter in Newsletter.objects.exclude(
@@ -26,13 +23,7 @@ class Command(NoArgsCommand):
if mailer.can_send:
- #if verbose:
- # with open('/tmp/cron.log', 'a') as f:f.write('Start emailing %s\n' % newsletter.title)
- # print 'Start emailing %s' % newsletter.title
-
mailer.run()
-
-
if verbose:
print 'End session sending'
diff --git a/emencia/django/newsletter/templates/newsletter/announce_template.html b/emencia/django/newsletter/templates/newsletter/announce_template.html
index 992ab4d9..cc7ada10 100644
--- a/emencia/django/newsletter/templates/newsletter/announce_template.html
+++ b/emencia/django/newsletter/templates/newsletter/announce_template.html
@@ -73,6 +73,12 @@
{% endwith %}
{# end events #}
+ {# banner #}
+
+
+  |
+
+
{% if news %}
diff --git a/proj/settings.py b/proj/settings.py
index c4588d68..ab5fc450 100644
--- a/proj/settings.py
+++ b/proj/settings.py
@@ -350,6 +350,7 @@ INSTALLED_APPS = (
'webinar',
'meta',
#django modules
+ 'django_crontab',
'sorl.thumbnail', # for logos
'photologue', # photogallery
'sortedm2m', # photologue dependence
@@ -367,6 +368,26 @@ INSTALLED_APPS = (
'specialist_catalog',
)
+CRONJOBS = [
+ ('8 * * * *', 'django.core.management.call_command', ['send_newsletter']),
+
+ ('0 * * * *', 'django.core.management.call_command', ['update_index', 'conference', '--remove', '--age=6']),
+ ('5 * * * *', 'django.core.management.call_command', ['update_index', 'exposition', '--remove', '--age=6']),
+ ('0 1,13 * * *', 'django.core.management.call_command', ['update_index', 'place_exposition', '--remove', '--age=24']),
+ ('0 3 * * *', 'django.core.management.call_command', ['update_index', 'company', '--remove', '--age=48']),
+ ('0 4 * * *', 'django.core.management.call_command', ['update_index', 'theme', '--remove', '--age=48']),
+ ('0 5 * * * ', 'django.core.management.call_command', ['update_index', 'tag', '--remove', '--age=48']),
+ ('0 6 * * *', 'django.core.management.call_command', ['update_index', 'country', '--remove', '--age=48']),
+ ('0 7 * * *', 'django.core.management.call_command', ['update_index', 'city', '--remove', '--age=48']),
+
+ ('10 * * * *', 'django.core.management.call_command', ['banner_log_update']),
+ ('20 2,14 * * *', 'django.core.management.call_command', ['banner_log_check_previous_day']),
+ ('*/5 * * * *', 'django.core.management.call_command', ['update_views_cache']),
+
+ ('40 6 * * * ', 'django.core.management.call_command', ['newsletter_contacts_remove_notactivated']),
+ ('41 5 * * *', 'django.core.management.call_command', ['newsletter_create_announce']),
+
+]
PYMORPHY_DICTS = {
'ru': { 'dir': os.path.join(SITE_ROOT, 'settings/russian_dicts')} #'/home/www/proj/settings/russian_dicts' },
diff --git a/settings/management/commands/do_inflect.py b/settings/management/commands/do_inflect.py
index c226f08a..319daa88 100644
--- a/settings/management/commands/do_inflect.py
+++ b/settings/management/commands/do_inflect.py
@@ -9,9 +9,11 @@ CITIES = settings.MEDIA_ROOT+'/import/cities_inflect.xls'
TAGS = settings.MEDIA_ROOT+'/import/tags_inflect.xls'
import inspect, os
-
+from datetime import datetime
class Command(BaseCommand):
def handle(self, *args, **options):
+ with open('/tmp/newsl.log', 'a') as f: f.write(str(datetime.now()) + '\n')
+ """
f = open(TAGS, 'r')
book = xlrd.open_workbook(file_contents=f.read())
sheet = book.sheet_by_index(0)
@@ -24,7 +26,7 @@ class Command(BaseCommand):
if inflect:
Tag.objects.filter(url=url).update(inflect=inflect)
-
+ """
#City.objects.filter(url=url).update(inflect=row[4])
diff --git a/settings/management/commands/update_views_cache.py b/settings/management/commands/update_views_cache.py
index 9115c17e..15c16eb7 100644
--- a/settings/management/commands/update_views_cache.py
+++ b/settings/management/commands/update_views_cache.py
@@ -12,7 +12,7 @@ from theme.models import Theme, Tag
-CACHE_TIME = 300
+CACHE_TIME = 450
update_keys = {'expo_main_page_key_%s': Exposition.objects.expo_main,
'country_area_all_%s': Area.objects.all_sorted,
'conf_main_page_key_%s': Conference.objects.conf_main,
@@ -44,14 +44,5 @@ class Command(BaseCommand):
key = k % lang
print(key)
- if key in cache:
- print('exist')
- else:
- print('not exist')
result = func()
- cache.set(key, result, CACHE_TIME)
-
-
-
-
- print('success')
+ cache.set(key, result, CACHE_TIME)
\ No newline at end of file