当前位置: 首页>>代码示例>>Python>>正文


Python acl.action_allowed函数代码示例

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


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

示例1: is_admin

 def is_admin(self, user):
     """
     Returns a boolean indicating whether the passed user passes either
     OperatorDashboard:* or Feed:Curate.
     """
     return (acl.action_allowed(self.request, 'OperatorDashboard', '*') or
             acl.action_allowed(self.request, 'Feed', 'Curate'))
开发者ID:atiqueahmedziad,项目名称:zamboni,代码行数:7,代码来源:views.py

示例2: wrapper

 def wrapper(request, *args, **kw):
     from mkt.access import acl
     if (acl.action_allowed(request, '*', '*')
         or not acl.action_allowed(request, 'Restricted', 'UGC')):
         return f(request, *args, **kw)
     else:
         raise PermissionDenied
开发者ID:anushbmx,项目名称:zamboni,代码行数:7,代码来源:decorators.py

示例3: global_settings

def global_settings(request):
    """Store global Marketplace-wide info. used in the header."""
    account_links = []
    tools_links = []
    footer_links = []
    context = {}

    tools_title = _('Tools')

    context['user'] = request.user
    if request.user.is_authenticated():
        context['is_reviewer'] = acl.check_reviewer(request)
        account_links = [
            # TODO: Coming soon with payments.
            # {'text': _('Account History'),
            #  'href': reverse('account.purchases')},
            {'text': _('Account Settings'), 'href': '/settings'},
            {'text': _('Change Password'),
             'href': 'https://login.persona.org/signin'},
            {'text': _('Sign out'), 'href': reverse('users.logout')},
        ]
        if '/developers/' not in request.path:
            tools_links.append({'text': _('Developer Hub'),
                                'href': reverse('ecosystem.landing')})
            if request.user.is_developer:
                tools_links.append({'text': _('My Submissions'),
                                    'href': reverse('mkt.developers.apps')})
        if '/reviewers/' not in request.path and context['is_reviewer']:
            footer_links.append({
                'text': _('Reviewer Tools'),
                'href': reverse('reviewers.apps.queue_pending'),
            })
        if acl.action_allowed(request, 'AccountLookup', '%'):
            footer_links.append({'text': _('Lookup Tool'),
                                 'href': reverse('lookup.home')})
        if acl.action_allowed(request, 'Admin', '%'):
            footer_links.append({'text': _('Admin Tools'),
                                 'href': reverse('zadmin.home')})

        tools_links += footer_links
        logged = True
    else:
        logged = False

    DESKTOP = (getattr(request, 'TABLET', None) or
               not getattr(request, 'MOBILE', None))

    context.update(account_links=account_links,
                   settings=settings,
                   mkt=mkt,
                   tools_links=tools_links,
                   tools_title=tools_title,
                   footer_links=footer_links,
                   ADMIN_MESSAGE=get_config('site_notice'),
                   collect_timings_percent=get_collect_timings(),
                   is_admin=acl.action_allowed(request, 'Apps', 'Edit'),
                   DESKTOP=DESKTOP,
                   logged=logged)
    return context
开发者ID:Witia1,项目名称:zamboni,代码行数:59,代码来源:context_processors.py

示例4: is_admin

 def is_admin(self, user):
     """
     Returns a boolean indicating whether the passed user passes either
     OperatorDashboard:* or Feed:Curate.
     """
     return acl.action_allowed(self.request, "OperatorDashboard", "*") or acl.action_allowed(
         self.request, "Feed", "Curate"
     )
开发者ID:waseem18,项目名称:zamboni,代码行数:8,代码来源:views.py

示例5: wrapper

 def wrapper(request, *args, **kw):
     admin = (action_allowed(request, 'Admin', '%') or
              action_allowed(request, 'AdminTools', 'View'))
     if reviewers is True:
         admin = (
             admin or
             action_allowed(request, 'ReviewerAdminTools', 'View'))
     if admin:
         return f(request, *args, **kw)
     raise PermissionDenied
开发者ID:MorrisJobke,项目名称:zamboni,代码行数:10,代码来源:decorators.py

示例6: queue_tabnav

def queue_tabnav(context):
    """
    Returns tuple of tab navigation for the queue pages.

    Each tuple contains three elements: (url, tab_code, tab_text)

    """
    request = context['request']
    counts = context['queue_counts']
    apps_reviewing = AppsReviewing(request).get_apps()

    # Apps.
    if acl.action_allowed(request, 'Apps', 'Review'):
        rv = [
            (reverse('reviewers.apps.queue_pending'), 'pending',
             _('Apps ({0})', counts['pending']).format(counts['pending'])),

            (reverse('reviewers.apps.queue_rereview'), 'rereview',
             _('Re-reviews ({0})', counts['rereview']).format(
             counts['rereview'])),

            (reverse('reviewers.apps.queue_updates'), 'updates',
             _('Updates ({0})', counts['updates']).format(counts['updates'])),
        ]
        if acl.action_allowed(request, 'Apps', 'ReviewEscalated'):
            rv.append((reverse('reviewers.apps.queue_escalated'), 'escalated',
                       _('Escalations ({0})', counts['escalated']).format(
                       counts['escalated'])))
        rv.extend([
            (reverse('reviewers.apps.queue_moderated'), 'moderated',
             _('Moderated Reviews ({0})', counts['moderated'])
             .format(counts['moderated'])),

            (reverse('reviewers.apps.apps_reviewing'), 'reviewing',
             _('Reviewing ({0})').format(len(apps_reviewing))),
        ])
        if acl.action_allowed(request, 'Apps', 'ReviewRegionCN'):
            url_ = reverse('reviewers.apps.queue_region',
                           args=[mkt.regions.CN.slug])
            rv.append((url_, 'region',
                      _('China ({0})').format(counts['region_cn'])))
        if acl.action_allowed(request, 'Apps', 'ReviewTarako'):
            url_ = reverse('reviewers.apps.additional_review',
                           args=[QUEUE_TARAKO])
            rv.append((url_, 'additional',
                      _('Tarako ({0})').format(counts['additional_tarako'])))
    else:
        rv = []

    if 'pro' in request.GET:
        device_srch = device_queue_search(request)
        rv.append((reverse('reviewers.apps.queue_device'), 'device',
                  _('Device ({0})').format(device_srch.count()),))

    return rv
开发者ID:MaxMillion,项目名称:zamboni,代码行数:55,代码来源:helpers.py

示例7: wrapper

 def wrapper(request, *args, **kw):
     reviewer_perm = acl.check_reviewer(request)
     moderator_perm = (moderator and
                       acl.action_allowed(request,
                                          'Apps', 'ModerateReview'))
     view_only = (request.method == 'GET' and
                  acl.action_allowed(request, 'ReviewerTools', 'View'))
     if (reviewer_perm or moderator_perm or view_only):
         return f(request, *args, **kw)
     else:
         raise PermissionDenied
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:11,代码来源:views.py

示例8: app_header

def app_header(context, app, page_type=''):
    t = env.get_template('lookup/helpers/app_header.html')

    is_author = acl.check_ownership(context['request'], app)
    is_operator = any(g.name == 'Operators' for g in context['request'].groups)
    is_admin = acl.action_allowed(context['request'], 'Users', 'Edit')
    is_staff = acl.action_allowed(context['request'], 'Apps', 'Configure')
    is_reviewer = acl.check_reviewer(context['request'])
    return jinja2.Markup(t.render({'app': app, 'page_type': page_type,
                                   'is_admin': is_admin, 'is_staff': is_staff,
                                   'is_reviewer': is_reviewer,
                                   'is_author': is_author,
                                   'is_operator': is_operator}))
开发者ID:Witia1,项目名称:zamboni,代码行数:13,代码来源:helpers.py

示例9: logs_tabnav

def logs_tabnav(context):
    """
    Returns tuple of tab navigation for the log pages.

    Each tuple contains three elements: (named url, tab_code, tab_text)
    """
    request = context["request"]
    if acl.action_allowed(request, "Apps", "Review"):
        rv = [("reviewers.apps.logs", "logs", _("Reviews"))]
    else:
        rv = []
    if acl.action_allowed(request, "Apps", "ModerateReview"):
        rv.append(("reviewers.apps.moderatelog", "moderatelog", _("Moderated Reviews")))
    return rv
开发者ID:kolyaflash,项目名称:zamboni,代码行数:14,代码来源:helpers.py

示例10: logs_tabnav

def logs_tabnav(context):
    """
    Returns tuple of tab navigation for the log pages.

    Each tuple contains three elements: (named url, tab_code, tab_text)
    """
    request = context['request']
    if acl.action_allowed(request, 'Apps', 'Review'):
        rv = [('reviewers.apps.logs', 'logs', _('Reviews'))]
    else:
        rv = []
    if acl.action_allowed(request, 'Apps', 'ModerateReview'):
        rv.append(('reviewers.apps.moderatelog',
                   'moderatelog', _('Moderated Reviews')))
    return rv
开发者ID:psvramaraju,项目名称:zamboni,代码行数:15,代码来源:helpers.py

示例11: user_summary

def user_summary(request, user_id):
    user = get_object_or_404(UserProfile, pk=user_id)
    is_admin = acl.action_allowed(request, 'Users', 'Edit')
    app_summary = _app_summary(user.pk)
    # All refunds that this user has requested (probably as a consumer).
    req = Refund.objects.filter(contribution__user=user)
    # All instantly-approved refunds that this user has requested.
    appr = req.filter(status=amo.REFUND_APPROVED_INSTANT)
    refund_summary = {'approved': appr.count(),
                      'requested': req.count()}
    # TODO: This should return all `addon` types and not just webapps.
    # -- currently get_details_url() fails on non-webapps so this is a
    # temp fix.
    user_addons = (user.addons.filter(type=amo.ADDON_WEBAPP)
                              .order_by('-created'))
    user_addons = paginate(request, user_addons, per_page=15)

    payment_data = (AddonPaymentData.objects.filter(addon__authors=user)
                    .values(*AddonPaymentData.address_fields())
                    .distinct())

    # If the user is deleted, get the log detailing the delete.
    try:
        delete_log = ActivityLog.objects.for_user(user).filter(
            action=amo.LOG.DELETE_USER_LOOKUP.id)[0]
    except IndexError:
        delete_log = None

    provider_portals = get_payment_provider_portals(user=user)
    return render(request, 'lookup/user_summary.html',
                  {'account': user, 'app_summary': app_summary,
                   'delete_form': DeleteUserForm(), 'delete_log': delete_log,
                   'is_admin': is_admin, 'refund_summary': refund_summary,
                   'user_addons': user_addons, 'payment_data': payment_data,
                   'provider_portals': provider_portals})
开发者ID:kylewu,项目名称:zamboni,代码行数:35,代码来源:views.py

示例12: process_disable

    def process_disable(self):
        """
        Bans app from Marketplace, clears app from all queues.
        Changes status to Disabled.
        Creates Banned/Disabled note.
        """
        if not acl.action_allowed(self.request, 'Apps', 'Edit'):
            return

        # Disable disables all files, not just those in this version.
        self.set_files(mkt.STATUS_DISABLED,
                       File.objects.filter(version__addon=self.addon),
                       hide_disabled_file=True)
        self.addon.update(status=mkt.STATUS_DISABLED)
        if self.in_escalate:
            EscalationQueue.objects.filter(addon=self.addon).delete()
        if self.in_rereview:
            RereviewQueue.objects.filter(addon=self.addon).delete()

        if waffle.switch_is_active('iarc-upgrade-v2'):
            iarc_unpublish.delay(self.addon.pk)
        else:
            set_storefront_data.delay(self.addon.pk, disable=True)

        self.create_note(mkt.LOG.APP_DISABLED)
        log.info(u'App %s has been banned by a reviewer.' % self.addon)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:26,代码来源:utils.py

示例13: filter_queryset

    def filter_queryset(self, qs):
        """Filter GET requests with active=True, unless we have the permissions
        to do differently."""
        if self.request.method == "GET":
            active_parameter = self.request.GET.get("active")
            fxos_version_parameter = self.request.GET.get("fxos_version")

            if "pk" in self.kwargs:
                # No filtering at all if we're trying to see a detail page: the
                # permission_classes mechanism will handle the rest for us. It
                # reveals the existence of the langpack but that's OK.
                return qs

            # Handle 'active' filtering.
            if active_parameter in ("null", "false"):
                if action_allowed(self.request, "LangPacks", "%"):
                    # If active=null, we don't need to filter at all (we show
                    # all langpacks regardless of their 'active' flag value).
                    # If it's false, we only show inactive langpacks.
                    if active_parameter == "false":
                        qs = qs.filter(active=False)
                else:
                    # We don't have the permission, but the parameter to filter
                    # was passed, return a permission denied, someone is trying
                    # to see things he shouldn't be able to see.
                    self.permission_denied(self.request)
            else:
                qs = qs.filter(active=True)

            # Handle 'fxos_version' filtering if necessary.
            if fxos_version_parameter:
                qs = qs.filter(fxos_version=fxos_version_parameter)
        return qs
开发者ID:jobava-mozilla,项目名称:zamboni,代码行数:33,代码来源:views.py

示例14: save

    def save(self, addon, commit=False):
        # We ignore `commit`, since we need it to be `False` so we can save
        # the ManyToMany fields on our own.
        addonform = super(AppFormBasic, self).save(commit=False)
        addonform.save()

        if 'manifest_url' in self.changed_data:
            before_url = self.old_manifest_url
            after_url = self.cleaned_data['manifest_url']

            # If a non-admin edited the manifest URL, add to Re-review Queue.
            if not acl.action_allowed(self.request, 'Admin', '%'):
                log.info(u'[Webapp:%s] (Re-review) Manifest URL changed '
                         u'from %s to %s'
                         % (self.instance, before_url, after_url))

                msg = (_(u'Manifest URL changed from {before_url} to '
                         u'{after_url}')
                       .format(before_url=before_url, after_url=after_url))

                RereviewQueue.flag(self.instance,
                                   amo.LOG.REREVIEW_MANIFEST_URL_CHANGE, msg)

            # Refetch the new manifest.
            log.info('Manifest %s refreshed for %s'
                     % (addon.manifest_url, addon))
            update_manifests.delay([self.instance.id])

        return addonform
开发者ID:kylewu,项目名称:zamboni,代码行数:29,代码来源:forms.py

示例15: user_summary

def user_summary(request, user_id):
    user = get_object_or_404(UserProfile, pk=user_id)
    is_admin = acl.action_allowed(request, 'Users', 'Edit')
    app_summary = _app_summary(user.pk)
    # All refunds that this user has requested (probably as a consumer).
    req = Refund.objects.filter(contribution__user=user)
    # All instantly-approved refunds that this user has requested.
    appr = req.filter(status=mkt.REFUND_APPROVED_INSTANT)
    refund_summary = {'approved': appr.count(),
                      'requested': req.count()}
    user_addons = user.addons.order_by('-created')
    user_addons = paginate(request, user_addons, per_page=15)

    payment_data = (AddonPaymentData.objects.filter(addon__authors=user)
                    .values(*AddonPaymentData.address_fields())
                    .distinct())

    # If the user is deleted, get the log detailing the delete.
    try:
        delete_log = ActivityLog.objects.for_user(user).filter(
            action=mkt.LOG.DELETE_USER_LOOKUP.id)[0]
    except IndexError:
        delete_log = None

    group_membership_formset = APIGroupMembershipFormSet()

    provider_portals = get_payment_provider_portals(user=user)
    return render(request, 'lookup/user_summary.html',
                  {'account': user, 'app_summary': app_summary,
                   'delete_form': DeleteUserForm(), 'delete_log': delete_log,
                   'is_admin': is_admin, 'refund_summary': refund_summary,
                   'user_addons': user_addons, 'payment_data': payment_data,
                   'provider_portals': provider_portals,
                   'group_membership_formset': group_membership_formset})
开发者ID:waseem18,项目名称:zamboni,代码行数:34,代码来源:views.py


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