コード例 #1
0
 def delete_contract(self, request):
     try:
         if "id" in request.args:
             file_path = self.db.HashMap().get_file(request.args["id"][0])
             with open(file_path, "r") as filename:
                 contract = json.load(filename, object_pairs_hook=OrderedDict)
             c = Contract(self.db, contract=contract)
             if "keywords" in c.contract["vendor_offer"]["listing"]["item"]:
                 for keyword in c.contract["vendor_offer"]["listing"]["item"]["keywords"]:
                     self.kserver.delete(
                         keyword.lower(),
                         c.get_contract_id(),
                         self.keychain.signing_key.sign(c.get_contract_id())[:64],
                     )
             if "delete_images" in request.args:
                 c.delete(delete_images=True)
             else:
                 c.delete()
         request.write(json.dumps({"success": True}))
         request.finish()
         return server.NOT_DONE_YET
     except Exception, e:
         request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
         request.finish()
         return server.NOT_DONE_YET
コード例 #2
0
ファイル: restapi.py プロジェクト: the9ull/OpenBazaar-Server
 def delete_contract(self, request):
     if "id" in request.args:
         c = Contract(hash_value=unhexlify(request.args["id"][0]))
         for keyword in c.contract["vendor_offer"]["listing"]["item"]["keywords"]:
             self.kserver.delete(keyword.lower(), c.get_contract_id(),
                                 KeyChain().signing_key.sign(c.get_contract_id())[:64])
         c.delete()
コード例 #3
0
 def delete_contract(self, request):
     try:
         if "id" in request.args:
             file_path = self.db.HashMap().get_file(
                 unhexlify(request.args["id"][0]))
             with open(file_path, 'r') as filename:
                 contract = json.load(filename,
                                      object_pairs_hook=OrderedDict)
             c = Contract(self.db, contract=contract)
             if "keywords" in c.contract["vendor_offer"]["listing"]["item"]:
                 for keyword in c.contract["vendor_offer"]["listing"][
                         "item"]["keywords"]:
                     self.kserver.delete(
                         keyword.lower(), c.get_contract_id(),
                         self.keychain.signing_key.sign(
                             c.get_contract_id())[:64])
             if "delete_images" in request.args:
                 c.delete(delete_images=True)
             else:
                 c.delete()
         request.write(json.dumps({"success": True}))
         request.finish()
         return server.NOT_DONE_YET
     except Exception, e:
         request.write(
             json.dumps({
                 "success": False,
                 "reason": e.message
             }, indent=4))
         request.finish()
         return server.NOT_DONE_YET
コード例 #4
0
 def delete_contract(self, request):
     if "id" in request.args:
         c = Contract(hash_value=unhexlify(request.args["id"][0]))
         for keyword in c.contract["vendor_offer"]["listing"]["item"]["keywords"]:
             self.kserver.delete(keyword.lower(), c.get_contract_id(),
                                 KeyChain().signing_key.sign(c.get_contract_id())[:64])
         c.delete()
コード例 #5
0
 def set_contract(self, request):
     try:
         if "options" in request.args:
             options = {}
             for option in request.args["options"]:
                 options[option] = request.args[option]
         c = Contract(self.db)
         c.create(
             str(request.args["expiration_date"][0]),
             request.args["metadata_category"][0],
             request.args["title"][0],
             request.args["description"][0],
             request.args["currency_code"][0],
             request.args["price"][0],
             request.args["process_time"][0],
             str_to_bool(request.args["nsfw"][0]),
             shipping_origin=request.args["shipping_origin"][0] if "shipping_origin" in request.args else None,
             shipping_regions=request.args["ships_to"] if "ships_to" in request.args else None,
             est_delivery_domestic=request.args["est_delivery_domestic"][0]
             if "est_delivery_domestic" in request.args
             else None,
             est_delivery_international=request.args["est_delivery_international"][0]
             if "est_delivery_international" in request.args
             else None,
             terms_conditions=request.args["terms_conditions"][0]
             if request.args["terms_conditions"][0] is not ""
             else None,
             returns=request.args["returns"][0] if request.args["returns"][0] is not "" else None,
             shipping_currency_code=request.args["shipping_currency_code"][0],
             shipping_domestic=request.args["shipping_domestic"][0],
             shipping_international=request.args["shipping_international"][0],
             keywords=request.args["keywords"] if "keywords" in request.args else None,
             category=request.args["category"][0] if request.args["category"][0] is not "" else None,
             condition=request.args["condition"][0] if request.args["condition"][0] is not "" else None,
             sku=request.args["sku"][0] if request.args["sku"][0] is not "" else None,
             images=request.args["images"],
             free_shipping=str_to_bool(request.args["free_shipping"][0]),
             options=options if "options" in request.args else None,
             moderators=request.args["moderators"] if "moderators" in request.args else None,
         )
         for keyword in request.args["keywords"]:
             self.kserver.set(
                 digest(keyword.lower()), c.get_contract_id(), self.kserver.node.getProto().SerializeToString()
             )
         request.write(json.dumps({"success": True, "id": c.get_contract_id().encode("hex")}))
         request.finish()
         return server.NOT_DONE_YET
     except Exception, e:
         request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
         request.finish()
         return server.NOT_DONE_YET
コード例 #6
0
ファイル: restapi.py プロジェクト: jsindy/OpenBazaar-Server
 def delete_contract(self, request):
     try:
         if "id" in request.args:
             c = Contract(self.db, hash_value=unhexlify(request.args["id"][0]))
             for keyword in c.contract["vendor_offer"]["listing"]["item"]["keywords"]:
                 self.kserver.delete(keyword.lower(), c.get_contract_id(),
                                     self.keychain.signing_key.sign(c.get_contract_id())[:64])
             c.delete()
         request.write(json.dumps({"success": True}))
         request.finish()
         return server.NOT_DONE_YET
     except Exception, e:
         request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
         request.finish()
         return server.NOT_DONE_YET
コード例 #7
0
ファイル: restapi.py プロジェクト: the9ull/OpenBazaar-Server
    def set_contract(self, request):
        print request
        c = Contract()
        c.create(
            str(request.args["expiration_date"][0]),
            request.args["metadata_category"][0],
            request.args["title"][0],
            request.args["description"][0],
            request.args["currency_code"][0],
            request.args["price"][0],
            request.args["process_time"][0],
            True if "nsfw" in request.args else False,
            request.args["shipping_origin"][0],
            request.args["ships_to"],
            est_delivery_domestic=request.args["est_delivery_domestic"][0],
            est_delivery_international=request.args["est_delivery_international"][0],
            shipping_currency_code=request.args["shipping_currency_code"][0],
            shipping_domestic=request.args["shipping_domestic"][0],
            shipping_international=request.args["shipping_international"][0],
            keywords=request.args["keywords"] if "keywords" in request.args else None,
            category=request.args["category"][0] if request.args["category"][0] is not "" else None,
            condition=request.args["condition"][0] if request.args["condition"][0] is not "" else None,
            sku=request.args["sku"][0] if request.args["sku"][0] is not "" else None,
            images=request.args["images"],
            free_shipping=True if "free_shipping" in request.args else False)

        for keyword in request.args["keywords"]:
            self.kserver.set(keyword.lower(), c.get_contract_id(), self.kserver.node.getProto().SerializeToString())
コード例 #8
0
    def set_contract(self, request):
        print request
        c = Contract()
        c.create(
            str(request.args["expiration_date"][0]),
            request.args["metadata_category"][0],
            request.args["title"][0],
            request.args["description"][0],
            request.args["currency_code"][0],
            request.args["price"][0],
            request.args["process_time"][0],
            True if "nsfw" in request.args else False,
            request.args["shipping_origin"][0],
            request.args["ships_to"],
            est_delivery_domestic=request.args["est_delivery_domestic"][0],
            est_delivery_international=request.
            args["est_delivery_international"][0],
            shipping_currency_code=request.args["shipping_currency_code"][0],
            shipping_domestic=request.args["shipping_domestic"][0],
            shipping_international=request.args["shipping_international"][0],
            keywords=request.args["keywords"]
            if "keywords" in request.args else None,
            category=request.args["category"][0]
            if request.args["category"][0] is not "" else None,
            condition=request.args["condition"][0]
            if request.args["condition"][0] is not "" else None,
            sku=request.args["sku"][0]
            if request.args["sku"][0] is not "" else None,
            images=request.args["images"],
            free_shipping=True if "free_shipping" in request.args else False)

        for keyword in request.args["keywords"]:
            self.kserver.set(keyword.lower(), c.get_contract_id(),
                             self.kserver.node.getProto().SerializeToString())
コード例 #9
0
 def set_contract(self, request):
     try:
         if "options" in request.args:
             options = {}
             for option in request.args["options"]:
                 options[option] = request.args[option]
         c = Contract(self.db)
         c.create(
             str(request.args["expiration_date"][0]),
             request.args["metadata_category"][0],
             request.args["title"][0],
             request.args["description"][0],
             request.args["currency_code"][0],
             request.args["price"][0],
             request.args["process_time"][0],
             str_to_bool(request.args["nsfw"][0]),
             shipping_origin=request.args["shipping_origin"][0] if "shipping_origin" in request.args else None,
             shipping_regions=request.args["ships_to"] if "ships_to" in request.args else None,
             est_delivery_domestic=request.args["est_delivery_domestic"][0]
             if "est_delivery_domestic" in request.args else None,
             est_delivery_international=request.args["est_delivery_international"][0]
             if "est_delivery_international" in request.args else None,
             terms_conditions=request.args["terms_conditions"][0]
             if request.args["terms_conditions"][0] is not "" else None,
             returns=request.args["returns"][0] if request.args["returns"][0] is not "" else None,
             shipping_currency_code=request.args["shipping_currency_code"][0],
             shipping_domestic=request.args["shipping_domestic"][0],
             shipping_international=request.args["shipping_international"][0],
             keywords=request.args["keywords"] if "keywords" in request.args else None,
             category=request.args["category"][0] if request.args["category"][0] is not "" else None,
             condition=request.args["condition"][0] if request.args["condition"][0] is not "" else None,
             sku=request.args["sku"][0] if request.args["sku"][0] is not "" else None,
             images=request.args["images"],
             free_shipping=str_to_bool(request.args["free_shipping"][0]),
             options=options if "options" in request.args else None,
             moderators=request.args["moderators"] if "moderators" in request.args else None)
         for keyword in request.args["keywords"]:
             self.kserver.set(digest(keyword.lower()), c.get_contract_id(),
                              self.kserver.node.getProto().SerializeToString())
         request.write(json.dumps({"success": True, "id": c.get_contract_id().encode("hex")}))
         request.finish()
         return server.NOT_DONE_YET
     except Exception, e:
         request.write(json.dumps({"success": False, "reason": e.message}, indent=4))
         request.finish()
         return server.NOT_DONE_YET