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("/")
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
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
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 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
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