Пример #1
0
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
Пример #2
0
def _real_email_regexes():
    real_email_regexes = get_config('real_email_regex_whitelist')
    # We have a whitelist set in the config so use it.
    if real_email_regexes:
        regexes = []
        for regex in real_email_regexes.split(','):
            try:
                regexes.append(re.compile(regex.strip().lower()))
            except re.error:
                pass
        return regexes
    else:
        return []
Пример #3
0
def _real_email_regexes():
    real_email_regexes = get_config('real_email_regex_whitelist')
    # We have a whitelist set in the config so use it.
    if real_email_regexes:
        regexes = []
        for regex in real_email_regexes.split(','):
            try:
                regexes.append(re.compile(regex.strip().lower()))
            except re.error:
                pass
        return regexes
    else:
        return []
Пример #4
0
        notblacklisted_list = []
        for email in recipient_list:
            if email and email.lower() in settings.EMAIL_BLACKLIST:
                log.debug('Blacklisted email removed from list: %s' % email)
            else:
                notblacklisted_list.append(email)
        recipient_list = notblacklisted_list

    # We're going to call send_email twice, once for fake emails, the other real.
    if settings.SEND_REAL_EMAIL:
        # Send emails out to all recipients.
        fake_recipient_list = []
        real_recipient_list = recipient_list
    else:
        # SEND_REAL_EMAIL is False so need to split out the fake from real mails.
        real_email_cs_string = get_config('real_email_whitelist')
        if real_email_cs_string is not None:
            # We have a whitelist set in the config so use it.
            real_white_list = [x.strip() for x in real_email_cs_string.split(',')]
            fake_recipient_list = []
            real_recipient_list = []
            for email in recipient_list:
                if email and email.lower() in real_white_list:
                    log.debug('Real email encountered: %s - sending.' % email)
                    real_recipient_list.append(email)
                else:
                    fake_recipient_list.append(email)
        else:
            # No whitelist in the config so all emails are fake.
            fake_recipient_list = recipient_list
            real_recipient_list = []
Пример #5
0
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,
                   amo=amo,
                   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
Пример #6
0
        notblacklisted_list = []
        for email in recipient_list:
            if email and email.lower() in settings.EMAIL_BLACKLIST:
                log.debug('Blacklisted email removed from list: %s' % email)
            else:
                notblacklisted_list.append(email)
        recipient_list = notblacklisted_list

    # We're going to call send_email twice, once for fake emails, the other real.
    if settings.SEND_REAL_EMAIL:
        # Send emails out to all recipients.
        fake_recipient_list = []
        real_recipient_list = recipient_list
    else:
        # SEND_REAL_EMAIL is False so need to split out the fake from real mails.
        real_email_cs_string = get_config('real_email_whitelist')
        if real_email_cs_string is not None:
            # We have a whitelist set in the config so use it.
            real_white_list = [
                x.strip() for x in real_email_cs_string.split(',')
            ]
            fake_recipient_list = []
            real_recipient_list = []
            for email in recipient_list:
                if email and email.lower() in real_white_list:
                    log.debug('Real email encountered: %s - sending.' % email)
                    real_recipient_list.append(email)
                else:
                    fake_recipient_list.append(email)
        else:
            # No whitelist in the config so all emails are fake.