def __init__(self, *args, **kwargs):
super(TeamSettingsForm, self).__init__(*args, **kwargs)
slack = Slacker(kwargs['instance'].access_token)
priv_ch = [(g['id'], g['name']) for g in slack.groups.list().body['groups'] if not (g['is_archived'] or g['name'].startswith('mpdm'))]
pub_ch = [(c['id'], c['name']) for c in slack.channels.list().body['channels'] if not c['is_archived']]
users = [(u['id'], u['profile']['real_name']) for u in slack.users.list().body['members'] if not u['deleted']]
self.fields['post_channel'].widget = forms.Select(choices=tuple(pub_ch))
self.fields['approval_channel'].widget = forms.Select(choices=tuple(pub_ch + priv_ch + users))
forms.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录