Example #1
0
 def __init__(self):
     self.fields = (
         oldforms.TextField(field_name="person_name", max_length=50, is_required=True,
             validator_list=[self.hasNoProfanities]),
         oldforms.LargeTextField(field_name="comment", max_length=3000, is_required=True,
             validator_list=[self.hasNoProfanities]),
     )
 def __init__(self, settings_modules):
     self.settings_modules = settings_modules
     site_list = Site.objects.in_bulk(settings_modules.keys()).values()
     self.fields = (
         oldforms.SelectField('site', is_required=True, choices=[(s.id, s.name) for s in site_list]),
         oldforms.LargeTextField('template', is_required=True, rows=25, validator_list=[self.isValidTemplate]),
     )
Example #3
0
 def __init__(self, user, ratings_required, ratings_range, num_rating_choices):
     AuthenticationForm.__init__(self)
     self.ratings_range, self.num_rating_choices = ratings_range, num_rating_choices
     choices = [(c, c) for c in ratings_range]
     def get_validator_list(rating_num):
         if rating_num <= num_rating_choices:
             return [validators.RequiredIfOtherFieldsGiven(['rating%d' % i for i in range(1, 9) if i != rating_num], _("This rating is required because you've entered at least one other rating."))]
         else:
             return []
     self.fields.extend([
         oldforms.LargeTextField(field_name="comment", max_length=3000, is_required=True,
             validator_list=[self.hasNoProfanities]),
         oldforms.RadioSelectField(field_name="rating1", choices=choices,
             is_required=ratings_required and num_rating_choices > 0,
             validator_list=get_validator_list(1),
         ),
         oldforms.RadioSelectField(field_name="rating2", choices=choices,
             is_required=ratings_required and num_rating_choices > 1,
             validator_list=get_validator_list(2),
         ),
         oldforms.RadioSelectField(field_name="rating3", choices=choices,
             is_required=ratings_required and num_rating_choices > 2,
             validator_list=get_validator_list(3),
         ),
         oldforms.RadioSelectField(field_name="rating4", choices=choices,
             is_required=ratings_required and num_rating_choices > 3,
             validator_list=get_validator_list(4),
         ),
         oldforms.RadioSelectField(field_name="rating5", choices=choices,
             is_required=ratings_required and num_rating_choices > 4,
             validator_list=get_validator_list(5),
         ),
         oldforms.RadioSelectField(field_name="rating6", choices=choices,
             is_required=ratings_required and num_rating_choices > 5,
             validator_list=get_validator_list(6),
         ),
         oldforms.RadioSelectField(field_name="rating7", choices=choices,
             is_required=ratings_required and num_rating_choices > 6,
             validator_list=get_validator_list(7),
         ),
         oldforms.RadioSelectField(field_name="rating8", choices=choices,
             is_required=ratings_required and num_rating_choices > 7,
             validator_list=get_validator_list(8),
         ),
     ])
     if user.is_authenticated():
         self["username"].is_required = False
         self["username"].validator_list = []
         self["password"].is_required = False
         self["password"].validator_list = []
         self.user_cache = user