def form_valid(self, form): org = self.request.user.get_org() authorization = self.get_session_authorization() access_token = authorization['access_token'] group_uuid = form.cleaned_data['group'] [group] = [ group for group in self.get_groups(access_token) if group['uuid'] == group_uuid ] config = { 'authorization': authorization, 'expires_at': ((datetime.now() + timedelta(seconds=authorization['expires_in']))).isoformat(), 'group': group, } self.object = Channel.create( org, self.request.user, None, self.channel_type, name='group messages to %(subject)s on %(number)s' % group, address=group['number'], config=config, secret=Channel.generate_secret()) self.clear_session_authorization() return super(WhatsAppClaimView, self).form_valid(form)
def form_valid(self, form): org = self.request.user.get_org() number = form.cleaned_data['number'] authorization = self.get_session_authorization() config = { 'authorization': authorization, 'expires_at': (datetime.now() + timedelta(seconds=authorization['expires_in'])).isoformat(), 'number': number, } self.object = Channel.create(org, self.request.user, None, self.channel_type, name='Direct Messages to %s' % (number, ), address=number, config=config, secret=Channel.generate_secret()) self.clear_session_authorization return super(WhatsAppClaimView, self).form_valid(form)