diff --git a/project/customer/models.py b/project/customer/models.py
index bb83fa2..0529c8c 100644
--- a/project/customer/models.py
+++ b/project/customer/models.py
@@ -11,7 +11,7 @@ from django.db.models import Max
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
-from . import consts, managers
+from . import consts, managers, utils
PROFILE_IMAGES_UPLOAD_DIR = 'customer/profile/' # куда сохранять загруженные изображения
@@ -383,6 +383,7 @@ class License(models.Model):
self.user.profile.active = True
self.user.profile.save()
self.status = 1
+ utils.check_one_profile(self.user.profile, License, datetime.now())
super(License, self).save(*args, **kwargs)
diff --git a/project/customer/tasks.py b/project/customer/tasks.py
index a173f6a..7be84da 100644
--- a/project/customer/tasks.py
+++ b/project/customer/tasks.py
@@ -3,11 +3,10 @@ from __future__ import absolute_import
from datetime import datetime, timedelta
from django.conf import settings
-from django.template.loader import render_to_string
-from django.core.mail import EmailMessage
from celery import shared_task
from .models import License, UserProfile
+from .utils import check_one_profile
SUPPORT_EMAIL = getattr(settings, 'SUPPORT_EMAIL', '')
@@ -25,29 +24,7 @@ def check_license():
licenses.update(status=4)
for profile in profiles:
- licenses = License.objects.filter(user=profile.user, date_from__lte=now, date_to__gte=now, status__in=[-1, 1, 2], deleted=False)
- if licenses:
- profile.active = True
- else:
- profile.active = False
- profile.save()
- licenses.filter(status=1).update(status=2)
-
- licenses = License.objects.filter(user=profile.user, date_to=now + timedelta(1), status__in=[-1, 2], deleted=False)
- licenses_remain = License.objects.filter(user=profile.user, date_from__gt=now + timedelta(1), status=1, deleted=False)
- licenses_to_pay = License.objects.filter(user=profile.user, status=0, deleted=False)
-
- if licenses and not licenses_remain:
- template_name = 'myauth/license_ends.txt'
- subject = u'Документор: окончание срока действия лицензии'
- dict_context = {'user_email': licenses[0].user,
- 'support_email': SUPPORT_EMAIL,
- 'license_ends': licenses[0].date_to,
- 'licenses_to_pay': licenses_to_pay,
- }
- email_body = render_to_string(template_name, dict_context)
- email = EmailMessage(subject=subject, to=(licenses[0].user.email,), body=email_body)
- return email.send()
+ check_one_profile(profile, License, now)
return None
diff --git a/project/customer/utils.py b/project/customer/utils.py
new file mode 100644
index 0000000..8a87b6a
--- /dev/null
+++ b/project/customer/utils.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+from datetime import timedelta
+from django.core.mail import EmailMessage
+from django.template.loader import render_to_string
+
+
+def check_one_profile(profile, License, now):
+ profile_is_active = profile.active
+ licenses = License.objects.filter(user=profile.user, date_from__lte=now, date_to__gte=now, status__in=[-1, 1, 2], deleted=False)
+ if licenses:
+ profile.active = True
+ else:
+ profile.active = False
+ profile.save()
+ licenses.filter(status=1).update(status=2)
+
+ licenses = License.objects.filter(user=profile.user, date_to__lt=now, status=2, deleted=False)
+ licenses.update(status=3)
+ licenses_to_pay = License.objects.filter(user=profile.user, status=0, deleted=False)
+
+ if licenses:
+ template_name = 'myauth/license_ended.txt'
+ subject = u'Документор: срок действия лицензии окончен'
+ dict_context = {'user_email': licenses[0].user,
+ 'support_email': SUPPORT_EMAIL,
+ 'license_ends': licenses[0].date_to,
+ 'licenses_to_pay': licenses_to_pay,
+ }
+ email_body = render_to_string(template_name, dict_context)
+ email = EmailMessage(subject=subject, to=(licenses[0].user.email,), body=email_body)
+ email.send()
+
+ licenses = License.objects.filter(user=profile.user, date_to=now + timedelta(1), status__in=[-1, 2], deleted=False)
+ licenses_remain = License.objects.filter(user=profile.user, date_from__gt=now + timedelta(1), status=1, deleted=False)
+ licenses_to_pay = License.objects.filter(user=profile.user, status=0, deleted=False)
+
+ if licenses and not licenses_remain:
+ template_name = 'myauth/license_ends.txt'
+ subject = u'Документор: окончание срока действия лицензии'
+ dict_context = {'user_email': licenses[0].user,
+ 'support_email': SUPPORT_EMAIL,
+ 'license_ends': licenses[0].date_to,
+ 'licenses_to_pay': licenses_to_pay,
+ }
+ email_body = render_to_string(template_name, dict_context)
+ email = EmailMessage(subject=subject, to=(licenses[0].user.email,), body=email_body)
+ email.send()
+
+
diff --git a/project/docs/views/base_views.py b/project/docs/views/base_views.py
index bda2406..a948164 100644
--- a/project/docs/views/base_views.py
+++ b/project/docs/views/base_views.py
@@ -379,6 +379,7 @@ class BaseViews(object):
def as_img(self, *args, **kwargs):
"""Вывести превью документа."""
try:
+ obj = self.get_obj(kwargs['id'])
pdf = self.get_pdf(*args, **kwargs)
_, filename = tempfile.mkstemp()
@@ -407,6 +408,7 @@ class BaseViews(object):
imgs = ['%stmp/%s/%s' % (MEDIA_URL, tmp_dirname, i) for i in imgs]
dictionary = {
+ 'obj': obj,
'images': imgs,
'padeji': self.PADEJI,
'padeji_mnoj': self.PADEJI_MNOJ,
diff --git a/project/static/css/style.css b/project/static/css/style.css
index 8d8b4c9..0509c12 100644
--- a/project/static/css/style.css
+++ b/project/static/css/style.css
@@ -214,4 +214,5 @@ div.blockMsg { width: 100%; height: 100%; top: 0; left: 0; text-align: center; }
.header {font-weight:bold; }
#menu ul li {display:inline;}
-.preview {width:1000px;height:500px;overflow:scroll;}
+.preview {width:780px;height:500px;overflow:scroll;float:left;}
+.list-col2 {float: left; width: 180px; margin-left: 16px; padding: 0 10px 10px 10px; border-left: solid 1px #797979;}
diff --git a/project/templates/docs/_base/base_list.html b/project/templates/docs/_base/base_list.html
index 2c06a5c..6f0b2a5 100644
--- a/project/templates/docs/_base/base_list.html
+++ b/project/templates/docs/_base/base_list.html
@@ -78,61 +78,10 @@
-