def motd(request): form = None if acl.action_allowed(request, 'AddonReviewerMOTD', 'Edit'): form = forms.MOTDForm( initial={'motd': get_config('editors_review_motd')}) data = context(form=form) return render(request, 'editors/motd.html', data)
def context(**kw): ctx = dict(motd=get_config('mkt_reviewers_motd'), queue_counts=queue_counts(), search_url=reverse('api_dispatch_list', kwargs={ 'api_name': 'apps', 'resource_name': 'search'})) ctx.update(kw) return ctx
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(): amo_user = request.amo_user profile = request.user is_reviewer = acl.check_reviewer(request) account_links.append({'text': _('My Profile'), 'href': profile.get_url_path()}) if not settings.APP_PREVIEW: account_links.append({ 'text': _('My Collections'), 'href': reverse('collections.user', args=[amo_user.username])}) account_links.append({ 'text': _('Log out'), 'href': remora_url('/users/logout?to=' + urlquote(request.path)), }) if request.amo_user.is_developer: tools_links.append({'text': _('Manage My Submissions'), 'href': reverse('devhub.addons')}) tools_links += [ {'text': _('Submit a New Add-on'), 'href': reverse('devhub.submit.1')}, {'text': _('Developer Hub'), 'href': reverse('devhub.index')}, ] 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['amo_user'] = request.amo_user else: context['amo_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'), 'collect_timings_percent': get_collect_timings(), 'is_reviewer': is_reviewer}) 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 context(**kw): statuses = dict((k, unicode(v)) for k, v in amo.STATUS_CHOICES.items()) ctx = dict(motd=get_config('mkt_reviewers_motd'), queue_counts=queue_counts(), search_url=reverse('api_dispatch_list', kwargs={ 'api_name': 'apps', 'resource_name': 'search'}), statuses=statuses) ctx.update(kw) return ctx
def test_perms_not_motd(self): # Any type of reviewer can see the MOTD. self.login_as_editor() req = self.client.get(self.url) eq_(req.status_code, 200) eq_(req.context['form'], None) # No redirect means it didn't save. eq_(self.client.post(self.url, dict(motd='motd')).status_code, 200) eq_(get_config(self.key), u'original value')
def global_settings(request): """ Storing standard AMO-wide information used in global headers, such as account links and settings. """ account_links = [] tools_links = [] context = {} if request.user.is_authenticated(): # TODO(jbalogh): reverse links amo_user = request.amo_user account_links.append({ 'text': _('View Profile'), 'href': request.user.get_profile().get_url_path(), }) account_links.append({'text': _('Edit Profile'), 'href': reverse('users.edit')}) if request.amo_user.is_developer: account_links.append({'text': _('My Add-ons'), 'href': '/developers/addons'}) account_links.append({ 'text': _('My Collections'), 'href': reverse('collections.user', args=[amo_user.username])}) if amo_user.favorite_addons: account_links.append( {'text': _('My Favorites'), 'href': reverse('collections.detail', args=[amo_user.username, 'favorites'])}) account_links.append({ 'text': _('Log out'), 'href': remora_url('/users/logout?to=' + urlquote(request.path)), }) tools_links.append({'text': _('Developer Hub'), 'href': '/developers'}) if acl.action_allowed(request, 'Editors', '%'): tools_links.append({'text': _('Editor Tools'), 'href': '/editors'}) 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'] = request.amo_user else: context['amo_user'] = AnonymousUser() context.update({'account_links': account_links, 'settings': settings, 'amo': amo, 'tools_links': tools_links, 'ADMIN_MESSAGE': get_config('site_notice')}) return context
def motd(request): form = None motd = get_config("mkt_reviewers_motd") if acl.action_allowed(request, "AppReviewerMOTD", "Edit"): form = MOTDForm(request.POST or None, initial={"motd": motd}) if form and request.method == "POST" and form.is_valid(): set_config(u"mkt_reviewers_motd", form.cleaned_data["motd"]) return redirect(reverse("reviewers.apps.motd")) data = context(form=form) return jingo.render(request, "reviewers/motd.html", data)
def motd(request): form = None motd = get_config('mkt_reviewers_motd') if acl.action_allowed(request, 'AppReviewerMOTD', 'Edit'): form = MOTDForm(request.POST or None, initial={'motd': motd}) if form and request.method == 'POST' and form.is_valid(): set_config(u'mkt_reviewers_motd', form.cleaned_data['motd']) return redirect(reverse('reviewers.apps.motd')) data = context(form=form) return jingo.render(request, 'reviewers/motd.html', data)
def check_jetpack_version(sender, **kw): import files.tasks from zadmin.models import get_config jetpack_version = get_config('jetpack_version') qs = File.objects.filter(version__addon=sender, jetpack_version__isnull=False) ids = [f.id for f in qs if version_int(f.jetpack_version) < version_int(jetpack_version)] if ids: files.tasks.start_upgrade.delay(jetpack_version, ids, priority='high')
def context(**kw): statuses = dict((k, unicode(v)) for k, v in amo.STATUS_CHOICES.items()) ctx = dict(motd=get_config('mkt_reviewers_motd'), queue_counts=queue_counts(), search_url=reverse('api_dispatch_list', kwargs={ 'api_name': 'apps', 'resource_name': 'search' }), statuses=statuses) ctx.update(kw) return ctx
def test_motd_change(self): # Only users in the MOTD group can POST. user = UserProfile.objects.get(email='*****@*****.**') self.grant_permission(user, 'AppReviewerMOTD:Edit') self.login_as_editor() # Get is a 200 with a form. req = self.client.get(self.url) eq_(req.status_code, 200) eq_(req.context['form'].initial['motd'], u'original value') # Empty post throws an error. req = self.client.post(self.url, dict(motd='')) eq_(req.status_code, 200) # Didn't redirect after save. eq_(pq(req.content)('#editor-motd .errorlist').text(), 'This field is required.') # A real post now. req = self.client.post(self.url, dict(motd='new motd')) self.assert3xx(req, self.url) eq_(get_config(self.key), u'new motd')
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 test_motd_change(self): # Only users in the MOTD group can POST. user = UserProfile.objects.get(email='*****@*****.**') group = Group.objects.create(name='App Reviewer MOTD', rules='AppReviewerMOTD:Edit') GroupUser.objects.create(user=user, group=group) self.login_as_editor() # Get is a 200 with a form. req = self.client.get(self.url) eq_(req.status_code, 200) eq_(req.context['form'].initial['motd'], u'original value') # Empty post throws an error. req = self.client.post(self.url, dict(motd='')) eq_(req.status_code, 200) # Didn't redirect after save. eq_( pq(req.content)('#editor-motd .errorlist').text(), 'This field is required.') # A real post now. req = self.client.post(self.url, dict(motd='new motd')) self.assertRedirects(req, self.url) eq_(get_config(self.key), u'new motd')
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 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): """ 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() and hasattr(request, 'amo_user'): amo_user = request.amo_user profile = request.user.get_profile() is_reviewer = acl.check_reviewer(request) account_links.append({'text': _('My Profile'), 'href': profile.get_url_path()}) if amo_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')}) if not settings.APP_PREVIEW: account_links.append({ 'text': _('My Collections'), 'href': reverse('collections.user', args=[amo_user.username])}) if amo_user.favorite_addons: account_links.append( {'text': _('My Favorites'), 'href': reverse('collections.detail', args=[amo_user.username, 'favorites'])}) account_links.append({ 'text': _('Log out'), 'href': remora_url('/users/logout?to=' + urlquote(request.path)), }) if request.amo_user.is_developer: tools_links.append({'text': _('Manage My Submissions'), 'href': reverse('devhub.addons')}) tools_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 is_reviewer: tools_links.append({'text': _('Editor Tools'), 'href': reverse('editors.home')}) if acl.action_allowed(request, 'L10nTools', 'View'): tools_links.append({'text': _('Localizer Tools'), 'href': '/localizers'}) if (acl.action_allowed(request, 'Admin', '%') or acl.action_allowed(request, 'AdminTools', 'View')): tools_links.append({'text': _('Admin Tools'), 'href': reverse('zadmin.home')}) context['amo_user'] = request.amo_user else: context['amo_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'), 'collect_timings_percent': get_collect_timings(), 'is_reviewer': is_reviewer}) return context
def context(**kw): ctx = dict(motd=get_config("mkt_reviewers_motd"), queue_counts=queue_counts()) ctx.update(kw) return ctx
def base_context(**kw): ctx = {'motd': get_config('editors_review_motd')} ctx.update(kw) return ctx
def process_request(self, request): # Get the value from Config if it exists request.ADMIN_MESSAGE = get_config('site_notice')
def motd(request): form = None if acl.action_allowed(request, "AddonReviewerMOTD", "Edit"): form = forms.MOTDForm(initial={"motd": get_config("editors_review_motd")}) data = context(request, form=form) return render(request, "editors/motd.html", data)
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': '/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 = (getattr(request, 'TABLET', None) or not getattr(request, 'MOBILE', None)) request.APP = getattr(request, 'APP', None) 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, 'Apps', 'Edit'), DESKTOP=DESKTOP, logged=logged) return context
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 = _("Developer") if request.user.is_authenticated(): # TODO(jbalogh): reverse links amo_user = request.amo_user account_links.append({"text": _("View Profile"), "href": request.user.get_profile().get_url_path()}) account_links.append({"text": _("Edit Profile"), "href": reverse("users.edit")}) account_links.append( {"text": _("My Collections"), "href": reverse("collections.user", args=[amo_user.username])} ) if amo_user.favorite_addons: account_links.append( { "text": _("My Favorites"), "href": reverse("collections.detail", args=[amo_user.username, "favorites"]), } ) account_links.append({"text": _("Log out"), "href": remora_url("/users/logout?to=" + urlquote(request.path))}) if request.amo_user.is_developer: tools_links.append({"text": _("Manage My Add-ons"), "href": reverse("devhub.addons")}) tools_links.append({"text": _("Submit a New Add-on"), "href": reverse("devhub.submit.1")}) tools_links.append({"text": _("Developer Hub"), "href": reverse("devhub.index")}) if acl.action_allowed(request, "Editors", "%"): tools_title = _("Tools") tools_links.append({"text": _("Editor Tools"), "href": reverse("editors.home")}) if acl.action_allowed(request, "Localizers", "%"): tools_title = _("Tools") tools_links.append({"text": _("Localizer Tools"), "href": "/localizers"}) if acl.action_allowed(request, "Admin", "%"): tools_title = _("Tools") tools_links.append({"text": _("Admin Tools"), "href": reverse("zadmin.home")}) context["amo_user"] = request.amo_user else: context["amo_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"), } ) 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 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 base_context(**kw): ctx = {"motd": get_config("editors_review_motd")} ctx.update(kw) return ctx
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(): amo_user = request.amo_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 amo_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=[amo_user.username])}) if amo_user.favorite_addons: account_links.append( {'text': _('My Favorites'), 'href': reverse('collections.detail', args=[amo_user.username, 'favorites'])}) account_links.append({ 'text': _('Log out'), 'href': reverse('users.logout') + '?to=' + urlquote(request.path), }) if request.amo_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, 'L10nTools', 'View'): tools_links.append({'text': _('Localizer Tools'), 'href': '/localizers'}) if (acl.action_allowed(request, 'Admin', '%') or acl.action_allowed(request, 'AdminTools', 'View')): tools_links.append({'text': _('Admin Tools'), 'href': reverse('zadmin.home')}) context['amo_user'] = request.amo_user else: context['amo_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'), 'collect_timings_percent': get_collect_timings(), 'is_reviewer': is_reviewer}) return context
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() and hasattr(request, "amo_user"): amo_user = request.amo_user profile = request.user.get_profile() is_reviewer = acl.check_reviewer(request) account_links.append({"text": _("My Profile"), "href": profile.get_url_path()}) if amo_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")}) if not settings.APP_PREVIEW: account_links.append( {"text": _("My Collections"), "href": reverse("collections.user", args=[amo_user.username])} ) if amo_user.favorite_addons: account_links.append( { "text": _("My Favorites"), "href": reverse("collections.detail", args=[amo_user.username, "favorites"]), } ) account_links.append({"text": _("Log out"), "href": remora_url("/users/logout?to=" + urlquote(request.path))}) if request.amo_user.is_developer: tools_links.append({"text": _("Manage My Submissions"), "href": reverse("devhub.addons")}) tools_links.append({"text": _("Submit a New Add-on"), "href": reverse("devhub.submit.1")}) if waffle.flag_is_active(request, "submit-personas"): # TODO(cvan)(fligtar): Do we want this here? tools_links.append({"text": _("Submit a New Theme"), "href": reverse("devhub.themes.submit")}) tools_links.append({"text": _("Developer Hub"), "href": reverse("devhub.index")}) if is_reviewer: tools_links.append({"text": _("Editor Tools"), "href": reverse("editors.home")}) if acl.action_allowed(request, "L10nTools", "View"): tools_links.append({"text": _("Localizer Tools"), "href": "/localizers"}) if acl.action_allowed(request, "Admin", "%") or acl.action_allowed(request, "AdminTools", "View"): tools_links.append({"text": _("Admin Tools"), "href": reverse("zadmin.home")}) context["amo_user"] = request.amo_user else: context["amo_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"), "collect_timings_percent": get_collect_timings(), "is_reviewer": is_reviewer, } ) return context
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") if request.user.is_authenticated() and hasattr(request, "amo_user"): amo_user = request.amo_user account_links.append({"text": _("My Profile"), "href": request.user.get_profile().get_url_path()}) account_links.append({"text": _("Account Settings"), "href": reverse("users.edit")}) if not settings.APP_PREVIEW: account_links.append( {"text": _("My Collections"), "href": reverse("collections.user", args=[amo_user.username])} ) if amo_user.favorite_addons: account_links.append( { "text": _("My Favorites"), "href": reverse("collections.detail", args=[amo_user.username, "favorites"]), } ) if waffle.switch_is_active("marketplace"): account_links.append({"text": _("My Purchases"), "href": reverse("users.purchases")}) if waffle.flag_is_active(request, "allow-pre-auth"): account_links.append({"text": loc("Payment Profile"), "href": reverse("users.payments")}) account_links.append({"text": _("Log out"), "href": remora_url("/users/logout?to=" + urlquote(request.path))}) if not settings.APP_PREVIEW: if request.amo_user.is_developer: tools_links.append({"text": _("Manage My Add-ons"), "href": reverse("devhub.addons")}) tools_links.append({"text": _("Submit a New Add-on"), "href": reverse("devhub.submit.1")}) if waffle.flag_is_active(request, "accept-webapps"): if settings.APP_PREVIEW or request.amo_user.is_developer: tools_links.append({"text": _("Manage My Apps"), "href": reverse("devhub.apps")}) tools_links.append({"text": _("Submit a New App"), "href": reverse("devhub.submit_apps.1")}) if waffle.flag_is_active(request, "submit-personas"): # TODO(cvan)(fligtar): Do we want this here? tools_links.append({"text": "Submit a New Persona", "href": reverse("devhub.personas.submit")}) if not settings.APP_PREVIEW: tools_links.append({"text": _("Developer Hub"), "href": reverse("devhub.index")}) if acl.action_allowed(request, "Editors", "%"): 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"] = request.amo_user else: context["amo_user"] = AnonymousUser() # The flag has to be enabled for everyone and then we'll use that # percentage in the pages. percent = 0 try: flag = waffle.models.Flag.objects.get(name="collect-timings") if flag.everyone and flag.percent: percent = float(flag.percent) / 100.0 except waffle.models.Flag.DoesNotExist: pass context.update( { "account_links": account_links, "settings": settings, "amo": amo, "tools_links": tools_links, "tools_title": tools_title, "ADMIN_MESSAGE": get_config("site_notice"), "collect_timings_percent": percent, } ) return context
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, "L10nTools", "View"): tools_links.append({"text": _("Localizer Tools"), "href": "/localizers"}) 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
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 = _('Developer') if request.user.is_authenticated() and hasattr(request, 'amo_user'): amo_user = request.amo_user account_links.append({ 'text': _('View Profile'), 'href': request.user.get_profile().get_url_path(), }) account_links.append({'text': _('Edit Profile'), 'href': reverse('users.edit')}) if waffle.switch_is_active('marketplace'): account_links.append({'text': _('My Purchases'), 'href': reverse('users.purchases')}) account_links.append({ 'text': _('My Collections'), 'href': reverse('collections.user', args=[amo_user.username])}) if amo_user.favorite_addons: account_links.append( {'text': _('My Favorites'), 'href': reverse('collections.detail', args=[amo_user.username, 'favorites'])}) account_links.append({ 'text': _('Log out'), 'href': remora_url('/users/logout?to=' + urlquote(request.path)), }) if request.amo_user.is_developer: tools_links.append({'text': _('Manage My Add-ons'), 'href': reverse('devhub.addons')}) tools_links.append({'text': _('Submit a New Add-on'), 'href': reverse('devhub.submit.1')}) tools_links.append({'text': _('Developer Hub'), 'href': reverse('devhub.index')}) if acl.action_allowed(request, 'Editors', '%'): tools_title = _('Tools') tools_links.append({'text': _('Editor Tools'), 'href': reverse('editors.home')}) if acl.action_allowed(request, 'Localizers', '%'): tools_title = _('Tools') tools_links.append({'text': _('Localizer Tools'), 'href': '/localizers'}) if acl.action_allowed(request, 'Admin', '%'): tools_title = _('Tools') tools_links.append({'text': _('Admin Tools'), 'href': reverse('zadmin.home')}) context['amo_user'] = request.amo_user else: context['amo_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')}) return context
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') if request.user.is_authenticated() and hasattr(request, 'amo_user'): amo_user = request.amo_user account_links.append({ 'text': _('My Profile'), 'href': request.user.get_profile().get_url_path(), }) account_links.append({'text': _('Account Settings'), 'href': reverse('users.edit')}) if not settings.APP_PREVIEW: account_links.append({ 'text': _('My Collections'), 'href': reverse('collections.user', args=[amo_user.username])}) if amo_user.favorite_addons: account_links.append( {'text': _('My Favorites'), 'href': reverse('collections.detail', args=[amo_user.username, 'favorites'])}) account_links.append({ 'text': _('Log out'), 'href': remora_url('/users/logout?to=' + urlquote(request.path)), }) if request.amo_user.is_developer: tools_links.append({'text': _('Manage My Add-ons'), 'href': reverse('devhub.addons')}) tools_links.append({'text': _('Submit a New Add-on'), 'href': reverse('devhub.submit.1')}) if waffle.flag_is_active(request, 'submit-personas'): # TODO(cvan)(fligtar): Do we want this here? tools_links.append({'text': _('Submit a New Theme'), 'href': reverse('devhub.themes.submit')}) tools_links.append({'text': _('Developer Hub'), 'href': reverse('devhub.index')}) if acl.check_reviewer(request): tools_links.append({'text': _('Editor Tools'), 'href': reverse('editors.home')}) if acl.action_allowed(request, 'L10nTools', 'View'): tools_links.append({'text': _('Localizer Tools'), 'href': '/localizers'}) if (acl.action_allowed(request, 'Admin', '%') or acl.action_allowed(request, 'AdminTools', 'View')): tools_links.append({'text': _('Admin Tools'), 'href': reverse('zadmin.home')}) context['amo_user'] = request.amo_user else: context['amo_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'), 'collect_timings_percent': get_collect_timings()}) return context
def context(**kw): ctx = dict(motd=get_config('editors_review_motd'), queue_counts=queue_counts()) ctx.update(kw) return ctx
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 = _('Developer') if request.user.is_authenticated(): # TODO(jbalogh): reverse links amo_user = request.amo_user account_links.append({ 'text': _('View Profile'), 'href': request.user.get_profile().get_url_path(), }) account_links.append({ 'text': _('Edit Profile'), 'href': reverse('users.edit') }) account_links.append({ 'text': _('My Collections'), 'href': reverse('collections.user', args=[amo_user.username]) }) if amo_user.favorite_addons: account_links.append({ 'text': _('My Favorites'), 'href': reverse('collections.detail', args=[amo_user.username, 'favorites']) }) account_links.append({ 'text': _('Log out'), 'href': remora_url('/users/logout?to=' + urlquote(request.path)), }) if request.amo_user.is_developer: tools_links.append({ 'text': _('Manage My Add-ons'), 'href': reverse('devhub.addons') }) tools_links.append({ 'text': _('Submit a New Add-on'), 'href': reverse('devhub.submit.1') }) tools_links.append({ 'text': _('Developer Hub'), 'href': reverse('devhub.index') }) if acl.action_allowed(request, 'Editors', '%'): tools_title = _('Tools') tools_links.append({ 'text': _('Editor Tools'), 'href': reverse('editors.home') }) if acl.action_allowed(request, 'Localizers', '%'): tools_title = _('Tools') tools_links.append({ 'text': _('Localizer Tools'), 'href': '/localizers' }) if acl.action_allowed(request, 'Admin', '%'): tools_title = _('Tools') tools_links.append({ 'text': _('Admin Tools'), 'href': reverse('zadmin.home') }) context['amo_user'] = request.amo_user else: context['amo_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') }) return context
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') if request.user.is_authenticated() and hasattr(request, 'amo_user'): amo_user = request.amo_user account_links.append({ 'text': _('My Profile'), 'href': request.user.get_profile().get_url_path(), }) account_links.append({ 'text': _('Account Settings'), 'href': reverse('users.edit') }) if not settings.APP_PREVIEW: account_links.append({ 'text': _('My Collections'), 'href': reverse('collections.user', args=[amo_user.username]) }) if amo_user.favorite_addons: account_links.append({ 'text': _('My Favorites'), 'href': reverse('collections.detail', args=[amo_user.username, 'favorites']) }) if waffle.switch_is_active('marketplace'): account_links.append({ 'text': _('My Purchases'), 'href': reverse('users.purchases') }) if waffle.flag_is_active(request, 'allow-pre-auth'): account_links.append({ 'text': loc('Payment Profile'), 'href': reverse('users.payments') }) account_links.append({ 'text': _('Log out'), 'href': remora_url('/users/logout?to=' + urlquote(request.path)), }) if not settings.APP_PREVIEW: if request.amo_user.is_developer: tools_links.append({ 'text': _('Manage My Add-ons'), 'href': reverse('devhub.addons') }) tools_links.append({ 'text': _('Submit a New Add-on'), 'href': reverse('devhub.submit.1') }) if waffle.flag_is_active(request, 'accept-webapps'): if settings.APP_PREVIEW or request.amo_user.is_developer: tools_links.append({ 'text': _('Manage My Apps'), 'href': reverse('devhub.apps') }) tools_links.append({ 'text': _('Submit a New App'), 'href': reverse('devhub.submit_apps.1') }) if waffle.flag_is_active(request, 'submit-personas'): # TODO(cvan)(fligtar): Do we want this here? tools_links.append({ 'text': 'Submit a New Persona', 'href': reverse('devhub.personas.submit') }) if not settings.APP_PREVIEW: tools_links.append({ 'text': _('Developer Hub'), 'href': reverse('devhub.index') }) if acl.action_allowed(request, 'Editors', '%'): 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'] = request.amo_user else: context['amo_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'), 'collect_timings_percent': get_collect_timings() }) return context