if self schedule data trigger geofence regionsets campaign date from_d

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
if self.schedule.data == 'trigger':
geofence = {
'regionsets': [],
'campaign': {
'date': {
'from_date': None,
'to_date': None,
},
'weekdays': [],
'cap': {
'limit': None,
'period': None
}
}
}
if self.locations.data:
geofence['regionsets'] = self.locations.data
#TODO build dates taking in account choosen timezone!!!
if self.campaign_start.data:
geofence['campaign']['date']['from_date'] = self.campaign_start.data#.strftime('%Y-%m-%dT%H:%M:%S')
if self.campaign_end.data:
geofence['campaign']['date']['to_date'] = self.campaign_end.data#.strftime('%Y-%m-%dT%H:%M:%S')
if self.campaign_weekdays.data:
geofence['campaign']['weekdays'] = self.campaign_weekdays.data
if self.push_capacity_limit.data:
geofence['campaign']['cap']['limit'] = self.push_capacity_limit.data
if self.push_capacity_period.data:
geofence['campaign']['cap']['period'] = self.push_capacity_period.data
data['target'].update({
'geofence': geofence
})