diff --git a/emencia/django/newsletter/admin_forms.py b/emencia/django/newsletter/admin_forms.py index befb511d..fbc4d9be 100644 --- a/emencia/django/newsletter/admin_forms.py +++ b/emencia/django/newsletter/admin_forms.py @@ -180,7 +180,7 @@ class NewsletterForm(forms.ModelForm): class Meta: model = Newsletter - fields = ('preheader', 'title', 'content', 'ab_testing', 'ab_first_stage', 'title2', 'content2', 'mailing_list', 'theme_for_filter', 'test_contacts', 'header_sender', + fields = ('preheader', 'title', 'content', 'ab_testing', 'ab_first_stage', 'preheader2', 'title2', 'content2', 'mailing_list', 'theme_for_filter', 'test_contacts', 'header_sender', 'header_reply', 'status', 'sending_date', 'slug') widgets = { 'ab_first_stage': forms.widgets.TextInput(attrs={'type':'number', 'min': 5, 'max': 100}), diff --git a/emencia/django/newsletter/mailer.py b/emencia/django/newsletter/mailer.py index 651b05e0..355dced8 100644 --- a/emencia/django/newsletter/mailer.py +++ b/emencia/django/newsletter/mailer.py @@ -272,7 +272,7 @@ class NewsLetterSender(object): if self.newsletter.ab_testing and self.ab_state == Newsletter.A: title = self.title_template.render(context) elif self.newsletter.ab_testing and self.ab_state == Newsletter.B: - title = self.title_template2.render(context) + title = self.title_template2.render(context) else: title = self.title_template.render(context) return title @@ -335,7 +335,7 @@ class NewsLetterSender(object): theme_word=theme_word.make_agree_with_number(count).word, ) return { - 'name': contact.first_name or contact.last_name, + 'name': contact.first_name or contact.last_name or _(u'Подписчик'), 'themes': ', '.join([self.themes.get(x) for x in contact.contactsettings.theme.all().values_list('pk', flat=True)[:3]]) + t_add, } diff --git a/emencia/django/newsletter/models.py b/emencia/django/newsletter/models.py index ae9afc2f..99ae0a0a 100644 --- a/emencia/django/newsletter/models.py +++ b/emencia/django/newsletter/models.py @@ -167,13 +167,29 @@ class Contact(models.Model): # making query params = Q() - countries = self.contactsettings.country.all().values_list('pk', flat=True) - if countries: - params |= Q(country__in=countries) - - cities = self.contactsettings.city.all().values_list('pk', flat=True) - if cities: - params |= Q(country__in=cities) + _countries = set(self.contactsettings.country.all().values_list('pk', flat=True)) + countries = set() + # countries_overall = set() + _cities = self.contactsettings.city.all().values_list('pk', 'country_id') + cities = set() + cities_overall = set() + + for city, country_id in _cities: + if country_id in _countries: + cities.add(city) + countries.add(country_id) + else: + cities_overall.add(city) + countries_overall = _countries.difference(countries) + + if countries_overall: + params |= Q(country_id__in=countries_overall) + + if cities_overall: + params |= Q(city_id__in=cities_overall) + + if countries and cities: + params |= Q(city_id__in=cities, country_id__in=countries) if themes: theme_ids = set([item.id for item in themes]) diff --git a/emencia/django/newsletter/templates/newsletter/announce_template.html b/emencia/django/newsletter/templates/newsletter/announce_template.html index 5ce43997..112ba77d 100644 --- a/emencia/django/newsletter/templates/newsletter/announce_template.html +++ b/emencia/django/newsletter/templates/newsletter/announce_template.html @@ -33,6 +33,7 @@ {# end header #} {# events #} + {% if expo %} {% with events=expo place=expo_places %}