def _get_activities(request, action): url = request.get_full_path() choices = (None, 'updates', 'status', 'collections', 'reviews') text = {None: _('All Activity'), 'updates': _('Add-on Updates'), 'status': _('Add-on Status'), 'collections': _('User Collections'), 'reviews': _('User Reviews'), } items = [] for c in choices: i = MenuItem() i.text = text[c] i.url, i.selected = urlparams(url, page=None, action=c), (action == c) items.append(i) return items
def _get_versions(request, versions, version): compats = [] url = request.get_full_path() c = MenuItem() (c.text, c.url) = (_('All Versions'), urlparams(url, lver=None, page=None)) if not version or version == 'any': c.selected = True compats.append(c) seen = {} exclude = request.APP.__dict__.get('exclude_versions', []) versions.sort(reverse=True) for v in versions: # v is a version_int so we can get the major and minor: v = dict_from_int(v) if v['minor1'] == 99: text = '%s.*' % v['major'] v_float = float('%s.99' % v['major']) else: text = '%s.%s' % (v['major'], v['minor1']) v_float = float(text) if seen.get(text): continue seen[text] = 1 if v_float < request.APP.min_display_version or v_float in exclude: continue c = MenuItem() c.text = text c.url = urlparams(url, lver=c.text, page=None) if c.text == version: c.selected = True compats.append(c) return compats
def _get_addons(request, addons, addon_id): """Create a list of ``MenuItem``s for the activity feed.""" items = [] a = MenuItem() a.selected = (not addon_id) (a.text, a.url) = (_('All My Add-ons'), reverse('devhub.feed_all')) items.append(a) for addon in addons: item = MenuItem() try: item.selected = (addon_id and addon.id == int(addon_id)) except ValueError: pass # We won't get here... EVER url = reverse('devhub.feed', args=[addon.slug]) item.text, item.url = addon.name, url items.append(item) return items
def _get_addons(request, addons, addon_id, action): """Create a list of ``MenuItem``s for the activity feed.""" items = [] a = MenuItem() a.selected = (not addon_id) (a.text, a.url) = (_('All My Add-ons'), reverse('devhub.feed_all')) if action: a.url += '?action=' + action items.append(a) for addon in addons: item = MenuItem() try: item.selected = (addon_id and addon.id == int(addon_id)) except ValueError: pass # We won't get here... EVER url = reverse('devhub.feed', args=[addon.slug]) if action: url += '?action=' + action item.text, item.url = addon.name, url items.append(item) return items