예제 #1
0
    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"
예제 #2
0
 def get(self, cid):
     url = Media.load_media_from_uuid(g.current_course.avatar, return_model=True).url
     return redirect(url)
예제 #3
0
 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)