def delete_user_avatar(sender, **kwargs): obj = kwargs['instance'] path = get_upload_avatars() + u"/u%s/" % obj.user.pk try: files = os.listdir(path) for f in files: fullpath = os.path.join(path, f) if os.path.isfile(fullpath): os.remove(fullpath) except: pass
the number of days specified in the setting ``ACCOUNT_ACTIVATION_DAYS`` (which should be the number of days after signup during which a user is allowed to activate their account); if the result is less than or equal to the current date, the key has expired and this method returns ``True``. """ expiration_date = datetime.timedelta( days=settings.ACCOUNT_ACTIVATION_DAYS) return self.activation_key == self.ACTIVATED or \ (self.user.date_joined + expiration_date <= datetime.datetime.now()) activation_key_expired.boolean = True fs = FileSystemStorage(location=get_upload_avatars()) def get_avatar_filepath(instance, filename): s = os.path.splitext(filename) filename = u"%s%s" % (slugify(s[0]), s[1]) return os.path.join(u"avatars/u%s/%s" % (str(instance.user.pk), filename)) def delete_user_avatar(sender, **kwargs): obj = kwargs['instance'] path = get_upload_avatars() + u"/u%s/" % obj.user.pk try: files = os.listdir(path) for f in files: fullpath = os.path.join(path, f)
days after signup during which a user is allowed to activate their account); if the result is less than or equal to the current date, the key has expired and this method returns ``True``. """ expiration_date = datetime.timedelta( days=settings.ACCOUNT_ACTIVATION_DAYS) return self.activation_key == self.ACTIVATED or \ (self.user.date_joined + expiration_date <= datetime.datetime.now()) activation_key_expired.boolean = True fs = FileSystemStorage(location=get_upload_avatars()) def get_avatar_filepath(instance, filename): s = os.path.splitext(filename) filename = u"%s%s" % (slugify(s[0]), s[1]) return os.path.join(u"avatars/u%s/%s" % (str(instance.user.pk), filename)) def delete_user_avatar(sender, **kwargs): obj = kwargs['instance'] path = get_upload_avatars() + u"/u%s/" % obj.user.pk try: files = os.listdir(path) for f in files: fullpath = os.path.join(path, f)