Exemplo n.º 1
0
 def delete(self, id, **kwargs):
     comment = dbs.query(Comment).filter(Comment.id == id).first()
     if not comment:
         abort(404, message="(Code 066) Comment {} doesn't exist".format(id))
     if not (comment.author_id == kwargs["user"].id or kwargs["user"].administrator):
         abort(401, message="(Code 067) Unauthorized".format(id))
     dbs.delete(comment)
     dbs.commit()
     return {}, 204
Exemplo n.º 2
0
 def delete(self, id, **kwargs):
     if kwargs['protected_action_permission'] != 'delete':
         abort(401, message='(Code 025) Wrong permissions!')
     user = dbs.query(User).filter(User.id == id).first()
     if not user:
         abort(404, message="(Code 002) User {} doesn't exist".format(id))
     dbs.delete(user)
     dbs.commit()
     return {}, 204
Exemplo n.º 3
0
 def delete(self, id, **kwargs):
     crag = dbs.query(Crag).filter(Crag.id == id).first()
     if not crag:
         abort(404, message="(Code 035) Crag {} doesn't exist".format(id))
     if crag.confirmed and not (kwargs['user'].administrator or kwargs['user'].moderator):
         abort(401, message="(Code 046) Unauthorized!")
     if not crag.confirmed and not (kwargs['user'].id == crag.original_author_id or
                                        kwargs['user'].administrator or kwargs['user'].moderator):
         abort(401, message="(Code 047) Unauthorized!")
     dbs.delete(crag)
     dbs.commit()
     return {}, 204
Exemplo n.º 4
0
 def delete(self, id, **kwargs):
     boulder = dbs.query(Boulder).filter(Boulder.id == id).first()
     if not boulder:
         abort(404, message="(Code 033) Boulder {} doesn't exist".format(id))
     if boulder.confirmed and not (kwargs['user'].administrator or kwargs['user'].moderator):
         abort(401, message="(Code 052) Unauthorized!")
     if not boulder.confirmed and not (kwargs['user'].id == boulder.original_author_id or
                                           kwargs['user'].administrator or kwargs['user'].moderator):
         abort(401, message="(Code 053) Unauthorized!")
     dbs.delete(boulder)
     dbs.commit()
     return {}, 204
Exemplo n.º 5
0
 def delete(self, id, **kwargs):
     block = dbs.query(Block).filter(Block.id == id).first()
     if not block:
         abort(404, message="(Code 031) Block {} doesn't exist".format(id))
     if block.confirmed and not (kwargs['user'].administrator or kwargs['user'].moderator):
         abort(401, message="(Code 049) Unauthorized!")
     if not block.confirmed and not (kwargs['user'].id == block.original_author_id or
                                         kwargs['user'].administrator or kwargs['user'].moderator):
         abort(401, message="(Code 050) Unauthorized!")
     dbs.delete(block)
     dbs.commit()
     return {}, 204
Exemplo n.º 6
0
 def delete(self, id, **kwargs):
     area = dbs.query(Area).filter(Area.id == id).first()
     if not area:
         abort(404, message="(Code 029) Area {} doesn't exist".format(id))
     if area.confirmed and not (kwargs["user"].administrator or kwargs["user"].moderator):
         abort(401, message="(Code 043) Unauthorized!")
     if not area.confirmed and not (
         kwargs["user"].id == area.original_author_id or kwargs["user"].administrator or kwargs["user"].moderator
     ):
         abort(401, message="(Code 044) Unauthorized!")
     dbs.delete(area)
     dbs.commit()
     return {}, 204
Exemplo n.º 7
0
 def post(self, **kwargs):
     parsed_args = boulder_grading_parser.parse_args()
     former_grading = dbs.query(BoulderGrading).filter(BoulderGrading.user_id == kwargs['user'].id,
                                                       BoulderGrading.boulder_id == parsed_args[
                                                           'boulder_id']).first()
     if former_grading:
         dbs.delete(former_grading)
     boulder = dbs.query(Boulder).filter(Boulder.id == parsed_args['boulder_id']).first()
     if not boulder:
         abort(404, message="(Code 073) Boulder doesn't exist!")
     if not boulder.confirmed:
         abort(400, message="(Code 074) Cannot suggest a grade for an unconfirmed boulder!")
     if parsed_args['grade'] not in fb_scale + v_scale:
         abort(400, message="(Code 075) Field 'grade' has to be a valid Vermin or Fontainebleau grade!")
     grading = BoulderGrading(boulder_id=parsed_args['boulder_id'],
                              grade=parsed_args['grade'],
                              user_id=kwargs['user'].id)
     dbs.add(grading)
     dbs.commit()
     return None, 201