示例#1
0
    def set_helper(self):
        print "AadhaarLoginForm.helper In helper"
        #form = AadhaarLoginForm()
        helper = FormHelper()
        reset = Reset('', 'Reset')
        helper.add_input(reset)
        submit = Submit('', 'Authenticate')
        helper.add_input(submit)
        helper.form_action = '/aadhaar/authenticate/' + self.detail
        helper.form_method = 'POST'
        helper.form_class = "blueForms"

        style = """
<style>
fieldset.formRow {
         margin-bottom: 1em;
         border-width: 0 0 1px 0;
         border-color:#CCCCCC;
         border-style:solid;
}
</style>
"""
        common_layout = Layout(
            Fieldset(
                'Required Parameters',
                'aadhaar_id',
                'aadhaar_attributes',
            ))
        pi_layout = Layout(
            Fieldset(
                "Personally Identifiable Information",
                'aadhaar_pi_match',
                'aadhaar_name',
                'aadhaar_dob',
                'aadhaar_age',
                'aadhaar_gender',
                'aadhaar_email',
                'aadhaar_phone',
            ))
        pa_layout = Layout(
            Fieldset("Address", 'aadhaar_pa_match', 'aadhaar_co',
                     'aadhaar_house', 'aadhaar_street', 'aadhaar_landmark',
                     'aadhaar_locality', 'aadhaar_vtc', 'aadhaar_subdist',
                     'aadhaar_district', 'aadhaar_state', 'aadhaar_pincode',
                     'aadhaar_postoffice'))

        if self.detail == "personal":
            layout = Layout(common_layout, pi_layout)
        elif self.detail == "address":
            layout = Layout(common_layout, pa_layout)
        else:
            layout = Layout(common_layout, pi_layout, pa_layout)

        helper.layout = layout

        self.helper = helper
示例#2
0
    def test_i18n(self):
        template = get_template_from_string(u"""
            {% load uni_form_tags %}
            {% uni_form form form.helper %}
        """)
        form = TestForm()
        form_helper = FormHelper()
        form_helper.layout = Layout(
            HTML(_("i18n text")),
            Fieldset(
                _("i18n legend"),
                'first_name',
                'last_name',
            ))
        form.helper = form_helper

        html = template.render(Context({'form': form}))
示例#3
0
    def test_i18n(self):
        template = get_template_from_string(u"""
            {% load uni_form_tags %}
            {% uni_form form form.helper %}
        """)
        form = TestForm()
        form_helper = FormHelper()
        form_helper.layout = Layout(
            HTML(_("i18n text")),
            Fieldset(
                _("i18n legend"),
                'first_name',
                'last_name',
            )
        )
        form.helper = form_helper

        html = template.render(Context({'form': form}))
示例#4
0
def profile_edit(request, template_name="profiles/profile_edit.html"):

    profile = request.user.get_profile()
    form = ProfileForm(request.POST or None, instance=profile)

    if form.is_valid():
        form.save()
        msg = 'Profile edited'
        messages.add_message(request, messages.INFO, msg)
        return HttpResponseRedirect(reverse("profile_detail", kwargs={"github_account":profile.github_account }))
        
    # TODO - move this to a template
    github_account = """
    <div 
        id="div_id_github_account" 
        class="ctrlHolder"><label for="id_github_account" >Github account</label><strong>{0}</strong></div>
    """.format(profile.github_account)
        
    helper = FormHelper()
    helper.form_class = "profile-edit-form"
    helper.layout = Layout(
        Fieldset(
            '',
            HTML(github_account),
            'bitbucket_url',
            'google_code_url',
            'email',
        ),
        ButtonHolder(
            Submit('edit', 'Edit', css_class="awesome forestgreen"),
        )
    )        

    return render_to_response(template_name,
        {
            "profile": profile,
            "form": form,
            "helper":helper,
        },
        context_instance=RequestContext(request)
    )
示例#5
0
def profile_edit(request, template_name="profiles/profile_edit.html"):

    profile = request.user.get_profile()
    form = ProfileForm(request.POST or None, instance=profile)

    if form.is_valid():
        print form.instance.__dict__
        form.save()
        msg = 'Profile edited'
        messages.add_message(request, messages.INFO, msg)
        return HttpResponseRedirect(reverse("profile_detail", kwargs={"github_account": profile.github_account}))

    # TODO - move this to a template
    github_account = """
    <div
        id="div_id_github_account"
        class="ctrlHolder"><label for="id_github_account" >Github account</label><strong>{0}</strong></div>
    """.format(profile.github_account)

    helper = FormHelper()
    helper.form_class = "profile-edit-form"
    helper.layout = Layout(
        Fieldset(
            '',
            HTML(github_account),
            'bitbucket_url',
            'google_code_url',
        ),
        ButtonHolder(
            Submit('edit', 'Edit', css_class="awesome forestgreen"),
        )
    )

    return render(request, template_name,
        {
            "profile": profile,
            "form": form,
            "helper": helper,
        })
示例#6
0
    def set_helper(self):
        print "AadhaarLoginForm.helper In helper"
        #form = AadhaarLoginForm()
        helper = FormHelper()
        reset = Reset('','Reset')
        helper.add_input(reset)
        submit = Submit('','Authenticate')
        helper.add_input(submit)
        helper.form_action = '/aadhaar/authenticate/' + self.detail 
        helper.form_method = 'POST'
        helper.form_class="blueForms"

        style="""
<style>
fieldset.formRow {
         margin-bottom: 1em;
         border-width: 0 0 1px 0;
         border-color:#CCCCCC;
         border-style:solid;
}
</style>
"""
        common_layout =  Layout(
            Fieldset('Required Parameters',
                     'aadhaar_id',
                     'aadhaar_attributes',
                     )
            )
        pi_layout= Layout(
            Fieldset("Personally Identifiable Information",
                     'aadhaar_pi_match',
                     'aadhaar_name',
                     'aadhaar_dob', 
                     'aadhaar_age',
                     'aadhaar_gender',
                     'aadhaar_email',
                     'aadhaar_phone',
                     )
            )
        pa_layout = Layout(
            Fieldset("Address",
                     'aadhaar_pa_match',
                     'aadhaar_co',
                     'aadhaar_house',
                     'aadhaar_street',
                     'aadhaar_landmark',
                     'aadhaar_locality',
                     'aadhaar_vtc',
                     'aadhaar_subdist',
                     'aadhaar_district',
                     'aadhaar_state',
                     'aadhaar_pincode',
                     'aadhaar_postoffice')
            )
        
        if self.detail == "personal": 
            layout = Layout(common_layout, pi_layout)
        elif self.detail == "address":
            layout = Layout(common_layout, pa_layout)
        else:
            layout = Layout(common_layout, pi_layout, pa_layout)
            
        helper.layout = layout

        self.helper = helper