コード例 #1
0
ファイル: views.py プロジェクト: wooster/django-topsoil
def oauth_application_edit(request, application_id):
    """Edit an OAuth application."""
    application = get_object_or_404(OAuthApplication, id=application_id, consumer__user=request.user)
    context = {'title':'Edit Application - %s' % application.consumer.name}
    if request.POST:
        form = OAuthApplicationForm(request.POST)
        if form.is_valid():
            application = form.save(request.user, application=application)
            return HttpResponseRedirect(application.get_absolute_url())
    else:
        initial = {
            'application_name':application.consumer.name,
            'application_description':application.consumer.description,
            'application_url':application.application_url,
            'organization_name':application.organization_name,
            'organization_url':application.organization_url,
            'application_type':application.application_type,
            'callback_url':application.callback_url
        }
        t = OAuthApplicationForm.READ_ONLY
        if application.delete_permission:
            t = OAuthApplicationForm.READ_WRITE_AND_DELETE
        elif application.write_permission:
            t = OAuthApplicationForm.READ_AND_WRITE
        initial['access_type'] = t
        initial['use_for_login'] = application.login_permission
        
        form = OAuthApplicationForm(initial=initial)
    context['form'] = form
    return render_to_response('oauth_client_edit.html', context_instance=RequestContext(request, context))
コード例 #2
0
ファイル: views.py プロジェクト: wooster/django-topsoil
def oauth_application_add(request):
    """Register a new OAuth application."""
    context = {'title':'Add Application'}
    if request.POST:
        form = OAuthApplicationForm(request.POST)
        if form.is_valid():
            application = form.save(request.user)
            return HttpResponseRedirect(application.get_absolute_url())
    else:
        form = OAuthApplicationForm()
    context['form'] = form
    return render_to_response('oauth_client_register.html', context_instance=RequestContext(request, context))