예제 #1
0
    def __init__(self, name):
        self.name = name
        self.user = User(name)

        current_user = request.user
        self.is_self = current_user and current_user.username == self.name
        ext = request.get_path().split('/')[-1]
        (self.page, self.start, self.link_prev, self.link_next, self.sort,
         self.direction) =\
            make_page_args(request, self.name, ext=ext)
        self.n_all = Gist.count_user_all(self.name, self.is_self)
        self.n_fork = Gist.count_user_fork(self.name)
        self.n_star = Gist.count_user_star(self.name)

        if self.sort not in ('created', 'updated') \
                or self.direction not in ('desc', 'asc'):
            raise TraversalError()
예제 #2
0
파일: gist.py 프로젝트: 000fan000/code
    def __init__(self, name):
        self.name = name
        self.user = User(name)

        current_user = request.user
        self.is_self = current_user and current_user.username == self.name
        ext = request.get_path().split('/')[-1]
        (self.page, self.start, self.link_prev, self.link_next, self.sort,
         self.direction) =\
            make_page_args(request, self.name, ext=ext)
        self.n_all = Gist.count_user_all(self.name, self.is_self)
        self.n_fork = Gist.count_user_fork(self.name)
        self.n_star = Gist.count_user_star(self.name)

        if self.sort not in ('created', 'updated') \
                or self.direction not in ('desc', 'asc'):
            raise TraversalError()
예제 #3
0
    def test_gist_count_classmethod(self):
        gist = self._add_gist()
        user_id = 'testuser'

        ret = Gist.count_user_all(user_id)
        eq_(ret, 1)

        gist.fork(user_id)
        ret = Gist.count_user_fork(user_id)
        eq_(ret, 1)

        gist.star(user_id)
        ret = Gist.count_user_star(user_id)
        eq_(ret, 1)

        ret = Gist.count_public_by_user(user_id)
        eq_(ret, 2)

        ret = Gist.count_secret_by_user(user_id)
        eq_(ret, 0)