Beispiel #1
0
    def put(self, id):
        district = District.get(id)
        if not district:
            abort(400)

        district_name = request.json.get('district_name')
        district.update_distrct(district_name)
        db.session.add(district)
        db.session.commit()

        return district, 201
Beispiel #2
0
    def put(self, id):
        district = District.get(id)
        if not district:
            abort(400)

        district_name = request.json.get('district_name')
        district.update_distrct(district_name)
        db.session.add(district)
        db.session.commit()

        return district, 201
Beispiel #3
0
    def delete(self, id):
        district = District.get(id)
        if district:
            if district.routes:
                return jsonify({'resCode': '30', 'resMsg': 'theere is some routes index for it'})
            else:
                db.session.delete(district)
                db.session.commit()
                return District.get_district_list()

        else:
            return jsonify({"resCode": '30', 'resMsg': 'District is not exit'})
Beispiel #4
0
 def delete(self, id):
     district = District.get(id)
     if district:
         # if district.routes:
         #     res = jsonify({'error': 'theere is some routes index for it'})
         #     res.status_code = 422
         #     return res
         # else:
         #     db.session.delete(district)
         #     db.session.commit()
         #     return District.get_district_list()
         db.session.delete(district)
         db.session.commit()
     else:
         return jsonify({"resCode": '30', 'resMsg': 'District is not exit'})
Beispiel #5
0
 def delete(self, id):
     district = District.get(id)
     if district:
         # if district.routes:
         #     res = jsonify({'error': 'theere is some routes index for it'})
         #     res.status_code = 422
         #     return res
         # else:
         #     db.session.delete(district)
         #     db.session.commit()
         #     return District.get_district_list()
         db.session.delete(district)
         db.session.commit()
     else:
         return jsonify({"resCode": '30', 'resMsg': 'District is not exit'})