Ejemplo n.º 1
0
class TestProfileImageResize(TestCase):
    def setUp(self):
        self.user = User(
            email="*****@*****.**",
            password="******"
        )
        self.user.save()
        self.profile = Profile(
            prefix="Mr",
            middle="Jim",
            suffix="Jr",
            first_name="Ben",
            last_name="Gilbertson",
            nick_name="Bengi",
            headline="Mr Bengil, Master of the Universe",
            dob=datetime.date(200, 1, 1),
            user=self.user,
            profile_image=create_image_file(),
            activation_key="ABCDEFGHIJK"
        )
        self.profile.save()

    # @unittest.skip("Takes too long, eats the CPU")
    def test_profile_valid(self):
        self.assertIsInstance(self.profile, Profile)
        self.assertTrue(self.profile.profile_image is not None)
        file_regex = re.compile(r'uploads/profile_img/test.*\.png')
        self.assertRegexpMatches(self.profile.profile_image.name, file_regex)
        # self.assertEqual(self.profile.profile_image.name, 'uploads/profile_img/test_*.png')

    # @unittest.skip("Takes Too Long, eats CPU")
    def test_profile_img_resize(self):
        path = settings.BASE_DIR + str(self.profile.profile_image.url)
        new_path = resize_image(path, 50, append_str="thumb")
        self.assertRegexpMatches(new_path, re.compile(r'.*thumb\.png'))
Ejemplo n.º 2
0
def createProfileSocial(request):

		person = Profile.objects.all().filter(user_id=request.user.id).exists()
		form = UserUpdateForm()
		if person == False:
			if request.method == 'POST':
				form = UserUpdateForm(request.POST)
				identification =  form['identification'].value()
				phone = form['phone'].value()
				userType = 'Externo'
				numAccount = form['numAccount'].value()	
				lastProfile = Profile.objects.all().filter().last()
				if lastProfile == None:
					object = Profile()
					newProfile = Profile(1, request.user.id,identification,userType,phone,numAccount)
					newProfile.save()
					messages.success(request,'Su perfil ha sido creado exitosamente!')
					return render(request, 'sales/viewsEvent.html')
				else:			
					object = Profile()
					idUser = lastProfile.id + 1
					newProfile = Profile(idUser, request.user.id,identification,userType,phone,numAccount)
					newProfile.save()
					messages.success(request,'Su perfil ha sido creado exitosamente!')
					return render(request, 'sales/viewsEvent.html')
			else:
				return render(request, 'users/createMyProfile.html',{'form': form})
		else:
				return render(request, 'sales/viewsEvent.html')
Ejemplo n.º 3
0
    def save(self):
        """Create user and profile."""
        data = self.cleaned_data
        data.pop('password_confirmation')

        user = User.objects.create_user(
            **data
        )  # **data sirve para enviar todos los atributos del diccionario
        profile = Profile(user=user, picture="users/pictures/perfil.png")
        profile.save()
Ejemplo n.º 4
0
 def setUp(self) -> None:
     self.user = User.objects.create_user(username="******",
                                          email="*****@*****.**",
                                          password="******")
     Profile(
         user=self.user,
         nationality="Dutch",
         terms_confirmed=True,
         subscribed_newsletter=False,
     ).save()
     self.client.login(username="******",
                       password="******")
Ejemplo n.º 5
0
 def setUp(self) -> None:
     self.service = Factory.get_newsletter_service(True)
     self.executor = Factory.get_executor()
     self.inst_email = "*****@*****.**"
     self.alt_email = "*****@*****.**"
     self.user = User.objects.create_user(
         username=self.inst_email,
         email=self.alt_email,
     )
     self.user.profile = Profile(user=self.user,
                                 nationality="Dutch",
                                 terms_confirmed=True,
                                 subscribed_newsletter=False)
Ejemplo n.º 6
0
 def setUp(self):
     self.user = User(
         email="*****@*****.**",
         password="******"
     )
     self.user.save()
     self.profile = Profile(
         prefix="Mr",
         middle="Jim",
         suffix="Jr",
         first_name="Ben",
         last_name="Gilbertson",
         nick_name="Bengi",
         headline="Mr Bengil, Master of the Universe",
         dob=datetime.date(200, 1, 1),
         user=self.user,
         profile_image=create_image_file(),
         activation_key="ABCDEFGHIJK"
     )
     self.profile.save()
Ejemplo n.º 7
0
 def create_new_profile(
     self,
     first_name="Tosti",
     last_name="Broodjes",
     username="******",
     email="*****@*****.**",
     password="******",
     nationality="Dutch",
     terms_confirmed=True,
     newsletter=False,
     gmm_invite=False,
     newsletter_recipient="TUE",
 ) -> Profile:
     user = User(username=username, email=email, password=password, first_name=first_name, last_name=last_name)
     return Profile(
         user=user,
         nationality=nationality,
         terms_confirmed=terms_confirmed,
         subscribed_newsletter=newsletter,
         subscribed_gmm_invite=gmm_invite,
         newsletter_recipient=newsletter_recipient,
     )