@require_setting('TRELLO_APP_KEY')
@login_required
def add_trello(request, code):
    project = _get_rw_project_for_user(request, code)
    if (request.method == 'POST'):
        channel = Channel(project=project, kind='trello')
        channel.value = request.POST['settings']
        channel.save()
        channel.assign_all_checks()
        return redirect('hc-channels', project.code)
    return_url = (settings.SITE_ROOT + reverse('hc-add-trello', args=[project.code]))
    authorize_url = ('https://trello.com/1/authorize?' + urlencode({'expiration': 'never', 'name': settings.SITE_NAME, 'scope': 'read,write', 'response_type': 'token', 'key': settings.TRELLO_APP_KEY, 'return_url': return_url}))
    ctx = {'page': 'channels', 'project': project, 'authorize_url': authorize_url}
    return render(request, 'integrations/add_trello.html', ctx)
@require_setting('TRELLO_APP_KEY')
@login_required
def add_trello(request, code):
    project = _get_rw_project_for_user(request, code)
    if (request.method == 'POST'):
        channel = Channel(project=project, kind='trello')
        channel.value = request.POST['settings']
        channel.save()
        channel.assign_all_checks()
        return redirect('hc-channels', project.code)
    return_url = (settings.SITE_ROOT + reverse('hc-add-trello', args=[project.code]))
    authorize_url = ('https://trello.com/1/authorize?' + urlencode({'expiration': 'never', 'name': settings.SITE_NAME, 'scope': 'read,write', 'response_type': 'token', 'key': settings.TRELLO_APP_KEY, 'return_url': return_url}))
    ctx = {'page': 'channels', 'project': project, 'authorize_url': authorize_url}
    return render(request, 'integrations/add_trello.html', ctx)