@@ -139,7 +139,10 @@ def parameters(cls):
139
139
'cohost_id' : {'help_text' : ('for easy Act-as-host links, if all events'
140
140
' have a cohost, then this will create'
141
141
' 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 },
143
146
144
147
}
145
148
@@ -160,6 +163,7 @@ class aksettings:
160
163
if re .match (r'^\d+$' , h )
161
164
])
162
165
self .cohost_id = data .get ('cohost_id' )
166
+ self .cohost_autocreate_page_id = data .get ('cohost_autocreate_page_id' )
163
167
self ._allowed_hosts = set (data ['base_url' ].split ('/' )[2 ])
164
168
if data .get ('allowed_hosts' ):
165
169
self ._allowed_hosts .update (data ['allowed_hosts' ].split (',' ))
@@ -265,6 +269,18 @@ def cleanchars(val, key):
265
269
hosts [hostpk ] = host
266
270
if hostpk == self .cohost_id :
267
271
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' ])
268
284
269
285
event_fields .update ({'organization_official_event' : False ,
270
286
'event_type' : 'unknown' ,
0 commit comments