<s> from __future__ import absolute_import <EOL> from django import forms <EOL> from django . contrib import messages <EOL> from django . core . urlresolvers import reverse <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from sentry . models import OrganizationStatus <EOL> from sentry . tasks . deletion import delete_organization <EOL> from sentry . web . frontend . base import OrganizationView <EOL> ERR_DEFAULT_ORG = _ ( '<STR_LIT>' ) <EOL> MSG_REMOVE_SUCCESS = _ ( '<STR_LIT>' ) <EOL> class RemoveOrganizationForm ( forms . Form ) : <EOL> pass <EOL> class RemoveOrganizationView ( OrganizationView ) : <EOL> required_scope = '<STR_LIT>' <EOL> sudo_required = True <EOL> def get_form ( self , request , organization ) : <EOL> if request . method == '<STR_LIT:POST>' : <EOL> return RemoveOrganizationForm ( request . POST ) <EOL> return RemoveOrganizationForm ( ) <EOL> def handle ( self , request , organization ) : <EOL> if organization . is_default : <EOL> messages . add_message ( request , messages . ERROR , ERR_DEFAULT_ORG ) <EOL> return self . redirect ( reverse ( '<STR_LIT>' , args = [ <EOL> organization . slug <EOL> ] ) ) <EOL> form = self . get_form ( request , organization ) <EOL> if form . is_valid ( ) : <EOL> if organization . status != OrganizationStatus . PENDING_DELETION : <EOL> organization . update ( status = OrganizationStatus . PENDING_DELETION ) <EOL> delete_organization . apply_async ( kwargs = { <EOL> '<STR_LIT>' : organization . id , <EOL> } , countdown = <NUM_LIT> * <NUM_LIT:5> ) <EOL> messages . add_message ( request , messages . SUCCESS , <EOL> MSG_REMOVE_SUCCESS % ( organization . name , ) ) <EOL> return self . redirect ( reverse ( '<STR_LIT>' ) ) <EOL> context = { <EOL> '<STR_LIT>' : form , <EOL> '<STR_LIT>' : organization . team_set . all ( ) , <EOL> } <EOL> return self . respond ( '<STR_LIT>' , context ) </s>
