comparison gpp/bio/models.py @ 560:4e891919c63f

Changed the avatar upload_to path to not rely on the user supplied name, as this has caused problems in the past (too long). Now just store avatars under media/avatars/users/username.ext.
author Brian Neal <bgneal@gmail.com>
date Thu, 02 Feb 2012 20:09:19 -0600
parents e0523e17ea43
children 98b373ca09f3
comparison
equal deleted inserted replaced
559:b9a41956be23 560:4e891919c63f
59 self.get_absolute_url(), self.name, self.name) 59 self.get_absolute_url(), self.name, self.name)
60 return u'' 60 return u''
61 html.allow_tags = True 61 html.allow_tags = True
62 62
63 63
64 def avatar_file_path_for_user(username, filename):
65 return os.path.join(settings.AVATAR_DIR, 'users', username, filename)
66
67 def avatar_file_path(instance, filename): 64 def avatar_file_path(instance, filename):
68 return avatar_file_path_for_user(instance.user.username, filename) 65 ext = os.path.splitext(filename)[1]
66 if not ext:
67 ext = '.jpg'
68 avatar_name = instance.user.username + ext
69 return os.path.join(settings.AVATAR_DIR, 'users', avatar_name)
69 70
70 71
71 class UserProfile(models.Model): 72 class UserProfile(models.Model):
72 """model to represent additional information about users""" 73 """model to represent additional information about users"""
73 74