Esempio n. 1
0
 def create_dummy_profile(self, user, id=None, flat=None, picture=None,
                          picture_path=None,
                          is_recognized=None):
     if picture_path and not picture:
         # створимо picture з файла на диску:
         with open(picture_path, 'rb') as file:
             picture = SimpleUploadedFile(picture_path, file.read())
     profile = UserProfile(user=user, id=id, flat=flat, picture=picture,
                           is_recognized=is_recognized)
     profile.save()
     trace_print('created profile:', profile, 'for user:', user)
     return profile
Esempio n. 2
0
 def create_dummy_profile(self,
                          user,
                          id=None,
                          flat=None,
                          picture=None,
                          picture_path=None,
                          is_recognized=None):
     if picture_path and not picture:
         # створимо picture з файла на диску:
         with open(picture_path, 'rb') as file:
             picture = SimpleUploadedFile(picture_path, file.read())
     profile = UserProfile(user=user,
                           id=id,
                           flat=flat,
                           picture=picture,
                           is_recognized=is_recognized)
     profile.save()
     trace_print('created profile:', profile, 'for user:', user)
     return profile
Esempio n. 3
0
 def processing(self, user, profile, msg):
     # Умови при яких зміни не відбудуться:
     if profile and profile.is_recognized == True:
         msg.title = user.username
         msg.type = msgType.NoChange
         msg.message = "Акаунт раніше вже був підтверджений!"
     else:
         # Робимо зміни:
         if not profile:
             profile = UserProfile(user=user)
         profile.is_recognized = True
         profile.save()
         user.userprofile = profile
         msg.title = user.username
         msg.type = msgType.Change
         msg.message = "Акаунт підтверджено!"
         e_msg_body = "Ваш акаунт на сайті підтверджено!"
         self.send_e_mail(user, e_msg_body)
     return user, msg
Esempio n. 4
0
 def processing(self, user, profile, msg):
     # Умови при яких зміни не відбудуться:
     if profile and profile.is_recognized == True:
         msg.title   = user.username
         msg.type    = msgType.NoChange
         msg.message = "Акаунт раніше вже був підтверджений!"
     else:
         # Робимо зміни:
         if not profile:
             profile = UserProfile(user=user)
         profile.is_recognized = True
         profile.save()
         user.userprofile = profile
         msg.title   = user.username
         msg.type    = msgType.Change
         msg.message = "Акаунт підтверджено!"
         e_msg_body = "Ваш акаунт на сайті підтверджено!"
         self.send_e_mail(user, e_msg_body)
     return user, msg
Esempio n. 5
0
 def processing(self, user, profile, msg):
     # Умови при яких зміни не відбудуться:
     if profile and profile.is_recognized == False:
         msg.title = user.username
         msg.type = msgType.NoChange
         msg.message = "Акаунт раніше вже був відхилений!"
     else:
         # Робимо зміни:
         if not profile:
             profile = UserProfile(user=user)
         profile.is_recognized = False
         profile.save()
         user.userprofile = profile
         user.is_active = False
         user.save()
         msg.title = user.username
         msg.type = msgType.Change
         msg.message = "Акаунт відхилено і деактивовано!"
         e_msg_body = "Ваш акаунт на сайті відхилено і деактивовано."
         self.send_e_mail(user, e_msg_body)
     return user, msg
Esempio n. 6
0
 def processing(self, user, profile, msg):
     # Умови при яких зміни не відбудуться:
     if profile and profile.is_recognized == False:
         msg.title   = user.username
         msg.type    = msgType.NoChange
         msg.message = "Акаунт раніше вже був відхилений!"
     else:
         # Робимо зміни:
         if not profile:
             profile = UserProfile(user=user)
         profile.is_recognized = False
         profile.save()
         user.userprofile = profile
         user.is_active = False
         user.save()
         msg.title   = user.username
         msg.type    = msgType.Change
         msg.message = "Акаунт відхилено і деактивовано!"
         e_msg_body = "Ваш акаунт на сайті відхилено і деактивовано."
         self.send_e_mail(user, e_msg_body)
     return user, msg
Esempio n. 7
0
 def test_empty_user_gives_error(self):
     p = UserProfile()
     with self.assertRaises(IntegrityError):
         p.save()
 def test_empty_user_gives_error(self):
     p = UserProfile()
     with self.assertRaises(IntegrityError):
         p.save()