from __future__ import absolute_import

from django.core.urlresolvers import reverse

from sentry.auth import manager
from sentry.auth.helper import AuthHelper
from sentry.models import OrganizationMemberType
from sentry.utils.http import absolute_uri
from sentry.web.frontend.base import OrganizationView


class OrganizationAuthSettingsView(OrganizationView):
    required_access = OrganizationMemberType.OWNER

    def handle_existing_provider(self, request, organization):
        # at this point the provider may or may not be fully configured
        auth_provider = organization.auth_provider
        provider = auth_provider.get_provider()

        context = {
            'login_url': absolute_uri(reverse('sentry-organization-home', args=[organization.slug])),
            'auth_provider': auth_provider,
            'provider_name': provider.name,
        }

        return self.respond('sentry/organization-auth-provider-settings.html', context)

    def handle_provider_setup(self, request, organization, provider_key):
        helper = AuthHelper(
            request=request,
            organization=organization,
            provider_key=provider_key,
            flow=AuthHelper.FLOW_SETUP_PROVIDER,
        )
        helper.init_pipeline()
        return helper.next_step()

    def handle(self, request, organization):
        if organization.auth_provider:
            return self.handle_existing_provider(request, organization)

        if request.method == 'POST':
            provider_key = request.POST.get('provider')
            if not manager.exists(provider_key):
                raise ValueError('Provider not found: {}'.format(provider_key))

            # render first time setup view
            return self.handle_provider_setup(request, organization, provider_key)

        context = {
            'provider_list': [(k, v.name) for k, v in manager],
        }

        return self.respond('sentry/organization-auth-settings.html', context)

@@ -484,167 +484,681 @@
   # 
-at this point the provider may or may not be fully configured%0A        auth_provider = organization.auth_provider%0A        provider = auth_provider.get_provider(
+TODO(dcramer): providers need to be able to extend this page. There%0A        # should always be a disable + login info blurb but each provider may%0A        # want to add additional behaviors%0A%0A        auth_provider = organization.auth_provider%0A        provider = auth_provider.get_provider()%0A%0A        if request.method == 'POST':%0A            op = request.POST.get('op')%0A            if op == 'disable':%0A                organization.update(auth_provider=None)%0A                auth_provider.delete()%0A%0A                next_uri = reverse('sentry-organization-auth-settings',%0A                                   args=%5Borganization.slug%5D)%0A                return self.redirect(next_uri
 )%0A%0A 

Add basic disable action