示例#1
0
 def menus(self):
     res = []
     if (self.where in ('overview', 'submitted', 'comments')):
         res.append(ProfileSortMenu(default=self.sort))
         if self.sort not in ("hot", "new"):
             res.append(TimeMenu(default=self.time))
     if self.where == 'saved' and c.user.gold:
         srnames = LinkSavesBySubreddit.get_saved_subreddits(self.vuser)
         srnames += CommentSavesBySubreddit.get_saved_subreddits(self.vuser)
         srs = Subreddit._by_name(srnames)
         srnames = [
             name for name, sr in srs.iteritems() if sr.can_view(c.user)
         ]
         srnames = sorted(list(set(srnames)))
         if len(srnames) > 1:
             sr_buttons = [
                 NavButton(_('all'), None, opt='sr', css_class='primary')
             ]
             for srname in srnames:
                 sr_buttons.append(NavButton(srname, srname, opt='sr'))
             base_path = request.path
             sr_menu = NavMenu(sr_buttons,
                               base_path=base_path,
                               title=_('filter by subreddit'),
                               type='lightdrop')
             res.append(sr_menu)
     return res
示例#2
0
 def menus(self):
     res = []
     if (self.where in ('overview', 'submitted', 'comments')):
         res.append(ProfileSortMenu(default=self.sort))
         if self.sort not in ("hot", "new"):
             res.append(TimeMenu(default=self.time))
     return res
示例#3
0
    def menus(self):
        res = []
        if (self.where in ('overview', 'submitted', 'comments')):
            res.append(ProfileSortMenu(default=self.sort))
            if self.sort not in ("hot", "new"):
                res.append(TimeMenu(default=self.time))
        if self.where == 'saved' and c.user.gold:
            srnames = LinkSavesBySubreddit.get_saved_subreddits(self.vuser)
            srnames += CommentSavesBySubreddit.get_saved_subreddits(self.vuser)
            srs = Subreddit._by_name(srnames)
            srnames = [
                name for name, sr in srs.iteritems() if sr.can_view(c.user)
            ]
            srnames = sorted(list(set(srnames)), key=lambda name: name.lower())
            if len(srnames) > 1:
                sr_buttons = [
                    NavButton(_('all'), None, opt='sr', css_class='primary')
                ]
                for srname in srnames:
                    sr_buttons.append(NavButton(srname, srname, opt='sr'))
                base_path = request.path
                sr_menu = NavMenu(sr_buttons,
                                  base_path=base_path,
                                  title=_('filter by subreddit'),
                                  type='lightdrop')
                res.append(sr_menu)
        elif (self.where == 'gilded'
              and (c.user == self.vuser or c.user_is_admin)):
            path = '/user/%s/gilded/' % self.vuser.name
            buttons = [
                NavButton(_("my posts"), dest='/'),
                NavButton(_("posts gilded by me"), dest='/given')
            ]
            res.append(NavMenu(buttons, base_path=path, type='flatlist'))

        return res