示例#1
0
def verificationAppForSeller(*args, **kwargs):
    """
        The task will be done in at schedule time, such as: every four hours.
        After Seller creating app clicks verified, verified app owner ship on schedule plan
    """
    times = string.atoi(common.getSystemParam(key='verify_app_times', default=3))
    ownerShipScans = appModels.OwnerShip_Scan.objects.filter(times__lte=times)
    massEmailThread = email.MassEmailThread()
    for ownerShipScan in ownerShipScans:
        app = ownerShipScan.app
        result = common.getITunes(app.apple_id)
        if result is None:
            continue
        description = result.get('description', None)
        if app.verify_token in description:
            templates = notificationModels.NotificationTemplate.objects.filter(name='verified_app_success_inform_seller')
            if templates:
                subject = templates[0].subject.replace('{param1}', app.app_name)
                message = templates[0].template.replace('{param1}', app.publisher.username).replace('{param2}', app.app_name)
                massEmailThread.addEmailData(subject=subject, message=message, recipient_list=[app.publisher.email])
                ownerShipScan.delete()
                #Update app is_verified value
                app.is_verified = True
                app.save()
        else:
            ownerShipScan.times += 1
            ownerShipScan.save()
            templates = notificationModels.NotificationTemplate.objects.filter(name='verified_app_failed_inform_seller')
            if ownerShipScan.times == 3 and templates:
                subject = templates[0].subject.replace('{param1}', app.app_name)
                message = templates[0].template.replace('{param1}', app.publisher.username).replace('{param2}', app.app_name)
                massEmailThread.addEmailData(subject=subject, message=message, recipient_list=[app.publisher.email])
    massEmailThread.start()

    return None
示例#2
0
def verificationAppForSeller(*args, **kwargs):
    """
        The task will be done in at schedule time, such as: every four hours.
        After Seller creating app clicks verified, verified app owner ship on schedule plan
    """
    times = string.atoi(
        common.getSystemParam(key='verify_app_times', default=3))
    ownerShipScans = appModels.OwnerShip_Scan.objects.filter(times__lte=times)
    massEmailThread = email.MassEmailThread()
    for ownerShipScan in ownerShipScans:
        app = ownerShipScan.app
        result = common.getITunes(app.apple_id)
        if result is None:
            continue
        description = result.get('description', None)
        if app.verify_token in description:
            templates = notificationModels.NotificationTemplate.objects.filter(
                name='verified_app_success_inform_seller')
            if templates:
                subject = templates[0].subject.replace('{param1}',
                                                       app.app_name)
                message = templates[0].template.replace(
                    '{param1}',
                    app.publisher.username).replace('{param2}', app.app_name)
                massEmailThread.addEmailData(
                    subject=subject,
                    message=message,
                    recipient_list=[app.publisher.email])
                ownerShipScan.delete()
                #Update app is_verified value
                app.is_verified = True
                app.save()
        else:
            ownerShipScan.times += 1
            ownerShipScan.save()
            templates = notificationModels.NotificationTemplate.objects.filter(
                name='verified_app_failed_inform_seller')
            if ownerShipScan.times == 3 and templates:
                subject = templates[0].subject.replace('{param1}',
                                                       app.app_name)
                message = templates[0].template.replace(
                    '{param1}',
                    app.publisher.username).replace('{param2}', app.app_name)
                massEmailThread.addEmailData(
                    subject=subject,
                    message=message,
                    recipient_list=[app.publisher.email])
    massEmailThread.start()

    return None
示例#3
0
文件: views.py 项目: kahihia/appbid
def saveAppStoreLink(request, form, model, *args, **kwargs):
    """Save the first register page - AppleStore Link."""
    initParam = kwargs.get('initParam')
    # The app in status=3 can not be edit.
    if model and model.status == 3:
        return redirect(
            reverse(initParam.get('nextPage'), kwargs={'pk': model.id}))

    title = form.cleaned_data['title'].strip()
    app_store_link = form.cleaned_data['app_store_link'].strip()
    app_type = form.cleaned_data['app_type']
    if title == "" or app_store_link == "" or app_type == "":
        return None

    #Verify whether the draft app exist.
    if model:
        if appModels.App.objects.filter(
                publisher_id=request.user.id,
                status=1,
                app_store_link__iexact=app_store_link).exclude(
                    pk=model.id).count():
            initParam['error_msg'] = _(
                'App with link has existed in your draft apps.')
            return None
    elif appModels.App.objects.filter(
            publisher_id=request.user.id,
            status=1,
            app_store_link__iexact=app_store_link).count():
        initParam['error_msg'] = _(
            'App with link has existed in your draft apps.')
        return None

    try:
        pattern = re.compile(r'^https://itunes.apple.com/[\S+/]+id(\d+)')
        match = pattern.match(app_store_link)
        if match is None:
            raise
        result = common.getITunes(match.group(1))
        if result is None:
            raise
    except Exception, e:
        initParam['error_msg'] = _('App store link is not correct.')
        log.error(
            _('App store link %(param)s is not correct.') %
            {'param': app_store_link})
        log.error(e.message)
        return None
示例#4
0
def saveAppStoreLink(request, form, model, *args, **kwargs):
    """Save the first register page - AppleStore Link."""
    initParam = kwargs.get("initParam")
    # The app in status=3 can not be edit.
    if model and model.status == 3:
        return redirect(reverse(initParam.get("nextPage"), kwargs={"pk": model.id}))

    title = form.cleaned_data["title"].strip()
    app_store_link = form.cleaned_data["app_store_link"].strip()
    app_type = form.cleaned_data["app_type"]
    if title == "" or app_store_link == "" or app_type == "":
        return None

    # Verify whether the draft app exist.
    if model:
        if (
            appModels.App.objects.filter(publisher_id=request.user.id, status=1, app_store_link__iexact=app_store_link)
            .exclude(pk=model.id)
            .count()
        ):
            initParam["error_msg"] = _("App with link has existed in your draft apps.")
            return None
    elif appModels.App.objects.filter(
        publisher_id=request.user.id, status=1, app_store_link__iexact=app_store_link
    ).count():
        initParam["error_msg"] = _("App with link has existed in your draft apps.")
        return None

    try:
        pattern = re.compile(r"^https://itunes.apple.com/[\S+/]+id(\d+)")
        match = pattern.match(app_store_link)
        if match is None:
            raise
        result = common.getITunes(match.group(1))
        if result is None:
            raise
    except Exception, e:
        initParam["error_msg"] = _("App store link is not correct.")
        log.error(_("App store link %(param)s is not correct.") % {"param": app_store_link})
        log.error(e.message)
        return None