Skip to content

Commit 8cff9ad

Browse files
authored
Merge pull request #84 from MoveOnOrg/autoadd-cohost
autoadd cohost post event-creation
2 parents 8aca3f3 + 5d47517 commit 8cff9ad

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

event_exim/connectors/actionkit_api.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ def parameters(cls):
139139
'cohost_id': {'help_text': ('for easy Act-as-host links, if all events'
140140
' have a cohost, then this will create'
141141
' links that do not need ActionKit staff access'),
142-
'required': False}
142+
'required': False},
143+
'cohost_autocreate_page_id': {'help_text': ('If you want the cohost auto-added as a host'
144+
'to all events add a page_id for event signup'),
145+
'required': False},
143146

144147
}
145148

@@ -160,6 +163,7 @@ class aksettings:
160163
if re.match(r'^\d+$', h)
161164
])
162165
self.cohost_id = data.get('cohost_id')
166+
self.cohost_autocreate_page_id = data.get('cohost_autocreate_page_id')
163167
self._allowed_hosts = set(data['base_url'].split('/')[2])
164168
if data.get('allowed_hosts'):
165169
self._allowed_hosts.update(data['allowed_hosts'].split(','))
@@ -265,6 +269,18 @@ def cleanchars(val, key):
265269
hosts[hostpk] = host
266270
if hostpk == self.cohost_id:
267271
cohost_create_action = host['create_action']
272+
if self.cohost_autocreate_page_id \
273+
and self.cohost_id \
274+
and not cohost_create_action:
275+
# cohost has not been added yet -- let's add it
276+
res = self.akapi.create_signup(self.cohost_id,
277+
e_id,
278+
self.cohost_autocreate_page_id,
279+
role='host',
280+
fields={'source': 'automatic',
281+
'provider': 'eventroller'})
282+
if res and res.get('id'):
283+
cohost_create_action = int(res['id'])
268284

269285
event_fields.update({'organization_official_event': False,
270286
'event_type': 'unknown',

0 commit comments

Comments
 (0)