remotes/origin/stage6
Alexander Burdeinyi 9 years ago
parent fa497232f8
commit 7b4514d541
  1. 11
      emencia/django/newsletter/mailer.py
  2. 24
      emencia/django/newsletter/templates/newsletter/AutomaticEmail_web.html
  3. 3
      emencia/django/newsletter/views/admin_views.py
  4. 8
      proj/sorlengine.py
  5. 2
      templates/client/includes/banners/top_head_banner.html

@ -332,9 +332,12 @@ class NewsLetterSender(object):
if obj is not None:
logo = getattr(obj, 'logo')
if not logo:
return None
logo_path = os.path.join(settings.STATIC_ROOT, 'client/img/no-logo.png')
else:
logo_path = logo.path
try:
ctype, encoding = mimetypes.guess_type(logo.path)
ctype, encoding = mimetypes.guess_type(logo_path)
except SuspiciousOperation:
return None
if ctype is None or encoding is not None:
@ -343,11 +346,11 @@ class NewsLetterSender(object):
maintype, subtype = ctype.split('/', 1)
try:
if resize is not None:
fd = get_thumbnail(logo.path, resize, **kwargs)
fd = get_thumbnail(logo_path, resize, **kwargs)
# import pdb; pdb.set_trace()
# fd = open(thumb.path, 'rb')
else:
fd = open(logo.path, 'rb')
fd = open(logo_path, 'rb')
except IOError:
return None
if maintype == 'image':

@ -131,6 +131,10 @@
<td valign="top" style="width: 225px;">
{% thumbnail obj.get_logo '281' as im %}
<a href="http://{{ domain }}{{ obj.get_permanent_url }}"><img src="{{ im.url }}"/></a>
{% empty %}
{% thumbnail no_logo_image '281' as im %}
<a href="http://{{ domain }}{{ obj.get_permanent_url }}"><img src="{{ im.url }}"/></a>
{% endthumbnail %}
{% endthumbnail %}
</td>
@ -204,6 +208,10 @@
<a href="http://{{ domain }}{{ obj.get_permanent_url }}" class="event_image">
{% thumbnail obj.get_logo '109x114' dailymail='russia' hit=obj.expohit as im %}
<img style="" src="{{ im.url }}"/>
{% empty %}
{% thumbnail no_logo_image '109x114' dailymail='russia' hit=obj.expohit as im %}
<img src="{{ im.url }}"/>
{% endthumbnail %}
{% endthumbnail %}
</a>
</td>
@ -283,6 +291,10 @@
<a href="https://{{ domain }}{{ obj.get_permanent_url }}" class="event_image">
{% thumbnail obj.get_logo '109x114' dailymail='russia' hit=obj.expohit as im %}
<img src="{{ im.url }}"/>
{% empty %}
{% thumbnail no_logo_image '109x114' dailymail='russia' hit=obj.expohit as im %}
<img src="{{ im.url }}"/>
{% endthumbnail %}
{% endthumbnail %}
</a>
</td>
@ -381,6 +393,10 @@
<a href="http://{{ domain }}{{ obj.get_permanent_url }}" class="foreign_image">
{% thumbnail obj.get_logo '130x130' dailymail='foreign' hit=obj.expohit as im %}
<img src="{{ im.url }}"/>
{% empty %}
{% thumbnail no_logo_image '130x130' dailymail='foreign' hit=obj.expohit as im %}
<img src="{{ im.url }}"/>
{% endthumbnail %}
{% endthumbnail %}
</a>
</td>
@ -449,6 +465,10 @@
<td style="width: 300px; text-align: center; padding-bottom: 30px;" valign="top">
{% thumbnail news.logo "272" as im %}
<a href="http://{{ domain }}{{ news.get_permanent_url }}"><img src="{{ im.url }}" alt=""></a>
{% empty %}
{% thumbnail no_logo_image '272' as im %}
<a href="http://{{ domain }}{{ news.get_permanent_url }}"><img src="{{ im.url }}"/></a>
{% endthumbnail %}
{% endthumbnail %}
</td>
@ -501,6 +521,10 @@
<td style="width: 300px; text-align: center; padding-bottom: 40px;" valign="top">
{% thumbnail blog.logo "272" as im %}
<a href="http://{{ domain }}{{ blog.get_permanent_url }}"><img src="{{ im.url }}" alt=""></a>
{% empty %}
{% thumbnail no_logo_image '272' as im %}
<a href="http://{{ domain }}{{ blog.get_permanent_url }}"><img src="{{ im.url }}"/></a>
{% endthumbnail %}
{% endthumbnail %}
</td>

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import os
import datetime
from django.conf import settings
@ -8,6 +9,7 @@ from django.forms.formsets import formset_factory
from django.forms.models import modelformset_factory
from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.core.files.storage import default_storage
from django.utils import translation
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _
@ -86,6 +88,7 @@ class AutomaticEmailTest(ContextMixin, FormView):
# 'tracking_image_format': TRACKING_IMAGE_FORMAT,
'uidb36': uidb36, 'token': token,
'name': contact.first_name or contact.last_name or _(u'Подписчик'),
'no_logo_image': default_storage.open('newsletter/images/no-logo.png'),
})
self.extra_ctx.update(contact.get_announce_context_v2(date=form.cleaned_data.get('date')))
return self.form_invalid(form)

@ -9,6 +9,7 @@ from sorl.thumbnail.engines.pil_engine import Engine
from django.contrib.staticfiles import finders
from django.conf import settings
from sorl.thumbnail.conf import settings as solr_settings
russia_size = (89, 94)
foreign_size = (110, 110)
@ -30,6 +31,9 @@ class SorlEngine(Engine):
(thumb.width - image.width) / 2 + image.width, # right
(thumb.height - image.height) / 2 + image.height # bottom
)
if image.mode == "P" and 'transparency' in image.info:
image = image.convert('RGBA')
# вставляем
if image.mode == "RGBA":
# с прозрачностью
@ -50,3 +54,7 @@ class SorlEngine(Engine):
if options.get('dailymail') == 'foreign':
return self.create_dailymail_thumb(image, foreign_size, foreign_background, options.get('hit', False))
return super(SorlEngine, self).create(image, geometry, options)
def write(self, image, options, thumbnail):
options['image_info'] = image.info
super(SorlEngine, self).write(image, options, thumbnail)

@ -1,6 +1,6 @@
<div id="top_page_banner">
{% if is_img %}
<a href="{{ url }}" class="top_page_banner">
<a href="{{ url }}" class="top_page_banner" target="_blank">
<img src="{{ img }}" alt="">
</a>
{% elif is_html %}

Loading…
Cancel
Save