def post(self, cid): if not g.current_user.is_teacher(g.current_course): return api_abort(403, "permission denied") old_media = Media.load_media_from_uuid(g.current_course.avatar, return_model=True) new_media = request.files.get("avatar") if new_media is None: return api_abort(400, "file missing") new_media_uuid = Media.save_media(new_media, "avatars/course", commit=False) old_media.delete() if old_media is not None else 1 g.current_course.avatar = new_media_uuid db.session.commit() return "OK"
def get(self, cid): url = Media.load_media_from_uuid(g.current_course.avatar, return_model=True).url return redirect(url)
def get(self, uid): print(g.current_user.avatar) url = Media.load_media_from_uuid(g.current_user.avatar, return_model=True).url return redirect(url)