コード例 #1
0
    def forwards(self, orm):
        """Rename and randomize existing avatars."""
        for userprofile in orm["users.UserProfile"].objects.exclude(photo=""):
            new_filename = _calculate_photo_filename(None, None)
            new_full_path = os.path.join(settings.MEDIA_ROOT, new_filename)

            try:
                shutil.move(userprofile.photo.path, new_full_path)
            except IOError, exp:
                logger.error("Error renaming avatar for user '%s': %s" % (userprofile.user.username, exp))

            userprofile.photo.name = new_filename
            userprofile.save()
コード例 #2
0
    def forwards(self, orm):
        """Rename and randomize existing avatars."""
        for userprofile in orm['users.UserProfile'].objects.exclude(photo=''):
            new_filename = _calculate_photo_filename(None, None)
            new_full_path = os.path.join(settings.MEDIA_ROOT, new_filename)

            try:
                shutil.move(userprofile.photo.path, new_full_path)
            except IOError, exp:
                logger.error("Error renaming avatar for user '%s': %s" %
                             (userprofile.user.username, exp))

            userprofile.photo.name = new_filename
            userprofile.save()
コード例 #3
0
ファイル: test_models.py プロジェクト: royshouvik/mozillians
 def test_base(self, uuid4_mock):
     result = _calculate_photo_filename(None, '')
     ok_(result.endswith('.jpg'))
     ok_(result.startswith(settings.USER_AVATAR_DIR))
     ok_(uuid4_mock.called)
コード例 #4
0
 def test_base(self, uuid4_mock):
     result = _calculate_photo_filename(None, '')
     ok_(result.endswith('.jpg'))
     ok_(result.startswith(settings.USER_AVATAR_DIR))
     ok_(uuid4_mock.called)