Beispiel #1
0
class RegistrationForm(forms.Form):
    first_name = forms.CharField(max_length=30)
    last_name = forms.CharField(max_length=30)
    email = forms.EmailField()
    username = forms.RegexField(
        r"^[a-zA-Z0-9_\-\.]*$",
        max_length=30,
        error_message='Only A-Z, 0-9, "_", "-", and "." allowed.')
    password = forms.CharField(min_length=5, max_length=30)
    password2 = forms.CharField()
Beispiel #2
0
class AddBotForm(forms.Form):
    network = forms.CharField()
    channel = forms.RegexField(r"^[^\s\x00-\x1f,%]+$", max_length=63,
                               error_message='Must be a valid IRC channel name.')

    def is_other_network(self):
        return self.data.get('network') == '_other'

    def clean_network(self):
        if not self.is_other_network():
            try:
                return models.Network.objects.get(pk=int(self.cleaned_data['network']))
            except (ValueError, models.Network.DoesNotExist):
                raise forms.ValidationError("Select a network.")
Beispiel #3
0
class NameForm(forms.Form):
    Domain = forms.RegexField(
        r'^[a-zA-Z0-9\.-]+$',
        help_text="Fully-Qualified Domain Name of this machine")

    Organization = forms.CharField(help_text="Legal Name of Organization")

    OrganizationalUnit = forms.CharField(
        help_text="Organizational Unit, e.g. department name", required=False)

    ApplianceName = forms.CharField(
        help_text="Short name, appears in web pages and emails")

    CommonName = forms.CharField(help_text="Short name, appears in web pages")
Beispiel #4
0
class CreateForm(forms.Form):
    username = forms.RegexField('^[a-zA-Z0-9_]*$', max_length=30)
    first_name = forms.CharField(max_length = 30,
                                 required = False)
    last_name = forms.CharField(max_length = 30,
                                required = False)

    email = forms.EmailField()

    pw1 = forms.CharField(widget = forms.PasswordInput,
                          label = 'Password')
    pw2 = forms.CharField(widget = forms.PasswordInput,
                          label = 'Password (again)',
                          required = False)
Beispiel #5
0
class LocationForm(forms.Form):
    Locality = forms.CharField(help_text="Locality, City, or County Name")
    State = forms.CharField(help_text="State or Province")
    Country = forms.RegexField('^[a-zA-Z][a-zA-Z]$',
                               max_length=2,
                               help_text="2 Letter Country Code")

    GoogleMapKey = forms.CharField(
        required=False,
        help_text=
        "<a target='_new' href='http://www.google.com/apis/maps/signup.html'>Sign up for a Google Map API Key</a>"
    )

    Latitude = forms.CharField(
        required=False,
        help_text=
        r"""Examples: 22N55'23" and 22 N 55.38' and 22.923 are the same latitude"""
    )
    Longitude = forms.CharField(
        required=False,
        help_text=
        r"""Examples: 120W13'51" and -120 13.85' and -120.2308 are the same longitude"""
    )

    Owner = forms.CharField(max_length=255,
                            widget=forms.Textarea(attrs=dict(rows=5, cols=50)),
                            label='Address',
                            help_text="Full Postal Address")

    def clean_Latitude(self):
        x = self.data['Latitude']

        if not x: return x

        try:
            return str(parse_latitude(x))
        except ValueError:
            raise forms.ValidationError('Invalid latitude')

    def clean_Longitude(self):
        x = self.data['Longitude']

        if not x: return x

        try:
            return str(parse_longitude(x))
        except ValueError:
            raise forms.ValidationError('Invalid longitude')
Beispiel #6
0
class AddNetworkForm(forms.Form):
    netname = forms.CharField(max_length=200)
    server = forms.RegexField(r"^([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,6}(:\d+)?$", max_length=120,
                               error_message='Must be a valid hostname with optional port.')

    def get_or_create(self, request):
        """Look up an existing network using this server name,
           creating one if it doesn't already exist.
           """
        uri = "irc://%s/" % self.cleaned_data['server']
        return models.Network.objects.get_or_create(
            uri__iexact = uri,
            defaults = dict(uri = uri,
                            description = self.cleaned_data['netname'],
                            created_by = request.user),
            )[0]
Beispiel #7
0
class PageForm(djangoforms.ModelForm):
  path = forms.RegexField(
    widget=forms.TextInput(attrs={'id':'path'}), 
    regex='(/[a-zA-Z0-9/]+)')
  title = forms.CharField(widget=forms.TextInput(attrs={'id':'title'}))
  template = forms.ChoiceField(choices=config.page_templates.items())
  body = forms.CharField(widget=forms.Textarea(attrs={
      'id':'body',
      'rows': 10,
      'cols': 20}))
  class Meta:
    model = models.Page
    fields = [ 'path', 'title', 'template', 'body' ]

  def clean_path(self):
    data = self._cleaned_data()['path']
    existing_page = models.Page.get_by_key_name(data)
    if not data and existing_page:
      raise forms.ValidationError("The given path already exists.")
    return data
Beispiel #8
0
class IDPForm(forms.Form):
    source_id = forms.CharField(max_length=40)
    name = forms.CharField(max_length=32)

    logo = forms.CharField(widget=forms.FileInput(), required=False)

    domain = forms.RegexField(r'^[a-zA-Z0-9\.\-]*$',
                              max_length=64,
                              required=False)

    logouturl = forms.URLField(max_length=128, required=False)

    website = forms.URLField(max_length=64, required=False)

    format = forms.CharField(
        help_text='Format of identity URL, use % as placeholder for username')

    def clean_format(self):
        format = self.data['format']
        if format.count('%') != 1:
            raise forms.ValidationError(
                'Must have one percent (%) as username placeholder')
        return format
Beispiel #9
0
class ReqForm(forms.Form):
    CN = forms.CharField(label='Domain Name',
			 help_text='Common Name, must be the fully-qualified domain name for this web server')
    C = forms.RegexField('^[A-Z]{2}$',
			 label='Country',
			 max_length = 2,
			 help_text='Two-letter country code.  For example: US')
    ST = forms.CharField(label='State or Province',
			 help_text='For example: California')
    L = forms.CharField(label='City, Locality, or Town',
			help_text='For example: Los Angeles')
    O = forms.CharField(label='Organization')
    OU = forms.CharField(label='Organizational Unit', required=False)

    pw1 = forms.CharField(widget=forms.PasswordInput(),
			  label='Password',
			  help_text='You will be prompted for this password when installing the certificate')
    pw2 = forms.CharField(widget=forms.PasswordInput(),
			  label='Password (again)')

    def clean_pw2(self):
	if self.data['pw1'] != self.data['pw2']:
	    raise forms.ValidationError('Passwords must match')
	return self.data['pw2']
Beispiel #10
0
class CreateForm(forms.Form):
    owner_mcid = forms.RegexField(VALID_MCID)
    id = forms.CharField(widget=forms.HiddenInput(), required=False)
Beispiel #11
0
class GroupForm(forms.Form):
    accid = forms.RegexField(VALID_MCID, label='Group Owner')

    name = forms.CharField(max_length=765, label='Group Name')