• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python forms.AppFormMedia类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mkt.developers.forms.AppFormMedia的典型用法代码示例。如果您正苦于以下问题:Python AppFormMedia类的具体用法?Python AppFormMedia怎么用?Python AppFormMedia使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AppFormMedia类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: details

def details(request, addon_id, addon):
    # Name, Slug, Summary, Description, Privacy Policy,
    # Homepage URL, Support URL, Support Email.
    form_basic = AppDetailsBasicForm(request.POST or None, instance=addon,
                                     request=request)
    form_cats = CategoryForm(request.POST or None, product=addon,
                             request=request)
    form_devices = DeviceTypeForm(request.POST or None, addon=addon)
    form_icon = AppFormMedia(request.POST or None, request.FILES or None,
                             instance=addon, request=request)
    form_previews = PreviewFormSet(request.POST or None, prefix='files',
                                   queryset=addon.get_previews())

    # For empty webapp-locale (or no-locale) fields that have
    # form-locale values, duplicate them to satisfy the requirement.
    form_locale = request.COOKIES.get("current_locale", "")
    app_locale = to_language(addon.default_locale)
    for name, value in request.POST.items():
        if value:
            if name.endswith(form_locale):
                basename = name[:-len(form_locale)]
            else:
                basename = name + '_'
            othername = basename + app_locale
            if not request.POST.get(othername, None):
                request.POST[othername] = value
    forms = {
        'form_basic': form_basic,
        'form_devices': form_devices,
        'form_cats': form_cats,
        'form_icon': form_icon,
        'form_previews': form_previews,
    }

    if request.POST and all(f.is_valid() for f in forms.itervalues()):
        addon = form_basic.save(addon)
        form_devices.save(addon)
        form_cats.save()
        form_icon.save(addon)
        for preview in form_previews.forms:
            preview.save(addon)

        tasks.generate_image_assets.delay(addon)

        checklist = AppSubmissionChecklist.objects.get(addon=addon)

        if waffle.switch_is_active('disabled-payments'):
            checklist.update(details=True, payments=True)
            addon.mark_done()
            return redirect('submit.app.done', addon.app_slug)
        else:
            checklist.update(details=True)
            return redirect('submit.app.payments', addon.app_slug)

    ctx = {
        'step': 'details',
        'addon': addon,
    }
    ctx.update(forms)
    return jingo.render(request, 'submit/details.html', ctx)
开发者ID:Sancus,项目名称:zamboni,代码行数:60,代码来源:views.py


示例2: details

def details(request, addon_id, addon):
    # Name, Slug, Description, Privacy Policy, Homepage URL, Support URL,
    # Support Email.
    form_basic = AppDetailsBasicForm(request.POST or None, instance=addon, request=request)
    form_cats = CategoryForm(request.POST or None, product=addon, request=request)
    form_icon = AppFormMedia(request.POST or None, request.FILES or None, instance=addon, request=request)
    form_previews = PreviewFormSet(request.POST or None, prefix="files", queryset=addon.get_previews())

    # For empty webapp-locale (or no-locale) fields that have
    # form-locale values, duplicate them to satisfy the requirement.
    form_locale = request.COOKIES.get("current_locale", "")
    app_locale = to_language(addon.default_locale)
    for name, value in request.POST.items():
        if value:
            if name.endswith(form_locale):
                basename = name[: -len(form_locale)]
            else:
                basename = name + "_"
            othername = basename + app_locale
            if not request.POST.get(othername, None):
                request.POST[othername] = value
    forms = {"form_basic": form_basic, "form_cats": form_cats, "form_icon": form_icon, "form_previews": form_previews}
    if request.POST and all(f.is_valid() for f in forms.itervalues()):
        addon = form_basic.save(addon)
        form_cats.save()
        form_icon.save(addon)
        for preview in form_previews.forms:
            preview.save(addon)
        # If this is an incomplete app from the legacy submission flow, it may
        # not have device types set yet - so assume it works everywhere.
        if not addon.device_types:
            for device in amo.DEVICE_TYPES:
                addon.addondevicetype_set.create(device_type=device)

        AppSubmissionChecklist.objects.get(addon=addon).update(details=True)

        if addon.needs_payment():
            # Paid apps get STATUS_NULL until payment information and content
            # ratings entered.
            addon.update(status=amo.STATUS_NULL, highest_status=amo.STATUS_PENDING)

        # Mark as pending in special regions (i.e., China).
        # By default, the column is set to pending when the row is inserted.
        # But we need to set a nomination date so we know to list the app
        # in the China Review Queue now (and sort it by that date too).
        for region in mkt.regions.SPECIAL_REGIONS:
            addon.geodata.set_nominated_date(region, save=True)
            log.info(u"[Webapp:%s] Setting nomination date to " u"now for region (%s)." % (addon, region.slug))

        record_action("app-submitted", request, {"app-id": addon.pk})

        return redirect("submit.app.done", addon.app_slug)

    ctx = {"step": "details", "addon": addon}
    ctx.update(forms)
    return render(request, "submit/details.html", ctx)
开发者ID:gurumukhi,项目名称:zamboni,代码行数:56,代码来源:views.py


示例3: icon

    def icon(self, request, *args, **kwargs):
        app = self.get_object()

        data_form = IconJSONForm(request.DATA)
        if not data_form.is_valid():
            return Response(data_form.errors, status=status.HTTP_400_BAD_REQUEST)

        form = AppFormMedia(data_form.cleaned_data, request=request)
        if not form.is_valid():
            return Response(data_form.errors, status=status.HTTP_400_BAD_REQUEST)

        form.save(app)
        return Response(status=status.HTTP_200_OK)
开发者ID:atiqueahmedziad,项目名称:zamboni,代码行数:13,代码来源:views.py


示例4: details

def details(request, addon_id, addon):
    # Name, Slug, Summary, Description, Privacy Policy,
    # Homepage URL, Support URL, Support Email.
    form_basic = AppDetailsBasicForm(request.POST or None, instance=addon,
                                     request=request)
    form_cats = CategoryFormSet(request.POST or None, addon=addon,
                                request=request)
    form_devices = DeviceTypeForm(request.POST or None, addon=addon)
    form_icon = AppFormMedia(request.POST or None, request.FILES or None,
                             instance=addon, request=request)
    form_previews = PreviewFormSet(request.POST or None, prefix='files',
                                   queryset=addon.previews.all())

    forms = {
        'form_basic': form_basic,
        'form_devices': form_devices,
        'form_cats': form_cats,
        'form_icon': form_icon,
        'form_previews': form_previews,
    }

    if request.POST and all(f.is_valid() for f in forms.itervalues()):
        addon = form_basic.save(addon)
        form_devices.save(addon)
        form_cats.save()
        form_icon.save(addon)
        for preview in form_previews.forms:
            preview.save(addon)
        AppSubmissionChecklist.objects.get(addon=addon).update(details=True)
        return redirect('submit.app.payments', addon.app_slug)

    ctx = {
        'step': 'details',
        'addon': addon,
    }
    ctx.update(forms)
    return jingo.render(request, 'submit/details.html', ctx)
开发者ID:beenishkhan,项目名称:zamboni,代码行数:37,代码来源:views.py


示例5: details

def details(request, addon_id, addon):
    # Name, Slug, Summary, Description, Privacy Policy,
    # Homepage URL, Support URL, Support Email.
    form_basic = AppDetailsBasicForm(request.POST or None, instance=addon,
                                     request=request)
    form_cats = CategoryForm(request.POST or None, product=addon,
                             request=request)
    form_icon = AppFormMedia(request.POST or None, request.FILES or None,
                             instance=addon, request=request)
    form_previews = PreviewFormSet(request.POST or None, prefix='files',
                                   queryset=addon.get_previews())

    # For empty webapp-locale (or no-locale) fields that have
    # form-locale values, duplicate them to satisfy the requirement.
    form_locale = request.COOKIES.get("current_locale", "")
    app_locale = to_language(addon.default_locale)
    for name, value in request.POST.items():
        if value:
            if name.endswith(form_locale):
                basename = name[:-len(form_locale)]
            else:
                basename = name + '_'
            othername = basename + app_locale
            if not request.POST.get(othername, None):
                request.POST[othername] = value
    forms = {
        'form_basic': form_basic,
        'form_cats': form_cats,
        'form_icon': form_icon,
        'form_previews': form_previews,
    }

    if request.POST and all(f.is_valid() for f in forms.itervalues()):
        addon = form_basic.save(addon)
        form_cats.save()
        form_icon.save(addon)
        for preview in form_previews.forms:
            preview.save(addon)

        # If this is an incomplete app from the legacy submission flow, it may
        # not have device types set yet - so assume it works everywhere.
        if not addon.device_types:
            for device in amo.DEVICE_TYPES:
                addon.addondevicetype_set.create(device_type=device)

        tasks.generate_image_assets.delay(addon)

        AppSubmissionChecklist.objects.get(addon=addon).update(details=True)

        make_public = (amo.PUBLIC_IMMEDIATELY
                       if form_basic.cleaned_data.get('publish')
                       else amo.PUBLIC_WAIT)

        # Free apps get pushed for review.
        if addon.premium_type == amo.ADDON_FREE:
            # The developer doesn't want the app published immediately upon
            # review.
            addon.update(status=amo.STATUS_PENDING,
                         make_public=make_public)
        else:
            # Paid apps get STATUS_NULL until payment information has been
            # entered.
            addon.update(status=amo.STATUS_NULL,
                         highest_status=amo.STATUS_PENDING,
                         make_public=make_public)

            # Mark the app as excluded in regions that don't support payments.
            for region in mkt.regions.ALL_REGIONS:
                if not region.has_payments:
                    AddonExcludedRegion.objects.get_or_create(
                        addon=addon, region=region.id)

        return redirect('submit.app.done', addon.app_slug)

    ctx = {
        'step': 'details',
        'addon': addon,
    }
    ctx.update(forms)
    return jingo.render(request, 'submit/details.html', ctx)
开发者ID:bearstech,项目名称:zamboni,代码行数:80,代码来源:views.py


示例6: details

def details(request, addon_id, addon):
    # Name, Slug, Description, Privacy Policy, Homepage URL, Support URL,
    # Support Email.
    form_basic = AppDetailsBasicForm(request.POST or None, instance=addon,
                                     request=request)
    form_cats = CategoryForm(request.POST or None, product=addon,
                             request=request)
    form_icon = AppFormMedia(request.POST or None, request.FILES or None,
                             instance=addon, request=request)
    form_previews = PreviewFormSet(request.POST or None, prefix='files',
                                   queryset=addon.get_previews())

    # For empty webapp-locale (or no-locale) fields that have
    # form-locale values, duplicate them to satisfy the requirement.
    form_locale = request.COOKIES.get('current_locale', '')
    app_locale = to_language(addon.default_locale)
    for name, value in request.POST.items():
        if value:
            if name.endswith(form_locale):
                basename = name[:-len(form_locale)]
            else:
                basename = name + '_'
            othername = basename + app_locale
            if not request.POST.get(othername, None):
                request.POST[othername] = value
    forms = {
        'form_basic': form_basic,
        'form_cats': form_cats,
        'form_icon': form_icon,
        'form_previews': form_previews,
    }

    if request.POST and all(f.is_valid() for f in forms.itervalues()):
        addon = form_basic.save(addon)
        form_cats.save()
        form_icon.save(addon)
        for preview in form_previews.forms:
            preview.save(addon)

        # If this is an incomplete app from the legacy submission flow, it may
        # not have device types set yet - so assume it works everywhere.
        if not addon.device_types:
            for device in amo.DEVICE_TYPES:
                addon.addondevicetype_set.create(device_type=device)

        AppSubmissionChecklist.objects.get(addon=addon).update(details=True)

        # `make_public` if the developer doesn't want the app published
        # immediately upon review.
        make_public = (amo.PUBLIC_IMMEDIATELY
                       if form_basic.cleaned_data.get('publish')
                       else amo.PUBLIC_WAIT)

        if addon.premium_type == amo.ADDON_FREE:
            if waffle.switch_is_active('iarc'):
                # Free apps get STATUS_NULL until content ratings has been
                # entered.
                # TODO: set to STATUS_PENDING once app gets an IARC rating.
                addon.update(make_public=make_public)
            else:
                addon.update(status=amo.STATUS_PENDING,
                             make_public=make_public)
        else:
            # Paid apps get STATUS_NULL until payment information and content
            # ratings has been entered.
            addon.update(status=amo.STATUS_NULL, make_public=make_public,
                         highest_status=amo.STATUS_PENDING)

        record_action('app-submitted', request, {'app-id': addon.pk})

        return redirect('submit.app.done', addon.app_slug)

    ctx = {
        'step': 'details',
        'addon': addon,
    }
    ctx.update(forms)
    return jingo.render(request, 'submit/details.html', ctx)
开发者ID:chusiang,项目名称:zamboni,代码行数:78,代码来源:views.py


示例7: details

def details(request, addon_id, addon):
    # Name, Slug, Description, Privacy Policy, Homepage URL, Support URL,
    # Support Email.
    form_basic = AppDetailsBasicForm(request.POST or None, instance=addon,
                                     request=request)
    form_cats = CategoryForm(request.POST or None, product=addon,
                             request=request)
    form_icon = AppFormMedia(request.POST or None, request.FILES or None,
                             instance=addon, request=request)
    form_previews = PreviewFormSet(request.POST or None, prefix='files',
                                   queryset=addon.get_previews())

    # For empty webapp-locale (or no-locale) fields that have
    # form-locale values, duplicate them to satisfy the requirement.
    form_locale = request.COOKIES.get('current_locale', '')
    app_locale = to_language(addon.default_locale)
    for name, value in request.POST.items():
        if value:
            if name.endswith(form_locale):
                basename = name[:-len(form_locale)]
            else:
                basename = name + '_'
            othername = basename + app_locale
            if not request.POST.get(othername, None):
                request.POST[othername] = value
    forms = {
        'form_basic': form_basic,
        'form_cats': form_cats,
        'form_icon': form_icon,
        'form_previews': form_previews,
    }
    if request.POST and all(f.is_valid() for f in forms.itervalues()):
        addon = form_basic.save(addon)
        form_cats.save()
        form_icon.save(addon)
        for preview in form_previews.forms:
            preview.save(addon)
        # If this is an incomplete app from the legacy submission flow, it may
        # not have device types set yet - so assume it works everywhere.
        if not addon.device_types:
            for device in mkt.DEVICE_TYPES:
                addon.addondevicetype_set.create(device_type=device)

        AppSubmissionChecklist.objects.get(addon=addon).update(details=True)

        if addon.needs_payment():
            # Paid apps get STATUS_NULL until payment information and content
            # ratings entered.
            addon.update(status=mkt.STATUS_NULL,
                         highest_status=mkt.STATUS_PENDING)

        record_action('app-submitted', request, {'app-id': addon.pk})

        return redirect('submit.app.done', addon.app_slug)

    ctx = {
        'step': 'details',
        'addon': addon,
    }
    ctx.update(forms)
    return render(request, 'submit/details.html', ctx)
开发者ID:digideskio,项目名称:zamboni,代码行数:61,代码来源:views.py


示例8: details

def details(request, addon_id, addon):
    # Name, Slug, Description, Privacy Policy, Homepage URL, Support URL,
    # Support Email.
    form_basic = AppDetailsBasicForm(request.POST or None, instance=addon,
                                     request=request)
    form_cats = CategoryForm(request.POST or None, product=addon,
                             request=request)
    form_icon = AppFormMedia(request.POST or None, request.FILES or None,
                             instance=addon, request=request)
    form_previews = PreviewFormSet(request.POST or None, prefix='files',
                                   queryset=addon.get_previews())

    # For empty webapp-locale (or no-locale) fields that have
    # form-locale values, duplicate them to satisfy the requirement.
    form_locale = request.COOKIES.get('current_locale', '')
    app_locale = to_language(addon.default_locale)
    for name, value in request.POST.items():
        if value:
            if name.endswith(form_locale):
                basename = name[:-len(form_locale)]
            else:
                basename = name + '_'
            othername = basename + app_locale
            if not request.POST.get(othername, None):
                request.POST[othername] = value
    forms = {
        'form_basic': form_basic,
        'form_cats': form_cats,
        'form_icon': form_icon,
        'form_previews': form_previews,
    }
    if request.POST and all(f.is_valid() for f in forms.itervalues()):
        addon = form_basic.save(addon)
        form_cats.save()
        form_icon.save(addon)
        for preview in form_previews.forms:
            preview.save(addon)
        # If this is an incomplete app from the legacy submission flow, it may
        # not have device types set yet - so assume it works everywhere.
        if not addon.device_types:
            for device in amo.DEVICE_TYPES:
                addon.addondevicetype_set.create(device_type=device)

        AppSubmissionChecklist.objects.get(addon=addon).update(details=True)

        # `publish_type` if the developer doesn't want the app published
        # immediately upon review.
        publish_type = (amo.PUBLISH_IMMEDIATE
                       if form_basic.cleaned_data.get('publish')
                       else amo.PUBLISH_PRIVATE)

        if addon.premium_type == amo.ADDON_FREE:
            if waffle.switch_is_active('iarc'):
                # Free apps get STATUS_NULL until content ratings has been
                # entered.
                # TODO: set to STATUS_PENDING once app gets an IARC rating.
                addon.update(publish_type=publish_type)
            else:
                addon.update(status=amo.STATUS_PENDING,
                             publish_type=publish_type)
        else:
            # Paid apps get STATUS_NULL until payment information and content
            # ratings has been entered.
            addon.update(status=amo.STATUS_NULL, publish_type=publish_type,
                         highest_status=amo.STATUS_PENDING)

        # Mark as pending in special regions (i.e., China).
        # By default, the column is set to pending when the row is inserted.
        # But we need to set a nomination date so we know to list the app
        # in the China Review Queue now (and sort it by that date too).
        for region in mkt.regions.SPECIAL_REGIONS:
            addon.geodata.set_nominated_date(region, save=True)
            log.info(u'[Webapp:%s] Setting nomination date to '
                     u'now for region (%s).' % (addon, region.slug))

        record_action('app-submitted', request, {'app-id': addon.pk})

        return redirect('submit.app.done', addon.app_slug)

    ctx = {
        'step': 'details',
        'addon': addon,
    }
    ctx.update(forms)
    return render(request, 'submit/details.html', ctx)
开发者ID:anushbmx,项目名称:zamboni,代码行数:85,代码来源:views.py



注:本文中的mkt.developers.forms.AppFormMedia类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python forms.CategoryForm类代码示例发布时间:2022-05-27
下一篇:
Python forms.APIConsumerForm类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap