Esempio n. 1
0
 def test_creating_adviser_user_on_invitation_and_form(self):
     """
     Ensure we can crate AdviserUser using AdviserInvitation and Form
     """
     test_user = {"first_name": "Test", "last_name": "Test", "password": "******",
                  "confirm_password": "******"}
     registration_form = UserRegistrationForm(test_user)
     adviser_user = AdviserUser.create_user(registration_form, AdviserInvitations.objects.get(id=1))
     self.assertEqual(adviser_user, AdviserUser.objects.get(id=adviser_user.id))
Esempio n. 2
0
    def post(self, request):
        """
        Handling GET method
        :param request: Request to View
        :return: HttpResponse with code 201 if user is created or
        HttpResponseBadRequest if request contain incorrect data
        """
        verification_code = request.GET.get("code", "")

        invitation = AdviserInvitations.get_invitation(verification_code)

        user_registration_form = UserRegistrationForm(json.loads(request.body))

        if not user_registration_form.is_valid():
            return HttpResponseBadRequest("Invalid input data. Please edit and try again.")

        AdviserUser.create_user(user_registration_form, invitation)

        invitation.close_invitation()

        return HttpResponse(status=201)
Esempio n. 3
0
    def post(self, request):
        """
        Handling GET method
        :param request: Request to View
        :return: HttpResponse with code 201 if user is created or
        HttpResponseBadRequest if request contain incorrect data
        """
        verification_code = request.GET.get("code", "")

        invitation = AdviserInvitations.get_invitation(verification_code)

        user_registration_form = UserRegistrationForm(json.loads(request.body))

        if not user_registration_form.is_valid():
            return HttpResponseBadRequest(
                "Invalid input data. Please edit and try again.")

        AdviserUser.create_user(user_registration_form, invitation)

        invitation.close_invitation()

        return HttpResponse(status=201)
Esempio n. 4
0
 def test_creating_adviser_user_on_invitation_and_form(self):
     """
     Ensure we can crate AdviserUser using AdviserInvitation and Form
     """
     test_user = {
         "first_name": "Test",
         "last_name": "Test",
         "password": "******",
         "confirm_password": "******"
     }
     registration_form = UserRegistrationForm(test_user)
     adviser_user = AdviserUser.create_user(
         registration_form, AdviserInvitations.objects.get(id=1))
     self.assertEqual(adviser_user,
                      AdviserUser.objects.get(id=adviser_user.id))