def update_cms_form(self): from webinars_web.webinars.models import EventForm, CmsForm if not self._update_cms_form: possibles = self.cms_forms.filter(is_sync_target=True) if possibles: self._update_cms_form = possibles[0] else: title = "%s [Webinars Sync]" % self.title #reg_prop_title = "%s [registered]" % self.id #att_prop_title = "%s [attended]" % self.id #nos_prop_title = "%s [noshow]" % self.id leads_client = hapi_plus.leads.LeadsClient(settings.HUBSPOT_API_KEY, hub_id=self.account.hub.id, env=settings.API_ENV, timeout=30) #contacts_client = hapi_plus.contacts.ContactsClient(settings.HUBSPOT_API_KEY, hub_id=self.account.hub.id, env=settings.API_ENV, timeout=30) form_guid = leads_client.create_form(title)['guid'] cms_form = CmsForm(hub=self.account.hub, guid=form_guid, name=title, is_sync_target=True) cms_form.save() event_form = EventForm(event=self, cms_form=cms_form) event_form.save() self._update_cms_form = cms_form self.save() return self._update_cms_form
def sync_forms(self): from webinars_web.webinars.models import CmsForm CmsForm.sync(self)