def global_settings(request): """ Storing standard AMO-wide information used in global headers, such as account links and settings. """ account_links = [] tools_links = [] context = {} tools_title = ugettext('Tools') is_reviewer = False if request.user.is_authenticated(): user = request.user profile = request.user is_reviewer = (acl.check_addons_reviewer(request) or acl.check_personas_reviewer(request)) account_links.append({ 'text': ugettext('My Profile'), 'href': profile.get_url_path() }) if user.is_artist: account_links.append({ 'text': ugettext('My Themes'), 'href': profile.get_themes_url_path() }) account_links.append({ 'text': ugettext('Account Settings'), 'href': reverse('users.edit') }) account_links.append({ 'text': ugettext('My Collections'), 'href': reverse('collections.user', args=[user.username]) }) if user.favorite_addons: account_links.append({ 'text': ugettext('My Favorites'), 'href': reverse('collections.detail', args=[user.username, 'favorites']) }) account_links.append({ 'text': ugettext('Log out'), 'href': reverse('users.logout') + '?to=' + urlquote(request.path), }) if request.user.is_developer: tools_links.append({ 'text': ugettext('Manage My Submissions'), 'href': reverse('devhub.addons') }) links = [ { 'text': ugettext('Submit a New Add-on'), 'href': reverse('devhub.submit.agreement') }, { 'text': ugettext('Submit a New Theme'), 'href': reverse('devhub.themes.submit') }, { 'text': ugettext('Developer Hub'), 'href': reverse('devhub.index') }, ] links.append({ 'text': ugettext('Manage API Keys'), 'href': reverse('devhub.api_key') }) tools_links += links if is_reviewer: tools_links.append({ 'text': ugettext('Reviewer Tools'), 'href': reverse('reviewers.dashboard') }) if (acl.action_allowed(request, amo.permissions.ADMIN) or acl.action_allowed(request, amo.permissions.ADMIN_TOOLS_VIEW)): tools_links.append({ 'text': ugettext('Admin Tools'), 'href': reverse('zadmin.index') }) context['user'] = request.user else: context['user'] = AnonymousUser() context.update({ 'account_links': account_links, 'settings': settings, 'amo': amo, 'tools_links': tools_links, 'tools_title': tools_title, 'ADMIN_MESSAGE': get_config('site_notice'), 'is_reviewer': is_reviewer }) return context
def wrapper(request, *args, **kw): if _view_on_get(request) or acl.check_personas_reviewer(request): return f(request, *args, **kw) raise PermissionDenied
def global_settings(request): """ Storing standard AMO-wide information used in global headers, such as account links and settings. """ account_links = [] tools_links = [] context = {} tools_title = _('Tools') is_reviewer = False if request.user.is_authenticated(): user = request.user profile = request.user is_reviewer = (acl.check_addons_reviewer(request) or acl.check_personas_reviewer(request)) account_links.append({'text': _('My Profile'), 'href': profile.get_url_path()}) if user.is_artist: account_links.append({'text': _('My Themes'), 'href': profile.get_user_url('themes')}) account_links.append({'text': _('Account Settings'), 'href': reverse('users.edit')}) account_links.append({ 'text': _('My Collections'), 'href': reverse('collections.user', args=[user.username])}) if user.favorite_addons: account_links.append( {'text': _('My Favorites'), 'href': reverse('collections.detail', args=[user.username, 'favorites'])}) account_links.append({ 'text': _('Log out'), 'href': reverse('users.logout') + '?to=' + urlquote(request.path), }) if request.user.is_developer: tools_links.append({'text': _('Manage My Submissions'), 'href': reverse('devhub.addons')}) links = [ {'text': _('Submit a New Add-on'), 'href': reverse('devhub.submit.1')}, {'text': _('Submit a New Theme'), 'href': reverse('devhub.themes.submit')}, {'text': _('Developer Hub'), 'href': reverse('devhub.index')}, ] if waffle.switch_is_active('signing-api'): links.append({'text': _('Manage API Keys'), 'href': reverse('devhub.api_key')}) tools_links += links if is_reviewer: tools_links.append({'text': _('Editor Tools'), 'href': reverse('editors.home')}) if (acl.action_allowed(request, 'Admin', '%') or acl.action_allowed(request, 'AdminTools', 'View')): tools_links.append({'text': _('Admin Tools'), 'href': reverse('zadmin.home')}) context['user'] = request.user else: context['user'] = AnonymousUser() context.update({'account_links': account_links, 'settings': settings, 'amo': amo, 'tools_links': tools_links, 'tools_title': tools_title, 'ADMIN_MESSAGE': get_config('site_notice'), 'is_reviewer': is_reviewer}) return context