Пример #1
0
 def delete(self, id):
     route = Route.get(id)
     if route:
         try:
             Route.delete(id)
             return jsonify({'success': u'删除成功'})
         except IntegrityError, e:
             response = jsonify({'error': u'存在引用的外鍵'})
             response.status_code = 422
Пример #2
0
 def delete(self, id):
     route = Route.get(id)
     if route:
         try:
             Route.delete(id)
             return jsonify({'success': u'删除成功'})
         except IntegrityError, e:
             response = jsonify({'error': u'存在引用的外鍵'})
             response.status_code = 422
Пример #3
0
    def put(self, id):
        district_id = request.json.get('district_id')
        route_name = request.json.get('route_name')
        route = Route.get(id)
        if not route:
            abort(404)
        route.district_id = district_id
        route.route_name = route_name

        db.session.add(route)
        db.session.commit()

        return route, 201
Пример #4
0
    def put(self, id):
        district_id = request.json.get('district_id')
        route_name = request.json.get('route_name')
        route = Route.get(id)
        if not route:
            abort(404)
        route.district_id = district_id
        route.route_name = route_name

        db.session.add(route)
        db.session.commit()

        return route, 201
Пример #5
0
    def delete(self, id):
        route = Route.get(id)

        if route:
            if route.buses:
                return jsonify({'resCode': '30', 'resMsg': 'theere is some buses index for it'})
            else:
                db.session.delete(route)
                db.session.commit()
                return jsonify({"resCode": '20', 'resMsg': 'delete success'})

        else:
            return jsonify({"resCode": '30', 'resMsg': 'route is not exit'})
Пример #6
0
 def get(self, id):
     route = Route.get(id)
     if not route:
         abort(404)
     return route
Пример #7
0
 def get(self, id):
     route = Route.get(id)
     if not route:
         abort(404)
     return route