<s> from __future__ import absolute_import <EOL> from django import forms <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from sentry . models import AuditLogEntry , AuditLogEntryEvent , Project <EOL> from sentry . signals import project_created <EOL> from sentry . utils . samples import create_sample_event <EOL> BLANK_CHOICE = [ ( "<STR_LIT>" , "<STR_LIT>" ) ] <EOL> class AddProjectForm ( forms . ModelForm ) : <EOL> name = forms . CharField ( label = _ ( '<STR_LIT:Name>' ) , max_length = <NUM_LIT:200> , <EOL> widget = forms . TextInput ( attrs = { <EOL> '<STR_LIT>' : _ ( '<STR_LIT>' ) , <EOL> } ) , <EOL> help_text = _ ( '<STR_LIT>' ) , <EOL> ) <EOL> class Meta : <EOL> fields = ( '<STR_LIT:name>' , ) <EOL> model = Project <EOL> def __init__ ( self , organization , * args , ** kwargs ) : <EOL> forms . ModelForm . __init__ ( self , * args , ** kwargs ) <EOL> self . organization = organization <EOL> def save ( self , actor , team , ip_address ) : <EOL> project = super ( AddProjectForm , self ) . save ( commit = False ) <EOL> project . team = team <EOL> project . organization = team . organization <EOL> project . save ( ) <EOL> AuditLogEntry . objects . create ( <EOL> organization = project . organization , <EOL> actor = actor , <EOL> ip_address = ip_address , <EOL> target_object = project . id , <EOL> event = AuditLogEntryEvent . PROJECT_ADD , <EOL> data = project . get_audit_log_data ( ) , <EOL> ) <EOL> project_created . send ( project = project , user = actor , sender = self ) <EOL> create_sample_event ( project , platform = '<STR_LIT>' ) <EOL> return project </s>
