Skip to content

Commit

Permalink
[refs #118672] Fix email send test and data table
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaboiangiu committed Jun 25, 2020
1 parent 9eb052b commit 2abaae8
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions notifications/views/emailtemplate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import csv
import json
import random
from urllib.parse import urlencode

from django.contrib.postgres.search import SearchVector
from django.db.models import Prefetch
Expand Down Expand Up @@ -260,7 +261,10 @@ def get_recipient_companies(self, company_ids=None):
return qs

def get_sort(self, order, direction):
sorting = ['integer_external_id', 'name', 'personcompany__person__name', 'personcompany__person__email']
if self.object.group.code in BDR_GROUP_CODES:
sorting = ['external_id', 'name', 'personcompany__person__name', 'personcompany__person__email']
else:
sorting = ['integer_external_id', 'name', 'personcompany__person__name', 'personcompany__person__email']
if direction == 'desc':
return '-' + sorting[order]
return sorting[order]
Expand Down Expand Up @@ -289,8 +293,8 @@ def get_data(self, context):
order = self.request.POST.get('order[0][column]')
direction = self.request.POST.get('order[0][dir]')
search_value = self.request.POST.get('search[value]')
order = self.get_sort(int(order), direction)
self.object = CycleEmailTemplate.objects.get(id=self.kwargs['pk'])
order = self.get_sort(int(order), direction)

if self.object.is_triggered:
companies = Company.objects.filter(notifications__emailtemplate=self.object).all().prefetch_related('personcompany_set')
Expand Down Expand Up @@ -369,12 +373,13 @@ def get_context_data(self, **kwargs):
return context

def get_success_url(self):
query_args = "?company_name={company}&person_name={person}".format(
company=self.request.POST['company'],
person=self.request.POST['contact']
)
params = {
"company_name": self.request.POST['company'],
"person_name": self.request.POST['contact'],
}
query_string = urlencode(params)
return reverse('notifications:template:test',
args=[self.object.pk]) + query_args
args=[self.object.pk]) + '?' + query_string

def breadcrumbs(self):
self.object = self.get_object()
Expand Down

0 comments on commit 2abaae8

Please sign in to comment.