コード例 #1
0
def main():
    import sys
    app = QApplication(sys.argv)
    #QTextCodec.setCodecForTr(QTextCodec.codecForName("UTF-8"))
    #QTextCodec.setCodecForCStrings(QTextCodec.codecForName("UTF-8"))
    tmpads = []
    #tmpads.append(Advertisement("qq", "url", "ad1.png", "http://www.baidu.com"))
    #tmpads.append(Advertisement("wps", "pkg", "ad2.png", "wps"))
    #tmpads.append(Advertisement("qt", "pkg", "ad3.png", "qtcreator"))
    tmpads.append(
        Advertisement("pchomewallpaper", "url", "ad0.png", "adbground0.png",
                      "http://download.pchome.net/wallpaper/"))
    tmpads.append(
        Advertisement(
            "qq", "url", "ad1.png", "adbground1.png",
            "http://www.ubuntukylin.com/ukylin/forum.php?mod=viewthread&tid=7688&extra=page%3D1"
        ))
    tmpads.append(
        Advertisement("wps", "pkg", "ad2.png", "adbground2.png", "wps-office"))
    tmpads.append(
        Advertisement(
            "dota2", "url", "ad3.png", "adbground3.png",
            "http://www.ubuntukylin.com/ukylin/forum.php?mod=viewthread&tid=7687&extra=page%3D1"
        ))
    #tmpads.append(Advertisement("pps", "url", "ad4.png", "adbground4.png", "http://dl.pps.tv/pps_linux_download.html"))
    tmpads.append(
        Advertisement("pchomewallpaper", "url", "ad5.png", "adbground5.png",
                      "http://download.pchome.net/wallpaper/"))

    adw = ADWidget(tmpads)
    adw.show()

    sys.exit(app.exec_())
コード例 #2
0
def get():
    queryStringTaxId = request.args.get("taxId")
    queryStringCategory = request.args.get("category")
    title = request.args.get("title")
    tags = request.args.get("tags")
    price = request.args.get("price")
    creationDate = request.args.get("creationDate")

    taxId, errors = ApiValidators.validateTaxId(taxId=queryStringTaxId)

    if len(errors) > 0:
        return ApiResponses.badRequestMessage(errors)

    if queryStringTaxId:
        advertisement = Advertisement.queryByTaxId(taxId)
        return ApiResponses.successMessage(item=advertisement)

    if not title or not tags:
        return ApiResponses.badRequestMessage("Parâmetro querystring 'title' ou 'tags' está faltando.")

    if price and not isinstance(price, float):
        return ApiResponses.badRequestMessage("Campo 'price' inválido, ex: 103.5 deve ser do tipo inteiro.")

    if creationDate and not ApiValidators.isDateISO8601(creationDate):
        return ApiResponses.badRequestMessage("Parâmetro 'creationDate' incorreto, ex: '2016-11-14'.")

    return ApiResponses.badRequestMessage("Não foi possível fazer requisição")
コード例 #3
0
 def get_advertisements(self, bysignal=False):
     print("we need to get the advertisements")
     tmpads = []
     tmpads.append(Advertisement("wps-office", "pkg", "ad2.png", "adb2.png", "wps-office"))
     tmpads.append(Advertisement("netease-cloud-music", "pkg", "ad0.png", "adb0.png", "netease-cloud-music"))
     tmpads.append(Advertisement("teamviewer", "pkg", "ad1.png", "adb1.png", "teamviewer"))
     tmpads.append(Advertisement("wps-office", "pkg", "ad2.png", "adb2.png", "wps-office"))
     tmpads.append(Advertisement("redeclipse", "pkg", "ad3.png", "adb3.png", "redeclipse"))
     tmpads.append(Advertisement("eclipse", "pkg", "ad4.png", "adb4.png", "eclipse"))
コード例 #4
0
def post():

    title = request.json.get("title")
    category = request.json.get("category")
    description = request.json.get("description")
    price = request.json.get("price")
    tags = request.json.get("tags")
    phoneNumber = request.json.get("phoneNumber")

    tags, errors = ApiValidators.validateTags(tags)
    price, errors = ApiValidators.validatePrice(price)
    phoneNumber, errors =ApiValidators.validatePhone(phoneNumber)

    if len(errors) > 0:
        return ApiResponses.badRequestMessage(errors)

    whatsAppApi = "None"

    if phoneNumber:
        whatsAppApi = "https://wa.me/{}?text=Ol%C3%A1," \
                      "%20gostaria%20de%20saber%20mais%20sobre%20o%20portal%20ATNAP".format(phoneNumber)

    try:
        Advertisement.newItem(
            title=title,
            description=description,
            price=price,
            category=category,
            advertiserTaxId="06.990.590/0001-23",
            phoneNumber=phoneNumber,
            whatsAppApi=whatsAppApi,
            tags=tags,
        )
        return ApiResponses.successMessage(message="sucesso", item="Anúncio '{}' foi registrado".format(title))
    except Exception as error:
        return ApiResponses.badRequestMessage("Erro ao criar anúncio! {}".format(error))