Example #1
0
def form_helper(action_name, button_name):
    """ Shortcut to generate django-uniform helper """
    helper = FormHelper()
    helper.form_action = action_name
    helper.form_method = 'POST'
    helper.add_input(Submit('', button_name))
    return helper
Example #2
0
class DocumentForm(ModelForm):
    class Meta:
        model = Document
        fields = ('file', 'filename', 'tags', 'show', 'group')

    def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.add_input(Submit('button', 'Submit'))
        return super(DocumentForm, self).__init__(*args, **kwargs)
Example #3
0
 def __init__(self, *args, **kwargs):
     super(EventForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         'name',
         'date',
     )
Example #4
0
    def __init__(self, *args, **kwargs):
        self.legend = kwargs.pop('legend', 'Entry')
        self.compo = kwargs.pop('compo', None)
        self.editing = kwargs.pop('editing', False)

        # Max sizes for filefields
        self.max_source_size = self.compo.source_sizelimit
        self.max_entry_size = self.compo.entry_sizelimit

        # Layout for uni-form ext.
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Fieldset(self.legend, 'name', 'creator', 'description',
                     'entryfile', 'sourcefile', 'imagefile_original',
                     ButtonHolder(Submit('submit', 'Tallenna'))))

        # Create the fields
        super(EntryForm, self).__init__(*args, **kwargs)

        # Give the entryfile and sourcefile fields a nicer help_text
        if self.compo:
            self.fields[
                'entryfile'].help_text = u"Tuotospaketti. Sallitut tiedostoformaatit: " + self.compo.readable_entry_formats(
                ) + u'. Tiedoston maksimikoko on ' + sizeformat(
                    self.max_entry_size) + '.'
            self.fields[
                'sourcefile'].help_text = u"Lähdekoodipaketti. Sallitut tiedostoformaatit: " + self.compo.readable_source_formats(
                ) + u'. Tiedoston maksimikoko on ' + sizeformat(
                    self.max_source_size) + '.'

        # If we are editing, then entryfile field is not required
        if self.editing:
            self.fields['entryfile'].required = False
Example #5
0
 def __init__(self, *args, **kwargs):
     self.helper = FormHelper()
     submit = Submit(u'submit', u'Submit')
     self.helper.add_input(submit)
     self.helper.form_method = u'POST'
     self.helper.form_class = u'uni_form'
     super(BaseEmailForm, self).__init__(*args, **kwargs)
Example #6
0
 def __init__(self, *args, **kwargs):
     super(AdminEntryForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Fieldset(u'Tuotos', 'compo', 'name', 'description', 'creator',
                  'entryfile', 'sourcefile', 'imagefile_original',
                  'youtube_url', 'disqualified', 'disqualified_reason',
                  ButtonHolder(Submit('submit', 'Tallenna'))))
Example #7
0
def authorize(request):
    authorizer = Authorizer()
    try:
        authorizer.validate(request)
    except MissingRedirectURI:
        return HttpResponseRedirect("/oauth2/missing_redirect_uri")
    except AuthorizationException:
        # The request is malformed or invalid. Automatically 
        # redirects to the provided redirect URL.
        return authorizer.error_redirect()
    if request.method == 'GET':
        # Make sure the authorizer has validated before requesting the client
        # or access_ranges as otherwise they will be None.
        template = {
            "client": authorizer.client, 
            "access_ranges": authorizer.access_ranges}
        template["form"] = AuthorizeForm()
        helper = FormHelper()
        no_submit = Submit('connect', 'No')
        helper.add_input(no_submit)
        yes_submit = Submit('connect', 'Yes')
        helper.add_input(yes_submit)
        helper.form_action = '/oauth2/authorize?%s' % authorizer.query_string
        helper.form_method = 'POST'
        template["helper"] = helper
        return render_to_response('oauth2/authorize.html', template, RequestContext(request))
    elif request.method == 'POST':
        form = AuthorizeForm(request.POST)
        if form.is_valid():
            if request.POST.get("connect") == "Yes":
                return authorizer.grant_redirect()
            else:
                return authorizer.error_redirect()
    return HttpResponseRedirect("/")
Example #8
0
class BaseEmailForm(forms.Form):
    sender = forms.EmailField(
        label=u'E-mail',
        error_messages={u'required': u'Please enter an e-mail address.'}
    )
    sender_name = forms.CharField(
        max_length=100,
        label=u'Your Name',
        error_messages={u'required': u'Please enter your name.'}
    )
    captcha = CaptchaField(label=u'Type the letters below')

    def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        submit = Submit(u'submit', u'Submit')
        self.helper.add_input(submit)
        self.helper.form_method = u'POST'
        self.helper.form_class = u'uni_form'
        super(BaseEmailForm, self).__init__(*args, **kwargs)
Example #9
0
 def __init__(self, *args, **kwargs):
     super(AdminCompoForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Fieldset(u'Kompo', 'name', 'description', 'adding_end',
                  'editing_end', 'compo_start', 'voting_start',
                  'voting_end', 'entry_sizelimit', 'source_sizelimit',
                  'formats', 'source_formats', 'active',
                  'show_voting_results', 'entry_view_type',
                  ButtonHolder(Submit('submit', 'Tallenna'))))
Example #10
0
 def helper(self):
     form = CreateClientForm()
     helper = FormHelper()
     reset = Reset('', 'Reset')
     helper.add_input(reset)
     submit = Submit('', 'Create Client')
     helper.add_input(submit)
     helper.form_action = '/account/clients'
     helper.form_method = 'POST'
     return helper
Example #11
0
 def helper(self):
     form = LoginForm()
     helper = FormHelper()
     reset = Reset('', 'Reset')
     helper.add_input(reset)
     submit = Submit('', 'Log In')
     helper.add_input(submit)
     helper.form_action = '/account/login'
     helper.form_method = 'POST'
     return helper
Example #12
0
 def helper(self):
     form = SignupForm()
     helper = FormHelper()
     reset = Reset('', 'Reset')
     helper.add_input(reset)
     submit = Submit('', 'Sign Up')
     helper.add_input(submit)
     helper.form_action = '/account/signup'
     helper.form_method = 'POST'
     return helper
 def standard_layout(self):
     """
     A reasonable generic layout for messages; if uni_form is not installed,
     this will fail silently and return ``None``.
     """
     try:
         from uni_form.helper import FormHelper
         from uni_form.layout import Layout, ButtonHolder, Submit
         helper = FormHelper()
         helper.form_method = "POST"
         helper.layout = Layout(
                     'recipients',
                     'subject',
                     'language',
                     'body',
                     ButtonHolder(
                             Submit('send', 'Send')
                         )
                 )
         return helper
     except ImportError:
         return None
Example #14
0
    def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_id = 'id-inviteRequest'
        self.helper.form_class = 'blueForms'
        self.helper.form_method = 'post'
        self.helper.form_action = 'privatebeta_invite'

        self.helper.layout = Layout(
            Div('first_name', 'last_name', css='ctrlHolder'),
            Div('email'),
            ButtonHolder(
                Submit('submit',
                       'Submit',
                       css_class='nice white button radius')
                #	Submit('submit', 'Submit', css_class='primaryAction')
            ))

        return super(InviteRequestForm, self).__init__(*args, **kwargs)
Example #15
0
    def helper(self):
        helper = FormHelper()

        helper.form_id = 'id-payment-form'
        helper.form_class = 'korta-form'
        helper.form_method = 'post'
        helper.form_action = 'submit_payment'

        helper.layout = Layout(
            Fieldset(
                _(u'Payment Information'),
                HTML('{% include "djkorta/cc_types.html" %}'),
                'number',
                Row('expiration_month','expiration_year'),
                'ccv',
            ),
            ButtonHolder(
                Submit('submit', _(u'Checkout'),
                    css_class='button')
            )
        )
        return helper
Example #16
0
 def __init__(self, *args, **kwargs):
     super(CreateTokensForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Fieldset(u'Generoi tokeneita', 'amount',
                  ButtonHolder(Submit('submit', 'Generoi'))))
Example #17
0
 def __init__(self, *args, **kwargs):
     super(RequestVoteCodeForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Fieldset(u'Pyydä äänestysoikeutta', 'text', 'formtype',
                  ButtonHolder(Submit('submit', 'Pyydä äänestysoikeutta'))))
Example #18
0
 def __init__(self, *args, **kwargs):
     self.helper = FormHelper()
     self.helper.add_input(Submit('button', 'Submit'))
     return super(DocumentForm, self).__init__(*args, **kwargs)
Example #19
0
 def __init__(self, *args, **kwargs):
     super(VoteCodeAssocForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Fieldset(u'Syötä äänestyskoodi', 'code', 'formtype',
                  ButtonHolder(Submit('submit', 'Tallenna'))))