Beispiel #1
0
    def delete(self, anek_id):
        anek = models.Anek.query.filter_by(id=anek_id).first_or_404()

        db.session.delete(anek)
        db.session.commit()

        return anek_schema.jsonify(anek)
Beispiel #2
0
    def post(self):
        if request.json is None:
            abort(400)

        anek = anek_schema.load(request.json, session=db.session)

        db.session.add(anek)
        db.session.commit()

        return anek_schema.jsonify(anek)
Beispiel #3
0
    def put(self, anek_id):
        if request.json is None:
            abort(400)

        anek_from_db = models.Anek.query.filter_by(id=anek_id).first_or_404()
        anek = anek_schema.load(request.json,
                                session=db.session,
                                instance=anek_from_db,
                                partial=True)

        db.session.commit()

        return anek_schema.jsonify(anek)
Beispiel #4
0
 def get(self):
     anek = models.Anek.query.order_by(func.random()).first_or_404()
     return anek_schema.jsonify(anek)
Beispiel #5
0
 def get(self, anek_id):
     anek = models.Anek.query.filter_by(id=anek_id).first_or_404()
     return anek_schema.jsonify(anek)