Exemple #1
0
    def favdelete(self):
        inputParams = self.getInput()
        groupfav = GroupFavorites.get(GroupFavorites.id == int(inputParams['id']))

        current_user = Users.get(Users.name == self.isLogin())
        if current_user.id != groupfav.owner.id and not self.isAdmin() or  not current_user.role.type < 100:
            return self.error(msg = '权限不足!', url=self.makeUrl('/admin/groups/favorites'))

        try:
            groupfav.delete_instance()
        except Exception, e:
            return self.success(msg='公司收藏删除失败: %s' % e, url=self.makeUrl('/admin/groups/favorites'))
Exemple #2
0
    def favorite(self):
        inputParams = self.getInput()
        page = int(inputParams['page']) if inputParams.has_key('page') else 1
        count = config.COUNT_PER_PAGE
        ###favotar只有admin能看到全部的,否则只能看到本人的
        current_user = Users.get(Users.name == self.isLogin())
        groupFavList = GroupFavorites.select()
        if not self.isAdmin():
            groupFavList = groupFavList.where(GroupFavorites.owner == current_user.id)
        pageString = self.getPageStr('/admin/groups/favorite', page, count, groupFavList.count())
        self.privData['GROUPFAV_LIST'] = groupFavList.order_by(GroupFavorites.id.desc()).paginate(page, count)
        self.privData['PAGE_STRING'] = pageString

        return self.display('groupfavViewList')