def upload_profile_image(self, files): """ POST only, validates email during registration """ up = UserProfile(photo=files['file'], id=self.user_id) up.save(update_fields=('photo',)) url = up.photo.url message = json.dumps(MessagesCreator.set_profile_image(url)) channel = RedisPrefix.generate_user(self.user_id) global_redis.sync_redis.publish(channel, message) return settings.VALIDATION_IS_OK
def upload_profile_image(request): """ POST only, validates email during registration """ up = UserProfile(photo=request.FILES['file'], id=request.user.id) up.save(update_fields=('photo', )) url = up.photo.url message = json.dumps(MessagesCreator.set_profile_image(url)) channel = RedisPrefix.generate_user(request.user.id) global_redis.sync_redis.publish(channel, message) return HttpResponse(settings.VALIDATION_IS_OK, content_type='text/plain')