• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.user_model函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.user_model函数的典型用法代码示例。如果您正苦于以下问题:Python user_model函数的具体用法?Python user_model怎么用?Python user_model使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了user_model函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: GET

 def GET(self):
     # sql = 'SELECT post_id FROM comment GROUP BY post_id ORDER BY MAX(time) DESC LIMIT 20'
     # post_ids = post_model().query_result(sql)
     crumb = Crumb()
     limit = 50
     total = post_model().count_table()
     pagination = Pagination("/recent", total, limit=limit)
     page = pagination.true_page(web.input(p=1)["p"])
     post_results = post_model().get_all(limit=limit, offset=(page - 1) * limit, order="time DESC")
     posts = []
     for post_result in post_results:
         # post_result = post_model().get_one({'id':row.post_id})
         post = {"post": post_result}
         user = user_model().get_one({"id": post_result.user_id})
         post["user"] = user
         node = node_model().get_one({"id": post_result.node_id})
         post["node"] = node
         comment = comment_model().get_one({"post_id": post_result.id}, order="time DESC")
         if comment:
             comment_user = user_model().get_one({"id": comment.user_id})
             post["comment_user"] = comment_user
         else:
             post["comment_user"] = None
         posts.append(post)
     crumb.append("最近的主题")
     return render.recent("最近的主题", total, crumb.output(), posts, pagination.output())
开发者ID:nasawz,项目名称:post_bar,代码行数:26,代码来源:index.py


示例2: POST

 def POST(self):
     import json
     json_dict = {'success':0, 'msg':'', 'script':''}
     comment_id = web.input(comment_id=None)['comment_id']
     comment = comment_model().get_one({'id':comment_id})
     if comment_id and comment:
         if session.user_id is None:
             post = post_model().get_one({'id':comment.post_id})
             json_dict['msg'] = '你要先登录的亲'
             json_dict['script'] = 'location.href=\'/login?next=/post/'+str(post.id)+'#reply-'+str(comment_id)+'\''
         elif comment.user_id != session.user_id:
             comment_thanks_id = comment_thanks_model().unique_insert({'user_id':session.user_id, 'comment_id':comment_id})
             if comment_thanks_id:
                 comment_thanks_model().update({'id':comment_thanks_id}, {'time':int(time.time())})
                 cost = money_model().cal_thanks()
                 money_type_id = money_type_model().get_one({'name':'comment_thanks'})['id']
                 money_model().insert({'user_id':session.user_id, 'money_type_id':money_type_id, 'amount':-cost, 'balance':user_model().update_money(session.user_id, -cost), 'foreign_id':comment_thanks_id})
                 money_model().insert({'user_id':comment.user_id, 'money_type_id':money_type_id, 'amount':cost, 'foreign_id':comment_thanks_id, 'balance':user_model().update_money(comment.user_id, cost)})
                 comment_model().count_thanks(comment_id)
                 user_model().update_session(session.user_id)
                 json_dict['success'] = 1
             else:
                 json_dict['msg'] = '你已经感谢过了不是吗?'
         else:
             json_dict['msg'] = '你不能感谢你自己不是吗?'
     else:
         json_dict['message'] = '评论不存在'
     return json.dumps(json_dict)
开发者ID:Aimsam,项目名称:post_bar,代码行数:28,代码来源:comment.py


示例3: GET

 def GET(self):
 	title = '首页'
     #sql = 'SELECT post_id FROM comment GROUP BY post_id ORDER BY MAX(time) DESC LIMIT 20'
     #post_ids = post_model().query_result(sql)
     post_results = post_model().get_all(order='last_update DESC', limit=20)
     posts = []
     for post_result in post_results:
         #post_result = post_model().get_one({'id':row.post_id})
         post = {'post':post_result}
         user = user_model().get_one({'id':post_result.user_id})
         post['user'] = user
         node = node_model().get_one({'id':post_result.node_id})
         post['node'] = node
         comment = comment_model().get_one({'post_id':post_result.id}, order='time DESC')
         if comment:
             comment_user = user_model().get_one({'id':comment.user_id})
             post['comment_user'] = comment_user
         else:
             post['comment_user'] = None
         posts.append(post)
     cats_result = cat_model().get_all()
     cats = []
     for cat_result in cats_result:
         cat = {'cat':cat_result}
         node = node_model().get_all({'category_id':cat_result.id})
         cat['node'] = node
         cats.append(cat)
     return render.index(cats, posts, title)
开发者ID:Aimsam,项目名称:post_bar,代码行数:28,代码来源:index.py


示例4: POST

 def POST(self, node_name):
     if session.user_id is None:
         raise web.SeeOther('/login?next=/post/create' + node_name)
     conditions = {'name' : node_name}
     node = node_model().get_one(conditions)
     if node is None:
         return render.not_found('节点未找到', '节点未找到')
     if not self.form.validates():
         return render.create_post(self.form, '创建失败, 请重创:D', self.crumb.output())
     user_model().update_session(session.user_id)
     length, cost = money_model().cal_post(self.form.d.content)
     if session.money < cost:
         self.crumb.append('财富不够')
         return render.no_money('财富不够', '你的财富值不够,不能创建改主题 :(', self.crumb.output())
     title = strip_tags(self.form.d.title)
     content = html2db(self.form.d.content)
     content, receiver_list = notify_model().convert_content(content)
     create_time = time.time()
     post_id = post_model().insert({'title' : title, 'content' : content, 'node_id' : node.id, 'time' : create_time, 'last_update':create_time, 'user_id' : session.user_id})
     # money
     money_type_id = money_type_model().get_one({'name':'post'})['id']
     money_model().insert({'user_id':session.user_id, 'money_type_id':money_type_id, 'amount':-cost, 'length':length, 'balance':user_model().update_money(session.user_id, -cost), 'foreign_id':post_id})
     # notify
     receiver_list = list_diff(receiver_list, [session.name])
     notify_model().insert_notify(session.user_id, receiver_list, 'post_at', post_id)
     user_model().update_session(session.user_id)
     raise web.seeother('/post/' + str(post_id))
开发者ID:Aimsam,项目名称:post_bar,代码行数:27,代码来源:post.py


示例5: GET

 def GET(self, name):
     limit = 10
     user = user_model().get_one({'name':name})
     crumb = Crumb()
     if user:
         crumb.append(name, '/profile/'+name)
         crumb.append('全部主题')
         total_rows = post_model().count_table({'user_id':user.id})
         pagination = Pagination('/profile/'+name+'/posts', total_rows, limit = limit)
         page = pagination.true_page(web.input(p=1)['p'])
         posts_result = post_model().get_all({'user_id':user.id}, limit = limit, offset = (page-1) * limit, order = 'time DESC')
         posts = []
         for post_result in posts_result:
             post = {'post':post_result}
             node = node_model().get_one({'id':post_result.node_id})
             post['node'] = node
             comment = comment_model().get_one({'post_id':post_result.id}, order='time DESC')
             if comment:
                 comment_user = user_model().get_one({'id':comment.user_id})
                 post['comment_user'] = comment_user
             else:
                 post['comment_user'] = None
             posts.append(post)
         return render.user_posts('全部主题', user,  posts, total_rows, crumb.output(), pagination.output())
     else:
         crumb.append('会员未找到')
         return render.user_nf('会员未找到', crumb.output())
开发者ID:codepongo,项目名称:post_bar,代码行数:27,代码来源:user.py


示例6: GET

 def GET(self, post_id):
     if session.user_id is None:
             raise web.SeeOther('/login?next=/post/unfav/'+post_id)
     user_meta_model().delete({'user_id':session.user_id, 'meta_key':'post_fav','meta_value':post_id})
     user_model().update({'id':session.user_id}, {'post_favs':user_meta_model().count_meta({'user_id':session.user_id, 'meta_key':'post_fav'})})
     user_model().update_session(session.user_id)
     raise web.SeeOther('/post/'+post_id)
开发者ID:Aimsam,项目名称:post_bar,代码行数:7,代码来源:post.py


示例7: GET

 def GET(self, node_name):
     limit = 10
     node = node_model().get_one({'name': node_name})
     if node is None:
         self.crumb.append('节点未找到')
         return render.node_nf('节点未找到', self.crumb.output())
     else:
         self.crumb.append(node.display_name)
         node_fav = False
         if session.user_id:
             if user_meta_model().get_one({'user_id':session.user_id, 'meta_key':'node_fav', 'meta_value':node.id}):
                 node_fav = True
         total_rows = post_model().count_table({'node_id':node.id})
         pagination = Pagination('/node/'+node_name, total_rows, limit = limit)
         page = pagination.true_page(web.input(p=1)['p'])
         posts_result = post_model().get_all({'node_id' : node.id}, limit = limit, offset = (page-1)*limit , order = 'time DESC')
         posts = []
         for post_result in posts_result:
             post = {'post':post_result}
             user = user_model().get_one({'id':post_result.user_id})
             post['user'] = user
             comment = comment_model().get_one({'post_id':post_result.id}, order='time DESC')
             if comment:
                 comment_user = user_model().get_one({'id':comment.user_id})
                 post['comment_user'] = comment_user
             else:
                 post['comment_user'] = None
             posts.append(post)
         return render.node_posts(posts, node, total_rows, node_fav, self.crumb.output(), pagination.output())
开发者ID:Aimsam,项目名称:post_bar,代码行数:29,代码来源:node.py


示例8: POST

 def POST(self):
     self.crumb.append('设置')
     user = user_model().get_one({'id':session.user_id})
     self.setting_form.name.set_value(user.name)
     if not self.setting_form.validates():
         self.setting_form.name.set_value(user.name)
         self.setting_form.email.set_value(user.email)
         self.setting_form.email.set_value(user.signature)
         self.setting_form.email.set_value(user.outsite_link)
         return render.settings('设置', user, self.setting_form, self.pass_form, self.crumb.output())
     else:
         user_model().update({'id':user.id}, {'email':self.setting_form.d.email, 'signature':self.setting_form.d.signature, 'outsite_link':self.setting_form.d.outsite_link.replace('http://', '').replace('https://', '')})
         
         raise web.SeeOther('/settings')
开发者ID:codepongo,项目名称:post_bar,代码行数:14,代码来源:user.py


示例9: _post

 def _post(self):
     if not self.form.validates():
         return False, '登录失败,请重登'
     condition = {'name' : self.form.d.name}
     # MD5加密 密码
     #condition['password'] = hashlib.md5(condition['password']).hexdigest()
     user = user_model().get_one(condition)
     if user is None:
         return False, '用户不存在'
     auth_from_form = hashlib.md5(hashlib.md5(self.form.d.password).hexdigest() + user.auth).hexdigest()
     if auth_from_form != user.password:
         return False, '密码错误'
     user_model().update_session(user.id)
     user_model().set_cookie(user.id)
     data = web.input();
     return True, ''
开发者ID:codepongo,项目名称:post_bar,代码行数:16,代码来源:user.py


示例10: GET

 def GET(self):
     crumb = Crumb()
     condition = {"receiver": session.user_id}
     total = notify_model().count_table(condition)
     limit = 10
     pagination = Pagination("/notifications", total, limit=limit)
     page = pagination.true_page(web.input(p=1)["p"])
     notify_result = notify_model().get_all(condition, order="id DESC", limit=limit, offset=(page - 1) * limit)
     notifications = []
     if notify_result is not None:
         for notify in notify_result:
             post = None
             user = None
             comment = None
             notify_type = notify_type_model().get_one({"id": notify.type_id}).name
             user = user_model().get_one({"id": notify.user_id})
             if notify_type == "post_at":
                 post = post_model().get_one({"id": notify.foreign_id})
             elif notify_type == "comment" or notify_type == "comment_at":
                 comment = comment_model().get_one({"id": notify.foreign_id})
                 post = post_model().get_one({"id": comment.post_id})
             notifications.append(
                 {"notify": notify, "post": post, "user": user, "comment": comment, "type": notify_type}
             )
     notify_model().mark_as_read(session.user_id)
     crumb.append("提醒系统")
     return render.notify("提醒系统", crumb.output(), total, notifications, pagination.output())
开发者ID:marslabtron,项目名称:post_bar,代码行数:27,代码来源:notifications.py


示例11: __init__

 def __init__(self):
     if session.user_id:
         raise web.SeeOther('/')
     self.title = '登录'
     self.crumb = Crumb()
     self.crumb.append('登录')
     self.form = user_model().login_form
开发者ID:codepongo,项目名称:post_bar,代码行数:7,代码来源:user.py


示例12: GET

 def GET(self, method):
     if method.lower() == 'signin':
         if session.user_id is None:
             return json.dumps({'ret':False, 'msg':'未登录'})
         gain = random.randint(1, 100)
         money_type_id = 7#money_type_model().get_one({'name':'post'})['id']
         balance = user_model().update_money(session.user_id, gain)
         money_model().insert({'user_id':session.user_id, 'money_type_id':money_type_id, 'amount':gain, 'length':0, 'balance': balance, 'foreign_id':0})
         return json.dumps({'ret':True, 'info':{'account':balance, 'gain':gain}})
开发者ID:codepongo,项目名称:post_bar,代码行数:9,代码来源:api.py


示例13: run

 def run(self):
     ltime = time.localtime(time.time())
     time_start = int(time.mktime(datetime.datetime(ltime.tm_year, ltime.tm_mon, ltime.tm_mday).timetuple()))
     time_end = time_start + 24 * 60 * 60
     sql = 'SELECT `post_id` FROM comment WHERE `time` >= '+str(time_start)+' AND `time` <= '+str(time_end)+' GROUP BY post_id ORDER BY count(post_id) DESC LIMIT 10'
     post_ids = comment_model().query_result(sql)
     posts = []
     for row in post_ids:
         post = post_model().get_one({'id':row.post_id})
         user = user_model().get_one({'id':post.user_id})
         posts.append({'post':post, 'user':user})
     return render.hot_posts_tody(posts)
开发者ID:nasawz,项目名称:post_bar,代码行数:12,代码来源:widget.py


示例14: POST

 def POST(self):
     if not self.form.validates():
         return render.login(self.form, '登录失败,请重登', self.crumb.output())
     condition = {'name' : self.form.d.name}
     # MD5加密 密码
     #condition['password'] = hashlib.md5(condition['password']).hexdigest()
     user = user_model().get_one(condition)
     if user is None:
         return render.login(self.form, '用户名不存在', self.crumb.output())
     auth_from_form = hashlib.md5(hashlib.md5(self.form.d.password).hexdigest() + user.auth).hexdigest()
     if auth_from_form != user.password:
         return render.login(self.form, '密码错误', self.crumb.output())
     user_model().update_session(user.id)
     user_model().set_cookie(user.id)
     data = web.input();
     try:
         if data['next'] is not None:
             raise web.SeeOther(data['next'])
         else:
             raise web.SeeOther('/')
     except KeyError:
         raise web.SeeOther('/')
开发者ID:Aimsam,项目名称:post_bar,代码行数:22,代码来源:user.py


示例15: insert_notify

 def insert_notify(self, user_id, user_list, notify_type, foreign_id):
     if isinstance(user_list, list):
         for receiver in user_list:
             user = user_model().get_one({"name": receiver})
             if user is not None:
                 self.insert(
                     {
                         "user_id": user_id,
                         "receiver": user.id,
                         "type_id": self.types[notify_type],
                         "foreign_id": foreign_id,
                     }
                 )
     else:
         user = user_model().get_one({"name": user_list})
         if user is not None:
             self.insert(
                 {
                     "user_id": user_id,
                     "receiver": user.id,
                     "type_id": self.types[notify_type],
                     "foreign_id": foreign_id,
                 }
             )
开发者ID:marslabtron,项目名称:post_bar,代码行数:24,代码来源:notify_model.py



注:本文中的models.user_model函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Account类代码示例发布时间:2022-05-27
下一篇:
Python models.slugify函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap