示例#1
0
def app_summary(request, addon_id):
    app = get_object_or_404(Webapp.with_deleted, pk=addon_id)

    if 'prioritize' in request.POST and not app.priority_review:
        app.update(priority_review=True)
        msg = u'Priority Review Requested'
        # Create notes and log entries.
        create_comm_note(app, app.latest_version, request.user, msg,
                         note_type=comm.PRIORITY_REVIEW_REQUESTED)
        amo.log(amo.LOG.PRIORITY_REVIEW_REQUESTED, app, app.latest_version,
                created=datetime.now(), details={'comments': msg})

    authors = (app.authors.filter(addonuser__role__in=(amo.AUTHOR_ROLE_DEV,
                                                       amo.AUTHOR_ROLE_OWNER))
                          .order_by('display_name'))

    if app.premium and app.premium.price:
        price = app.premium.price
    else:
        price = None

    purchases, refunds = _app_purchases_and_refunds(app)
    provider_portals = get_payment_provider_portals(app=app)
    versions = None

    status_form = APIStatusForm(initial={
        'status': amo.STATUS_CHOICES_API[app.status]
    })
    version_status_forms = {}
    if app.is_packaged:
        versions = app.versions.all().order_by('-created')
        for v in versions:
            version_status_forms[v.pk] = APIFileStatusForm(initial={
                'status': amo.STATUS_CHOICES_API[v.all_files[0].status]
            })

    permissions = {}
    if app.latest_version:
        permissions = app.latest_version.manifest.get('permissions', {})

    return render(request, 'lookup/app_summary.html', {
        'abuse_reports': app.abuse_reports.count(), 'app': app,
        'authors': authors, 'downloads': _app_downloads(app),
        'purchases': purchases, 'refunds': refunds, 'price': price,
        'provider_portals': provider_portals,
        'status_form': status_form, 'versions': versions,
        'is_tarako': app.tags.filter(tag_text=QUEUE_TARAKO).exists(),
        'tarako_review':
            app.additionalreview_set.latest_for_queue(QUEUE_TARAKO),
        'version_status_forms': version_status_forms,
        'permissions': permissions,
    })
示例#2
0
文件: views.py 项目: waseem18/zamboni
def app_summary(request, addon_id):
    if unicode(addon_id).isdigit():
        query = {'pk': addon_id}
    else:
        query = {'app_slug': addon_id}
    app = get_object_or_404(Webapp.with_deleted, **query)

    if request.FILES:
        promo_img_form = PromoImgForm(request.POST, request.FILES)
    else:
        promo_img_form = PromoImgForm()
    if 'promo_img' in request.FILES and promo_img_form.is_valid():
        promo_img_form.save(app)
        messages.success(
            request, 'Promo image successfully uploaded.'
            ' You may have to refresh the page again to see it below.')
        return redirect(reverse('lookup.app_summary', args=[app.pk]))

    if 'prioritize' in request.POST and not app.priority_review:
        prioritize_app(app, request.user)

    authors = (app.authors.filter(addonuser__role__in=(mkt.AUTHOR_ROLE_DEV,
                                                       mkt.AUTHOR_ROLE_OWNER))
               .order_by('display_name'))

    if app.premium and app.premium.price:
        price = app.premium.price
    else:
        price = None

    purchases, refunds = _app_purchases_and_refunds(app)
    provider_portals = get_payment_provider_portals(app=app)
    versions = None

    status_form = APIStatusForm(initial={
        'status': mkt.STATUS_CHOICES_API[app.status]
    })
    version_status_forms = {}
    if app.is_packaged:
        versions = app.versions.all().order_by('-created')
        for v in versions:
            version_status_forms[v.pk] = APIFileStatusForm(initial={
                'status': mkt.STATUS_CHOICES_API[v.all_files[0].status]
            })

    permissions = {}
    if app.latest_version:
        permissions = app.latest_version.manifest.get('permissions', {})

    return render(request, 'lookup/app_summary.html', {
        'abuse_reports': app.abuse_reports.count(), 'app': app,
        'authors': authors, 'purchases': purchases, 'refunds': refunds,
        'price': price, 'provider_portals': provider_portals,
        'status_form': status_form, 'versions': versions,
        'is_tarako': app.tags.filter(tag_text=QUEUE_TARAKO).exists(),
        'tarako_review':
            app.additionalreview_set.latest_for_queue(QUEUE_TARAKO),
        'version_status_forms': version_status_forms,
        'permissions': permissions,
        'promo_img_form': promo_img_form,
    })