Beispiel #1
0
 def put(self, id):
     args = self.parser.parse_args()
     shop = db.session.query(Shop).filter(Shop.id == id).first()
     if not (args['name'] and args['domain']):
         abort(400, message="name, domain and non-empty pricelists list are required.")
     if not domain_check(args['domain']):
         abort(400, message="domain should be a proper domain name.")
     shop.name = args['name']
     shop.domain = args['domain']
     db.session.add(shop)
     db.session.commit()
     return {'result': 'OK'}, 200
Beispiel #2
0
 def post(self):
     args = self.parser.parse_args()
     if not (args['name'] and args['domain'] and args['pricelists']):
         abort(400, message="name, domain and non-empty pricelists list are required.")
     if not domain_check(args['domain']):
         abort(400, message="domain should be a proper domain name.")
     shop = Shop(name=args['name'], domain=args['domain'])
     db.session.add(shop)
     db.session.commit()
     for pl in args['pricelists']:
         db.session.add(Pricelist(shop_id=shop.id, url=pl['url'], format=pl['format']))
         db.session.commit()
     return {'result': 'OK'}, 200