<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from django import forms <EOL> from django . conf import settings <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from sentry . models import ProjectOption <EOL> from sentry . web . forms . fields import RangeField <EOL> class NotificationSettingsForm ( forms . Form ) : <EOL> subject_prefix = forms . CharField ( <EOL> label = _ ( '<STR_LIT>' ) , required = False , <EOL> help_text = _ ( '<STR_LIT>' ) ) <EOL> class DigestSettingsForm ( forms . Form ) : <EOL> minimum_delay = RangeField ( <EOL> label = _ ( '<STR_LIT>' ) , <EOL> help_text = _ ( '<STR_LIT>' ) , <EOL> required = False , <EOL> min_value = <NUM_LIT:1> , max_value = <NUM_LIT> , <EOL> ) <EOL> maximum_delay = RangeField ( <EOL> label = _ ( '<STR_LIT>' ) , <EOL> help_text = _ ( '<STR_LIT>' ) , <EOL> required = False , <EOL> min_value = <NUM_LIT:1> , max_value = <NUM_LIT> , <EOL> ) <EOL> def clean ( self ) : <EOL> cleaned = super ( DigestSettingsForm , self ) . clean ( ) <EOL> if cleaned [ '<STR_LIT>' ] > cleaned [ '<STR_LIT>' ] : <EOL> raise forms . ValidationError ( _ ( '<STR_LIT>' ) ) <EOL> return cleaned <EOL> class ProjectQuotasForm ( forms . Form ) : <EOL> per_minute = forms . CharField ( <EOL> label = _ ( '<STR_LIT>' ) , <EOL> widget = forms . TextInput ( attrs = { '<STR_LIT>' : '<STR_LIT>' } ) , <EOL> help_text = _ ( '<STR_LIT>' ) , <EOL> required = False <EOL> ) <EOL> def __init__ ( self , project , * args , ** kwargs ) : <EOL> self . project = project <EOL> super ( ProjectQuotasForm , self ) . __init__ ( * args , ** kwargs ) <EOL> per_minute = ProjectOption . objects . get_value ( <EOL> self . project , '<STR_LIT>' , None <EOL> ) <EOL> if per_minute is None : <EOL> per_minute = settings . SENTRY_DEFAULT_MAX_EVENTS_PER_MINUTE <EOL> self . fields [ '<STR_LIT>' ] . initial = per_minute <EOL> def clean_per_minute ( self ) : <EOL> value = self . cleaned_data . get ( '<STR_LIT>' ) <EOL> if not value : <EOL> return value <EOL> if value . endswith ( '<STR_LIT:%>' ) : <EOL> try : <EOL> pct = int ( value [ : - <NUM_LIT:1> ] ) <EOL> except ( TypeError , ValueError ) : <EOL> raise forms . ValidationError ( '<STR_LIT>' ) <EOL> if pct > <NUM_LIT:100> : <EOL> raise forms . ValidationError ( '<STR_LIT>' ) <EOL> if pct == <NUM_LIT:0> : <EOL> value = '<STR_LIT:0>' <EOL> return value <EOL> def save ( self ) : <EOL> ProjectOption . objects . set_value ( <EOL> self . project , '<STR_LIT>' , self . cleaned_data [ '<STR_LIT>' ] or '<STR_LIT>' <EOL> ) <EOL> class NewRuleForm ( forms . Form ) : <EOL> label = forms . CharField ( <EOL> label = _ ( '<STR_LIT>' ) , <EOL> widget = forms . TextInput ( attrs = { '<STR_LIT>' : '<STR_LIT>' } ) , <EOL> ) </s>
