Exemplo n.º 1
0
    def _process(self, request):
        user = self.request.user
        password = self.cleaned_data.get('new_password', '')
        user.set_password(password)
        user.save()

        Utils.set_msg(self.request,
                      "You password has been updated. Please login now. ")
        return {'return': 302, 'redirect_url': reverse('login')}
Exemplo n.º 2
0
    def _render_http(self, request, node_dict, flag_html=False):
        """ Sub render method for normal HTTP
        :param request - Django request object
        :param node_dict - dict to be passed to template
        :return: dict
        """

        code = int(node_dict.get('return'))
        msg = node_dict.get('msg')
        redirect_url = node_dict.get('redirect_url')

        # check for error in implementation
        if int(code) == 302 and not redirect_url:
            raise Exception("Redirect URL is not found. ")  # pragma: no cover
        elif int(code) >= 400 and not msg:
            raise Exception("No error detail. ")  # pragma: no cover

        # msg
        if msg:
            Utils.set_msg(request, msg)

        # redirect
        if redirect_url:
            try:
                print "---> going to do a redict: %s" % redirect_url
                return redirect(redirect_url)
            except NoReverseMatch:
                return redirect("/")

        # error
        if code >= 400:
            return render_to_response(node_dict['x_error_template'],
                                      node_dict,
                                      context_instance=RequestContext(request))

        # render
        if flag_html:
            t = loader.get_template(node_dict['x_template'])
            c = Context(node_dict)
            html = t.render(c)
            return html
        return render_to_response(node_dict['x_template'],
                                  node_dict,
                                  context_instance=RequestContext(request))
Exemplo n.º 3
0
 def _process(self, request):
     # Create user account                
     raw_email = self.cleaned_data.get("email", None) 
     display_name = self.cleaned_data.get("display_name", None)
     password = self.cleaned_data.get("password", None)
     
     user_email = SignUpForm.normalize_email(self.request, raw_email)
     new_user = User.objects.create_user(user_email, user_email, password=password)
     new_user.is_active = True
     new_user.actual_email = raw_email
     new_user.display_name = display_name
     new_user.display_name_slug = slugify(display_name)
     new_user.save()
     
     user = authenticate(username=user_email, password=password)
     if user is not None: 
         auth_login(self.request, user)   
         Utils.set_msg(self.request, "Thank you, your account has been created. ")
     return {'return':'302',
             'redirect_url': reverse('login')}