Exemplo n.º 1
0
 class Meta:
     model = ReversiUser
     fields = ('nickname', 'email', 'theme')
     widgets = {
         'nickname': BootstrapTextInput(prepend='N', ),
         'email': BootstrapTextInput(prepend='E', ),
     }
Exemplo n.º 2
0
 class Meta:
     model = Site
     fields = ('id', 'name', 'url')
     attrs = {
         'id': {
             'widget': HiddenInput(),
         },
         'fresh': {
             'help_text': '',
         },
         'banned': {
             'help_text': '',
         },
         'name': {
             'label':
             '',
             'help_text':
             '',
             'widget':
             BootstrapTextInput(attrs={'placeholder': 'Name of the site'}),
         },
         'url': {
             'label': '',
             'help_text': '',
             'widget':
             BootstrapTextInput(attrs={'placeholder': 'URL Address'}),
         },
     }
Exemplo n.º 3
0
 class Meta:
     category = CategoryModelChoice(queryset=Category.objects.all(),
                                    widget=forms.Select())
     location = LocationModelChoice(queryset=Location.objects.all(),
                                    widget=forms.Select())
     #country_code = CountryCodeModelChoice(queryset = CountriesSupported.objects.all(), widget=forms.Select())
     twitter = forms.CharField(widget=BootstrapTextInput(
         prepend='www.twitter.com/'))
     facebook = forms.CharField(widget=BootstrapTextInput(
         prepend='www.facebook.com/'))
     model = Business
     fields = ('id', 'name', 'xmpp_handle', 'email', 'location', 'website',
               'facebook', 'twitter', 'category', 'phone_number',
               'preview_text', 'active', 'haptik_flag', 'devicehelp_flag',
               'devicehelp_active', 'ios_recommended',
               'android_recommended', 'via_name')
Exemplo n.º 4
0
class EmailForm(forms.Form):
    subject = forms.CharField(
        widget=BootstrapTextInput(attrs={'style': 'width:98%'}),
        label=_('Title'),
        required=True)
    message = forms.CharField(
        widget=Textarea(attrs={'style': 'width:98%;max-width:98%'}),
        label=_('Text'),
        required=True)
Exemplo n.º 5
0
 def __init__(self, *args, **kwargs):
     super(UserProfileForm, self).__init__(*args, **kwargs)
     twitter_id_field = self.fields['twitter_id']
     twitter_id_field.widget = BootstrapTextInput(
         prepend='@',
     )
     twitter_id_field.widget.attrs.update({
         'placeholder': 'Twitter Id'
     })
Exemplo n.º 6
0
 class Meta:
     model = Blog
     fields = ('name', 'title', 'description', 'language', 'theme', 'dirty')
     exclude = ('owner', 'members', 'domain')
     widgets = {
         'name': NameWidget,
         'description':
         forms.Textarea(attrs={'class': 'input-block-level'}),
         'title': BootstrapTextInput({'class': 'input-block-level'}),
         'dirty': forms.HiddenInput(),
     }
Exemplo n.º 7
0
class BusinessForm(forms.ModelForm):

    category = CategoryModelChoice(queryset=Category.objects.filter(active=1),
                                   widget=forms.Select())
    location = LocationModelChoice(queryset=CountriesSupported.objects.all(),
                                   widget=forms.Select())
    #country_code = CountryCodeModelChoice(queryset = CountriesSupported.objects.all(), widget=forms.Select())
    twitter = forms.CharField(widget=BootstrapTextInput(
        prepend='www.twitter.com/'))
    facebook = forms.CharField(widget=BootstrapTextInput(
        prepend='www.facebook.com/'))

    def __init__(self, *args, **kwargs):
        print 'IN INIT'
        print 'args : ', args
        print 'kwargs : ', kwargs
        super(BusinessForm, self).__init__(*args, **kwargs)
        for key in [
                'email', 'website', 'facebook', 'twitter', 'phone_number',
                'preview_text', 'location'
        ]:
            self.fields[key].required = False

    class Meta:
        category = CategoryModelChoice(queryset=Category.objects.all(),
                                       widget=forms.Select())
        location = LocationModelChoice(queryset=Location.objects.all(),
                                       widget=forms.Select())
        #country_code = CountryCodeModelChoice(queryset = CountriesSupported.objects.all(), widget=forms.Select())
        twitter = forms.CharField(widget=BootstrapTextInput(
            prepend='www.twitter.com/'))
        facebook = forms.CharField(widget=BootstrapTextInput(
            prepend='www.facebook.com/'))
        model = Business
        fields = ('id', 'name', 'xmpp_handle', 'email', 'location', 'website',
                  'facebook', 'twitter', 'category', 'phone_number',
                  'preview_text', 'active', 'haptik_flag', 'devicehelp_flag',
                  'devicehelp_active', 'ios_recommended',
                  'android_recommended', 'via_name')
Exemplo n.º 8
0
class ClientSignupForm(EmailRegistrationForm):

    email = forms.EmailField(max_length=256,
                             required=True,
                             widget=forms.TextInput(attrs={'class': 'email'}),
                             label="Email")
    password1 = forms.CharField(required=True,
                                widget=forms.PasswordInput(
                                    attrs={'class': 'password'},
                                    render_value=False),
                                label="Password")
    password2 = forms.CharField(required=True,
                                widget=forms.PasswordInput(
                                    attrs={'class': 'password'},
                                    render_value=False),
                                label="Password (repeat)")
    your_name = forms.CharField(required=False)
    pub_name = forms.CharField(label='News organization name', required=True)
    pub_type = forms.ChoiceField(choices=PUB_TYPES,
                                 label='News media type',
                                 required=True)
    first_name = forms.CharField(label='First name', required=True)
    last_name = forms.CharField(label='Last name', required=True)
    address = forms.CharField(max_length=100, required=True)
    city = forms.CharField(max_length=100, required=True)
    state = forms.CharField(widget=USStateSelect(),
                            initial="NE",
                            required=True)
    zipcode = forms.CharField(
        max_length=5,
        required=True,
        widget=BootstrapTextInput(attrs={'class': 'zipcode'}))
    phone = forms.CharField(max_length=15, required=True)
    pub_area = forms.CharField(
        max_length=100,
        required=True,
        label="Circulation or Broadcast Area",
        widget=BootstrapTextInput(attrs={'class': 'circarea'}))
    about = forms.CharField(
        required=False,
        label="Special Topics of interest to your audience. (optional)",
        widget=BootstrapTextInput(attrs={
            'class': 'specialtopics',
        }))
    twitter = forms.CharField(
        max_length=150,
        required=False,
        label="Twitter (optional)",
        widget=BootstrapTextInput(attrs={'class': 'website'}))
    facebook = forms.CharField(
        max_length=150,
        required=False,
        label="Facebook (optional)",
        widget=BootstrapTextInput(attrs={'class': 'website'}))
    website = forms.URLField(
        max_length=200,
        required=False,
        label="Website (optional)",
        widget=BootstrapTextInput(attrs={'class': 'website'}))
Exemplo n.º 9
0
class LoginForm(forms.Form):

    username = forms.CharField(
        label='',
        max_length=100,
        required=True,
        widget=BootstrapTextInput(attrs={'placeholder': 'Username'}),
    )
    password = forms.CharField(
        label='',
        max_length=100,
        required=True,
        widget=BootstrapPasswordInput(attrs={'placeholder': 'Password'}),
    )
Exemplo n.º 10
0
def identification_field_factory(label, error_required):
    """
    A simple identification field factory which enable you to set the label.

    :param label:
        String containing the label for this field.

    :param error_required:
        String containing the error message if the field is left empty.

    """
    return forms.CharField(label=label,
                           widget=BootstrapTextInput(attrs=attrs_dict),
                           max_length=75,
                           error_messages={'required': error_required})
Exemplo n.º 11
0
 class Meta:
     model = SearchResult
     fields = ('id', 'sequence')
     attrs = {
         'id': {
             'widget': HiddenInput(),
         },
         'sequence': {
             'label':
             '',
             'widget':
             BootstrapTextInput(
                 attrs={'placeholder': 'Sequence number(s)'}),
         }
     }
Exemplo n.º 12
0
 class Meta:
     model = Post
     fields = ('blog', 'title', 'slug', 'tags', 'date', 'description',
               'markup', 'text', 'dirty')
     exclude = ('author', )
     widgets = {
         'title':
         BootstrapTextInput({'class': 'input-block-level'}),
         'slug':
         BootstrapTextInput({'class': 'input-block-level'}),
         'tags':
         BootstrapTextInput({'class': 'input-block-level'}),
         'date':
         DateTimeWidget(),
         'description':
         forms.Textarea({
             'rows': 3,
             'class': 'input-block-level'
         }),
         'text':
         forms.Textarea(),
         'dirty':
         forms.HiddenInput(),
     }
Exemplo n.º 13
0
class RevisionForm(forms.ModelForm):
    class Meta:
        model = Revision

    f_actualizacion = forms.DateField(widget=BootstrapDateInput(attrs={}, ), )
    cambios = forms.CharField(label='Registro de Cambios',
                              widget=forms.Textarea(
                                  attrs={
                                      'rows': 5,
                                      'cols': 78,
                                      'style': 'width: 80%; height: 120px',
                                      'class': 'wmd-input'
                                  }))
    revision = forms.CharField(widget=BootstrapTextInput(attrs={
        'class': 'input-mini',
    }, ), )
Exemplo n.º 14
0
 class Meta:
     model = Search
     fields = (
         'engine',
         'q',
     )
     attrs = {
         'engine': {
             'label': '',
             'empty_label': 'Select engine',
             'queryset': model.engine.get_query_set().filter(active=True),
         },
         'q': {
             'label':
             '',
             'widget':
             BootstrapTextInput(attrs={'placeholder': 'Query string'}),
         },
     }
Exemplo n.º 15
0
class MultiplayerGameForm(forms.Form):
    name = forms.CharField(
        label=mark_safe('<span class="text-large">Spielname</span>'),
        initial=random_game_name,
        max_length=100,
        help_text=
        u'Jede Schlacht sollte einen sehr coolen Namen für die Geschichtsbücher haben!',
        widget=BootstrapTextInput(prepend='N',
                                  attrs={
                                      'placeholder': 'Benenne das Spiel',
                                      'class': 'input-xxlarge'
                                  }),
    )
    player = forms.ChoiceField(
        label=mark_safe(
            u'<span class="text-large">Wer beginnt die Schlacht?</span>'),
        help_text=
        u"Wähle ob Du die legendäre Schlacht beginnen oder Dein Territorium verteiltigen möchstest.",
        choices=(
            (CELL_PLAYER1, "Ich selbst"),
            (CELL_PLAYER2, "Mein Gegner"),
        ),
        widget=forms.RadioSelect(attrs={
            'inline': True,
            'class': 'input-xlarge'
        }))
    color = forms.ChoiceField()

    def __init__(self, user, *args, **kwargs):
        super(MultiplayerGameForm, self).__init__(*args, **kwargs)
        self.fields["color"] = forms.ChoiceField(
            label=mark_safe('<span class="text-large">Meine Farbe</span>'),
            choices=(
                (CELL_PLAYER1, user.theme.player1),
                (CELL_PLAYER2, user.theme.player2),
            ),
            widget=forms.RadioSelect(attrs={
                'inline': True,
                'class': 'input-xlarge'
            }))
Exemplo n.º 16
0
 class Meta:
     model = SiteData
     fields = ('id', 'category', 'fresh', 'banned')
     attrs = {
         'id': {
             'widget': HiddenInput(),
         },
         'fresh': {
             'help_text': '',
         },
         'banned': {
             'help_text': '',
         },
         'name': {
             'help_text': '',
             'widget': BootstrapTextInput(attrs={'class': 'span11'}),
         },
         'category': {
             'label': '',
             'empty_label': 'Select category',
             'queryset': model.category.get_query_set().filter(active=True),
         },
     }
Exemplo n.º 17
0
class TestForm(forms.Form):
    date = forms.DateField(widget=BootstrapDateInput(), )
    title = forms.CharField(
        max_length=100,
        help_text=u'This is the standard text input',
    )
    disabled = forms.CharField(
        max_length=100,
        help_text=u'I am disabled',
        widget=forms.TextInput(attrs={
            'disabled': 'disabled',
            'placeholder': 'I am disabled',
        }))
    uneditable = forms.CharField(
        max_length=100,
        help_text=u'I am uneditable and you cannot enable me with JS',
        initial=u'Uneditable',
        widget=BootstrapUneditableInput())
    content = forms.ChoiceField(
        choices=(
            ("text", "Plain text"),
            ("html", "HTML"),
        ),
        help_text=u'Pick your choice',
    )
    email = forms.EmailField()
    like = forms.BooleanField(required=False)
    fruits = forms.MultipleChoiceField(
        widget=forms.CheckboxSelectMultiple,
        choices=(
            ("apple", "Apple"),
            ("pear", "Pear"),
        ),
        help_text=u'As you can see, multiple checkboxes work too',
    )
    veggies = forms.MultipleChoiceField(
        widget=forms.CheckboxSelectMultiple(attrs={
            'inline': True,
        }),
        choices=(
            ("broccoli", "Broccoli"),
            ("carrots", "Carrots"),
            ("turnips", "Turnips"),
        ),
        help_text=u'And can be inline',
    )
    color = forms.ChoiceField(
        widget=forms.RadioSelect,
        choices=(
            ("#f00", "red"),
            ("#0f0", "green"),
            ("#00f", "blue"),
        ),
        help_text=u'And we have <i>radiosets</i>',
    )
    prepended = forms.CharField(
        max_length=100,
        help_text=u'I am prepended by a P',
        widget=BootstrapTextInput(prepend='P'),
    )

    def clean(self):
        cleaned_data = super(TestForm, self).clean()
        raise forms.ValidationError(
            "This error was added to show the non field errors styling.")
        return cleaned_data
Exemplo n.º 18
0
class TestForm(forms.Form):
    date = forms.DateField(
        widget=BootstrapDateInput(),
    )
    title = forms.CharField(
        max_length=100,
        help_text=u'This is the standard text input',
    )
    body = forms.CharField(
        max_length=100,
        help_text=u'This is a text area',
        widget=forms.Textarea(
            attrs={
                'title': 'I am "nice"',
            }
        ),
    )
    disabled = forms.CharField(
        max_length=100,
        required=False,
        help_text=u'I am disabled',
        widget=forms.TextInput(attrs={
            'disabled': 'disabled',
            'placeholder': 'I am disabled',
        })
    )
    content = forms.ChoiceField(
        choices=(
            ("text", "Plain text"),
            ("html", "HTML"),
        ),
        help_text=u'Pick your choice',
    )
    email = forms.EmailField()
    like = forms.BooleanField(required=False)
    fruits = forms.MultipleChoiceField(
        widget=forms.CheckboxSelectMultiple,
        choices=(
            ("apple", "Apple"),
            ("pear", "Pear"),
        ),
        help_text=u'As you can see, multiple checkboxes work too',
    )
    number = forms.MultipleChoiceField(
        widget=forms.CheckboxSelectMultiple(attrs={
            'inline': True,
        }),
        choices=(
            ("3", "Three"),
            ("33", "Thirty three"),
            ("333", "Three hundred thirty three"),
        ),
        help_text=u'And can be inline',
    )
    color = forms.ChoiceField(
        widget=forms.RadioSelect(attrs={'data-demo-attr': 'bazinga'}),
        choices=(
            ("#f00", "red"),
            ("#0f0", "green"),
            ("#00f", "blue"),
        ),
        help_text=u'And we have <i>radiosets</i>',
    )
    prepended = forms.CharField(
        max_length=100,
        help_text=u'I am prepended by a P',
        widget=BootstrapTextInput(prepend='P'),
    )

    def clean(self):
        cleaned_data = super(TestForm, self).clean()
        raise forms.ValidationError("This error was added to show the non field errors styling.")
        return cleaned_data
Exemplo n.º 19
0
 class Meta:
     model = Ticket
     exclude = ['event', 'sale', 'success', 'checked_in', 'lobby_day', 'ambassador_program']
     widgets = {
         'twitter': BootstrapTextInput(attrs={'placeholder': "e.g., \"tcampdc\""}),
     }
Exemplo n.º 20
0
class SignupForm(forms.Form):
    """
    Form for creating a new user account.

    Validates that the requested username and e-mail is not already in use.
    Also requires the password to be entered twice.

    """
    username = forms.RegexField(
        regex=USERNAME_RE,
        max_length=30,
        widget=BootstrapTextInput(attrs=attrs_dict),
        label=_("Username"),
        error_messages={
            'invalid':
            _('Username must contain only letters, numbers, dots and underscores.'
              )
        })
    email = forms.EmailField(
        widget=BootstrapTextInput(attrs=dict(attrs_dict, maxlength=75)),
        label=_("Email"))
    password1 = forms.CharField(widget=BootstrapPasswordInput(),
                                label=_("Create password"))
    password2 = forms.CharField(widget=BootstrapPasswordInput(
        attrs=attrs_dict, render_value=False),
                                label=_("Repeat password"))

    def clean_username(self):
        """
        Validate that the username is alphanumeric and is not already in use.
        Also validates that the username is not listed in
        ``USERENA_FORBIDDEN_USERNAMES`` list.

        """
        try:
            user = get_user_model().objects.get(
                username__iexact=self.cleaned_data['username'])
        except get_user_model().DoesNotExist:
            pass
        else:
            if userena_settings.USERENA_ACTIVATION_REQUIRED and UserenaSignup.objects.filter(
                    user__username__iexact=self.cleaned_data['username']
            ).exclude(activation_key=userena_settings.USERENA_ACTIVATED):
                raise forms.ValidationError(
                    _('This username is already taken but not confirmed. Please check your email for verification steps.'
                      ))
            raise forms.ValidationError(_('This username is already taken.'))
        if self.cleaned_data['username'].lower(
        ) in userena_settings.USERENA_FORBIDDEN_USERNAMES:
            raise forms.ValidationError(_('This username is not allowed.'))
        return self.cleaned_data['username']

    def clean_email(self):
        """ Validate that the e-mail address is unique. """
        if get_user_model().objects.filter(
                email__iexact=self.cleaned_data['email']):
            if userena_settings.USERENA_ACTIVATION_REQUIRED and UserenaSignup.objects.filter(
                    user__email__iexact=self.cleaned_data['email']).exclude(
                        activation_key=userena_settings.USERENA_ACTIVATED):
                raise forms.ValidationError(
                    _('This email is already in use but not confirmed. Please check your email for verification steps.'
                      ))
            raise forms.ValidationError(
                _('This email is already in use. Please supply a different email.'
                  ))
        return self.cleaned_data['email']

    def clean(self):
        """
        Validates that the values entered into the two password fields match.
        Note that an error here will end up in ``non_field_errors()`` because
        it doesn't apply to a single field.

        """
        if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data:
            if self.cleaned_data['password1'] != self.cleaned_data['password2']:
                raise forms.ValidationError(
                    _('The two password fields didn\'t match.'))
        return self.cleaned_data

    def save(self):
        """ Creates a new user and account. Returns the newly created user. """
        username, email, password = (self.cleaned_data['username'],
                                     self.cleaned_data['email'],
                                     self.cleaned_data['password1'])

        new_user = UserenaSignup.objects.create_user(
            username, email, password,
            not userena_settings.USERENA_ACTIVATION_REQUIRED,
            userena_settings.USERENA_ACTIVATION_REQUIRED)
        return new_user
Exemplo n.º 21
0
 class Meta:
     model = Organization
     fields = ('org_name', )
     widgets = {'org_name': BootstrapTextInput()}