Exemple #1
0
    def GET(self, context):
        i = web.input(start=0, order=default_order, desc='desc', query='')
        start = int(i.start)
        context = context or 'all'
        user_id = session.is_logged() and session.get_user_id()

        results, num_results = applicants.query(query=i.query,
                                                context=context,
                                                offset=start,
                                                limit=results_per_page,
                                                order=i.order + ' ' + i.desc,
                                                user_id=user_id)

        pager = web.storage(
            paging.get_paging(start,
                              num_results,
                              results_per_page=results_per_page,
                              window_size=1))

        counts = applicants.get_counts()

        user = session.get_session()

        stats = applicants.get_stats()

        return view.layout(view.applicants(results, context, pager, i), user,
                           context, counts, i.query, stats)
    def POST(self, id):
        i = web.input(amount='')

        if i.id and i.amount:
            applicants.grant(session.get_user_id(), id, i.amount)

        raise web.seeother(web.ctx.environ['HTTP_REFERER'])
Exemple #3
0
    def GET(self, id):
        i = web.input(context='all',
                      start=0,
                      order=default_order,
                      desc='desc',
                      query='')
        start = int(i.start)
        user_id = session.is_logged() and session.get_user_id()

        results, num_results = applicants.query(query=i.query,
                                                context=i.context,
                                                offset=start and start - 1,
                                                limit=results_per_page + 2,
                                                order=i.order + ' ' + i.desc,
                                                user_id=user_id)

        pager = web.storage(
            paging.get_paging_results(start, num_results, int(id), results,
                                      results_per_page))

        counts = applicants.get_counts()

        user = session.get_session()

        applicant = applicants.get_by_id(id)

        _comments = comments.get_comments(applicant.id)

        _votes = votes.get_votes(applicant.id)

        stats = applicants.get_stats()

        return view.layout(
            view.applicant(applicant, _comments, _votes, user, pager, i), user,
            i.context, counts, i.query, stats)
Exemple #4
0
    def GET(self, id):
        img = image.get_img_by_imgid(id)
        if img:
            i = web.input(start=0, order=default_order, desc='desc', query='')
            start = int(i.start)
            user_id = session.is_logged() and session.get_user_id()
            author_id = img.userID
            results, num_results = image.query(author_id)
            pager = web.storage(paging.get_paging_results(start, num_results, 
                int(id), results, results_per_page))
            #tm = time.strftime('%Y年%m月%d日', time.localtime(img.creationTime))
            author = users.get_user_by_id(img.userID)
            results = list(results)
            is_favorite = image.IsFavorite(user_id, img.id)

            #得到被多少人喜欢
            #count = image.GetFavUserCount(img_id)

            #浏览人数加1
            if user_id and image.user_not_viewed_image(user_id, id):
                image.add_img_hit(id)
                image.add_user_to_img_viewed(user_id, id)

            #得到评论
            comments = image.get_comment_by_image_id(id).list()
            #得到评论者信息
            comments_authors_ids = []
            for i in xrange(len(comments)):
                #comments_authors_ids += str(comments[i].user_id).split()
                comments_authors_ids += users.get_users_by_id(comments[i].user_id).list()
            

            return view.base(view.photo_single(img, pager, user_id, user, author, is_favorite, comments, comments_authors_ids), user, siteName)
        else:
            raise web.notfound()
Exemple #5
0
    def POST(self, id):
        i = web.input(amount='')

        if i.id and i.amount:
            applicants.grant(session.get_user_id(), id, i.amount)
        
        raise web.seeother(web.ctx.environ['HTTP_REFERER'])
Exemple #6
0
 def GET(self, id):
     i = web.input(context='all', start=0, order=default_order, desc='desc', query='')
     start = int(i.start)
     user_id = session.is_logged() and session.get_user_id()
     
     results, num_results = applicants.query(query=i.query, context=i.context, 
         offset=start and start - 1, limit=results_per_page+2, order=i.order + ' ' + i.desc, 
         user_id=user_id)
     
     pager = web.storage(paging.get_paging_results(start, num_results, 
         int(id), results, results_per_page))
     
     counts = applicants.get_counts()
     
     user = session.get_session()
     
     applicant = applicants.get_by_id(id)
     
     _comments = comments.get_comments(applicant.id)
     
     _votes = votes.get_votes(applicant.id)
     
     stats = applicants.get_stats()
     
     return view.layout(
         view.applicant(applicant, _comments, _votes, user, pager, i), 
         user, i.context, counts, i.query, stats)
    def POST(self, id):
        i = web.input(comment='')

        if i.id and i.comment:
            comments.add_comment(session.get_user_id(), id, i.comment)

        raise web.seeother(web.ctx.environ['HTTP_REFERER'])
Exemple #8
0
 def POST(self, id):
     i = web.input(comment='')
     
     if i.id and i.comment:
         comments.add_comment(session.get_user_id(), id, i.comment)
     
     raise web.seeother(web.ctx.environ['HTTP_REFERER'])
 def POST(self):
     f = self.form()
     if not f.validates(web.input(_unicode=False)):
         return render_settings(email_form=f)
     else:
         users.update(session.get_user_id(), email=f.d.email)
         session.reset()
         raise web.seeother('/settings')
Exemple #10
0
 def POST(self):
     f = self.form()
     if not f.validates(web.input(_unicode=False)):
         return render_settings(email_form=f)
     else:
         users.update(session.get_user_id(), email=f.d.email)
         session.reset()
         raise web.seeother('/settings')
Exemple #11
0
 def POST(self):
     f = self.form()
     if not f.validates(web.input(_unicode=False)):
         return render_settings(password_form=f)
     else:
         users.update(session.get_user_id(), password=f.d.password)
         session.reset()
         return render_settings(on_success_message='Your password has been successfuly changed.')
    def POST(self):
        i = web.input(context='', id=[], score=[])
        score = web.intget(i.score[0] or i.score[1], '')

        if i.id and score:
            #            applicants.rate(i.id, score, session.get_user_id())
            votes.add(i.id, score, session.get_user_id())
        raise web.seeother(web.ctx.environ['HTTP_REFERER'])
Exemple #13
0
    def POST(self):
        i = web.input(context='', id=[], score=[])
        score = web.intget(i.score[0] or i.score[1], '')
        
        if i.id and score:
#            applicants.rate(i.id, score, session.get_user_id())
            votes.add(i.id, score, session.get_user_id())
        raise web.seeother(web.ctx.environ['HTTP_REFERER'])
 def POST(self):
     f = self.form()
     if not f.validates(web.input(_unicode=False)):
         return render_settings(password_form=f)
     else:
         users.update(session.get_user_id(), password=f.d.password)
         session.reset()
         return render_settings(
             on_success_message='Your password has been successfuly changed.'
         )
Exemple #15
0
    def GET(self, id):
        img = image.get_img_by_imgid(id)
        if img:
            i = web.input(start=0, order=default_order, desc='desc', query='')
            start = int(i.start)
            user_id = session.is_logged() and session.get_user_id()
            author_id = img.userID
            results, num_results = image.query(author_id)
            pager = web.storage(
                paging.get_paging_results(start, num_results, int(id), results,
                                          results_per_page))
            #tm = time.strftime('%Y年%m月%d日', time.localtime(img.creationTime))
            author = users.get_user_by_id(img.userID)
            results = list(results)
            is_favorite = image.IsFavorite(user_id, img.id)

            #得到被多少人喜欢
            #count = image.GetFavUserCount(img_id)

            #浏览人数加1
            if user_id and image.user_not_viewed_image(user_id, id):
                image.add_img_hit(id)
                image.add_user_to_img_viewed(user_id, id)

            #得到评论
            comments = image.get_comment_by_image_id(id).list()
            #得到评论者信息
            comments_authors_ids = []
            for i in xrange(len(comments)):
                #comments_authors_ids += str(comments[i].user_id).split()
                comments_authors_ids += users.get_users_by_id(
                    comments[i].user_id).list()

            return view.base(
                view.photo_single(img, pager, user_id, user, author,
                                  is_favorite, comments, comments_authors_ids),
                user, siteName)
        else:
            raise web.notfound()
Exemple #16
0
 def GET(self, context):
     i = web.input(start=0, order=default_order, desc='desc', query='')
     start = int(i.start)
     context = context or 'all'
     user_id = session.is_logged() and session.get_user_id()
     
     results, num_results = applicants.query(query=i.query, context=context, 
         offset=start, limit=results_per_page, order=i.order + ' ' + i.desc, 
         user_id=user_id)
     
     pager = web.storage(paging.get_paging(start, num_results, 
         results_per_page=results_per_page, window_size=1))
     
     counts = applicants.get_counts()
     
     user = session.get_session()
     
     stats = applicants.get_stats()
     
     return view.layout(
         view.applicants(results, context, pager, i), 
         user, context, counts, i.query, stats)
Exemple #17
0
    def POST(self, id):
        form = post_form()
        data = web.input(category_ids=[])

        if 'slug' in data and data['slug'].strip():
            data['slug'] = data['slug'].strip()
            form.slug.validators = (validator.unique('posts', 'slug'), )

        if 'category_ids' in data:
            data['category_ids'] = [web.intget(category_id, 0)  for category_id in data['category_ids']]

        if not form.validates(data):
            return render.post_edit(form)

        data['user_id'] = session.get_user_id()

        if post_model.update_post(id=id, **data):
            session.set_flash('编辑文章成功', 'success')
        else:
            session.set_flash('编辑文章失败', 'error')

        raise web.seeother('/post/edit/%d', id)
    def GET(self, comment_id):
        comments.delete_comment(session.get_user_id(), comment_id)

        raise web.seeother(web.ctx.environ['HTTP_REFERER'])
Exemple #19
0
 def GET(self, comment_id):
     comments.delete_comment(session.get_user_id(), comment_id)
     
     raise web.seeother(web.ctx.environ['HTTP_REFERER'])
Exemple #20
0
 def GET(self):
     userid = session.get_user_id()
     user_data = users.get_user_by_id(userid)
     # print user_data
     return view.base(view.index(user_data))
    def POST(self):
        i = web.input(context='', id=[])

        if i.id:
            applicants.make_attendee(i.id, session.get_user_id())
        raise web.seeother(web.ctx.environ['HTTP_REFERER'])
Exemple #22
0
 def GET(self, name):
     userid = session.get_user_id()
     user_data = users.get_user_by_id(userid)
     return view.base(view.index(user_data))
Exemple #23
0
 def POST(self):
     i = web.input(context='', id=[])
     
     if i.id:
         applicants.undecide(i.id, session.get_user_id())
     raise web.seeother(web.ctx.environ['HTTP_REFERER'])