Example #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))
     return res
Example #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))
     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
Example #3
0
    def query(self):
        q = Link._query(sort = SortMenu.operator(self.sort),
                        read_cache = True,
                        *c.site.query_rules())

        if g.REDDIT_MAIN:
            q._stats_collector = g.stats_collector

        t = TimeMenu.operator(self.time)
        if t: q._filter(t)

        return q
Example #4
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
Example #5
0
 def top_filter(self):
     return TimeMenu(default=self.time, title=_('Filter'), type='dropdown2')
Example #6
0
 def menus(self):
     return [TimeMenu(default=self.time)]