admin statistic unsubscription fix and unique link fix

remotes/origin/stage5
Alexander Burdeiny 9 years ago
parent e79d681d20
commit 427469edfc
  1. 32
      emencia/django/newsletter/views/mailing_list.py
  2. 2
      templates/c_admin/newsletters/newsletter_stat.html

@ -24,8 +24,20 @@ def view_mailinglist_unsubscribe(request, slug, uidb36, token):
newsletter.mailing_list.unsubscribers.add(contact) newsletter.mailing_list.unsubscribers.add(contact)
newsletter.mailing_list.save() newsletter.mailing_list.save()
already_unsubscribed = True already_unsubscribed = True
ContactMailingStatus.objects.create(newsletter=newsletter, contact=contact, params = dict(newsletter=newsletter,
status=ContactMailingStatus.UNSUBSCRIPTION) contact=contact,
status=ContactMailingStatus.UNSUBSCRIPTION)
if newsletter.ab_testing:
try:
ab_state = ContactMailingStatus.objects.filter(
newsletter=newsletter,
contact=contact,
status__in=(ContactMailingStatus.SENT_TEST, ContactMailingStatus.SENT),
).order_by('-creation_date')[0].ab
params.update({'ab': ab_state})
except:
pass
ContactMailingStatus.objects.create(**params)
return HttpResponseRedirect(reverse_lazy('newsletter_mailinglist_unsubscribe_success')) return HttpResponseRedirect(reverse_lazy('newsletter_mailinglist_unsubscribe_success'))
@ -87,8 +99,20 @@ class UnsubscribeView(DetailView):
context = super(UnsubscribeView, self).get_context_data(**kwargs) context = super(UnsubscribeView, self).get_context_data(**kwargs)
context['subscribe'] = self.get_announce_form() context['subscribe'] = self.get_announce_form()
# #
ContactMailingStatus.objects.create(newsletter=self.object, contact=self.contact, params = dict(newsletter=self.object,
status=ContactMailingStatus.UNSUBSCRIPTION) contact=self.contact,
status=ContactMailingStatus.UNSUBSCRIPTION)
if self.object.ab_testing:
try:
ab_state = ContactMailingStatus.objects.filter(
newsletter=self.object,
contact=self.contact,
status__in=(ContactMailingStatus.SENT_TEST, ContactMailingStatus.SENT),
).order_by('-creation_date')[0].ab
params.update({'ab': ab_state})
except:
pass
ContactMailingStatus.objects.create(**params)
return context return context

@ -95,7 +95,7 @@
<tr> <tr>
<td>Открыто(уникальных)</td> <td>Открыто(уникальных)</td>
<td>{{ statB.opened.data }} {% if statB.opened.percent %} ({{ statB.opened.percent|floatformat:"0" }}%) {% endif %}</td> <td>{{ statB.opened.data }} {% if statB.opened.percent %} ({{ statB.opened.percent|floatformat:"0" }}%) {% endif %}/ {{ stat.opened.data_all }}</td>
<td><a href="{% url 'newsletters_newsletters_history' object.id %}?status={{ statB.opened.filter }}&ab={{ statB.ab }}">Подробно</a></td> <td><a href="{% url 'newsletters_newsletters_history' object.id %}?status={{ statB.opened.filter }}&ab={{ statB.ab }}">Подробно</a></td>
</tr> </tr>
<tr> <tr>

Loading…
Cancel
Save