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
def global_settings(request): """Store global Marketplace-wide info. used in the header.""" account_links = [] tools_links = [] context = {} tools_title = _('Tools') if request.user.is_authenticated() and hasattr(request, 'amo_user'): amo_user = request.amo_user account_links = [] context['is_reviewer'] = acl.check_reviewer(request) if getattr(request, 'can_view_consumer', True): account_links = [ {'text': _('Account History'), 'href': reverse('account.purchases')}, {'text': _('Account Settings'), 'href': reverse('account.settings')}, ] account_links += [ {'text': _('Change Password'), 'href': 'https://browserid.org/signin'}, {'text': _('Log out'), 'href': reverse('users.logout')}, ] if '/developers/' not in request.path: if amo_user.is_app_developer: tools_links.append({'text': _('My Submissions'), 'href': reverse('mkt.developers.apps')}) else: tools_links.append({'text': _('Developers'), 'href': reverse('ecosystem.landing')}) if '/reviewers/' not in request.path and context['is_reviewer']: tools_links.append({'text': _('Reviewer Tools'), 'href': reverse('reviewers.home')}) if acl.action_allowed(request, 'Localizers', '%'): tools_links.append({'text': _('Localizer Tools'), 'href': '/localizers'}) if acl.action_allowed(request, 'AccountLookup', '%'): tools_links.append({'text': _('Lookup Tool'), 'href': reverse('lookup.home')}) if acl.action_allowed(request, 'Admin', '%'): tools_links.append({'text': _('Admin Tools'), 'href': reverse('zadmin.home')}) context['amo_user'] = amo_user else: context['amo_user'] = AnonymousUser() context.update(account_links=account_links, settings=settings, amo=amo, mkt=mkt, APP=amo.FIREFOX, tools_links=tools_links, tools_title=tools_title, ADMIN_MESSAGE=get_config('site_notice'), collect_timings_percent=get_collect_timings(), is_admin=acl.action_allowed(request, 'Addons', 'Edit')) return context
def global_settings(request): """Store global Marketplace-wide info. used in the header.""" account_links = [] tools_links = [] context = {} tools_title = _('Tools') if request.user.is_authenticated() and hasattr(request, 'amo_user'): amo_user = request.amo_user account_links = [ {'text': _('Change Password'), 'href': 'https://browserid.org/signin'}, {'text': _('Log out'), 'href': reverse('users.logout')}, ] if '/developers/' not in request.path: tools_links.append({'text': _('Developer Hub'), 'href': reverse('mkt.developers.index')}) if '/reviewers/' not in request.path and acl.check_reviewer(request): tools_links.append({'text': _('Reviewer Tools'), 'href': reverse('reviewers.home')}) if acl.action_allowed(request, 'Localizers', '%'): tools_links.append({'text': _('Localizer Tools'), 'href': '/localizers'}) if acl.action_allowed(request, 'Admin', '%'): tools_links.append({'text': _('Admin Tools'), 'href': reverse('zadmin.home')}) context['amo_user'] = amo_user else: context['amo_user'] = AnonymousUser() context.update(account_links=account_links, settings=settings, amo=amo, mkt=mkt, tools_links=tools_links, tools_title=tools_title, ADMIN_MESSAGE=get_config('site_notice'), collect_timings_percent=get_collect_timings(), is_admin=acl.action_allowed(request, 'Addons', 'Edit')) return context
def global_settings(request): """Store global Marketplace-wide info. used in the header.""" account_links = [] tools_links = [] context = {} tools_title = _('Tools') if request.user.is_authenticated() and hasattr(request, 'amo_user'): amo_user = request.amo_user account_links = [ {'text': _('Change Password'), 'href': 'https://browserid.org/'}, {'text': _('Log out'), 'href': reverse('users.logout')}, ] # Not right now. This leads to a rabbit hole of issues. See bug 729751 # or ask andym for more. # if acl.check_reviewer(request): # tools_links.append({'text': _('Editor Tools'), # 'href': reverse('editors.home')}) if acl.action_allowed(request, 'Localizers', '%'): tools_links.append({'text': _('Localizer Tools'), 'href': '/localizers'}) if acl.action_allowed(request, 'Admin', '%'): tools_links.append({'text': _('Admin Tools'), 'href': reverse('zadmin.home')}) context['amo_user'] = amo_user else: context['amo_user'] = AnonymousUser() context.update(account_links=account_links, settings=settings, amo=amo, mkt=mkt, tools_links=tools_links, tools_title=tools_title, ADMIN_MESSAGE=get_config('site_notice'), collect_timings_percent=get_collect_timings()) return context
def record(request): # The rate limiting is done up on the client, but if things go wrong # we can just turn the percentage down to zero. if get_collect_timings(): return django_statsd_record(request) return HttpResponseForbidden()
def record(request): # The rate limiting is done up on the client, but if things go wrong # we can just turn the percentage down to zero. if get_collect_timings(): return django_statsd_record(request) raise PermissionDenied
def global_settings(request): """Store global Marketplace-wide info. used in the header.""" account_links = [] tools_links = [] footer_links = [] context = {} tools_title = _('Tools') if request.user.is_authenticated() and getattr(request, 'amo_user', None): amo_user = request.amo_user 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': reverse('account.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 amo_user.is_app_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, 'Localizers', '%'): footer_links.append({ 'text': _('Localizer Tools'), 'href': 'https://addons.mozilla.org/localizers/' }) 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 context['amo_user'] = amo_user logged = True else: context['amo_user'] = AnonymousUser() logged = False DESKTOP = request.TABLET or not request.MOBILE context.update(account_links=account_links, settings=settings, amo=amo, mkt=mkt, APP=amo.FIREFOX, 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, 'Addons', 'Edit'), DESKTOP=DESKTOP, logged=logged) return context
def global_settings(request): """Store global Marketplace-wide info. used in the header.""" account_links = [] tools_links = [] context = {} tools_title = _('Tools') if request.user.is_authenticated() and hasattr(request, 'amo_user'): amo_user = request.amo_user account_links = [] context['is_reviewer'] = acl.check_reviewer(request) if getattr(request, 'can_view_consumer', True): account_links = [ # TODO: Coming soon with payments. # {'text': _('Account History'), # 'href': reverse('account.purchases')}, { 'text': _('Account Settings'), 'href': reverse('account.settings') }, ] account_links += [ { 'text': _('Change Password'), 'href': 'https://login.persona.org/signin' }, { 'text': _('Log out'), 'href': reverse('users.logout') }, ] if '/developers/' not in request.path: tools_links.append({ 'text': _('Developer Hub'), 'href': reverse('ecosystem.landing'), 'target': '_blank' }) if amo_user.is_app_developer: tools_links.append({ 'text': _('My Submissions'), 'href': reverse('mkt.developers.apps'), 'target': '_blank' }) if '/reviewers/' not in request.path and context['is_reviewer']: tools_links.append({ 'text': _('Reviewer Tools'), 'href': reverse('reviewers.home') }) if acl.action_allowed(request, 'Localizers', '%'): tools_links.append({ 'text': _('Localizer Tools'), 'href': '/localizers' }) if acl.action_allowed(request, 'AccountLookup', '%'): tools_links.append({ 'text': _('Lookup Tool'), 'href': reverse('lookup.home') }) if acl.action_allowed(request, 'Admin', '%'): tools_links.append({ 'text': _('Admin Tools'), 'href': reverse('zadmin.home') }) context['amo_user'] = amo_user else: context['amo_user'] = AnonymousUser() context.update(account_links=account_links, settings=settings, amo=amo, mkt=mkt, APP=amo.FIREFOX, tools_links=tools_links, tools_title=tools_title, ADMIN_MESSAGE=get_config('site_notice'), collect_timings_percent=get_collect_timings(), is_admin=acl.action_allowed(request, 'Addons', 'Edit')) return context
def global_settings(request): """Store global Marketplace-wide info. used in the header.""" account_links = [] tools_links = [] footer_links = [] context = {} tools_title = _('Tools') if request.user.is_authenticated() and hasattr(request, 'amo_user'): amo_user = request.amo_user 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': reverse('account.settings')}, {'text': _('Change Password'), 'href': 'https://login.persona.org/signin'}, {'text': _('Log out'), 'href': reverse('users.logout')}, ] if '/developers/' not in request.path: tools_links.append({'text': _('Developer Hub'), 'href': reverse('ecosystem.landing')}) if amo_user.is_app_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.home')}) if acl.action_allowed(request, 'Localizers', '%'): footer_links.append({'text': _('Localizer Tools'), 'href': '/localizers'}) 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 context['amo_user'] = amo_user else: context['amo_user'] = AnonymousUser() DESKTOP = request.TABLET or not request.MOBILE context.update(account_links=account_links, settings=settings, amo=amo, mkt=mkt, APP=amo.FIREFOX, 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, 'Addons', 'Edit'), DESKTOP=DESKTOP) return context