Exemplo n.º 1
0
 def set_user_member(self, organization_id, user_id, excuse):
     info = self.find_data(['type'],
                           organization_id=organization_id,
                           user_id=user_id,
                           get_some=False)
     if not info:  #如果没有该条数据
         info = {}
         info['type'] = 0
         self.insert_into_db({
             "organization_id":
             organization_id,
             "user_id":
             user_id,
             "type":
             self.is_ord_memeber,
             "msg":
             excuse,
             "change_date":
             PublicFunc.get_current_datetime()
         })
         return
     new_type = info['type'] | self.is_ord_memeber
     return self.update_db({'type': new_type},
                           organization_id=organization_id,
                           user_id=user_id,
                           msg=excuse,
                           change_date=PublicFunc.get_current_datetime())
Exemplo n.º 2
0
 def get_interact(self, comm_id, page):
     """直接根据团队id获取这个互动  这块还是先查到这条数据的id 再查找多条数据"""
     # return [rows for rows in self.m_c.find({search_key:int(id)})]
     page = int(page)
     per_page = 10
     interact_info = self.m_c.find({
         'comm_id': comm_id
     }, {
         'content': 1,
         'time': 1,
         '_id': 0,
         'uid': 1
     }).skip(per_page * page).limit(per_page).sort([('time', -1)])
     interact_list = []
     current_time = PublicFunc.get_current_stamp()
     index = page * per_page
     for info in interact_info:
         index += 1
         info['time'] = PublicFunc.time_format_span(info['time'],
                                                    current_time)
         info['index'] = index
         if not info['uid']:
             info['avatar'] = 'http://101.200.214.68/Uploads/head.png'
             info['nickname'] = '游客'
         else:
             user_info = UsersModel.get_instance().get_import_user_info(
                 info['uid'], ['avatar', 'username'])
             info['avatar'] = user_info['avatar']
             info['nickname'] = user_info['username']
         del info['uid']
         interact_list.append(info)
     return interact_list
Exemplo n.º 3
0
	def get_post_info(self,uid,post_id):
		"""
		获取说说详情
		"""

		post_info = PostModel().get_post_info(post_id)
		post_info['post_id'] = str(post_info['_id'])
		current_time = PublicFunc.get_current_stamp()
		post_info['time'] = PublicFunc.time_format_span(post_info['time'],current_time)
		del post_info['_id']
		user_info = UsersModel().get_import_user_info(post_info['uid'],['avatar','nickname'])#获取发说说的人的信息
		post_info['avatar'] = user_info['avatar']
		post_info['nickname'] = user_info['nickname'] if user_info['nickname'] else options.default_nick_name
		comm_list = post_info['comm_list']
		for comm in comm_list:
			comm['time'] = PublicFunc.time_format_span(comm['time'],current_time)
			comm_user_info =  UsersModel().get_import_user_info(comm['uid'],['avatar','nickname'])#获取评论说说的人的信息
			comm['avatar'] = comm_user_info['avatar']
			comm['nickname'] = comm_user_info['nickname'] if comm_user_info['nickname'] else options.default_nick_name
		love_list = post_info['love_list']
		for lover in love_list:
			lover_info = UsersModel().get_import_user_info(lover['uid'],['avatar','nickname'])#获取评论说说的人的信息
			lover['avatar'] = lover_info['avatar']
		# post_info['pic_list'] = [options.ipnet + pic for pic in post_info['pic_list']]
		# post_info['pic_list'] = [{'ori_pic':options.ipnet + pic,'thumb_pic':options.ipnet+options.post_thumb_save_path+'t'+pic[-17:]} for pic in post_info['pic_list']]
		post_info['pic_list'] = [{'ori_pic':options.ipnet + pic,'thumb_pic':options.ipnet+pic} for pic in post_info['pic_list']]
		#man has love? 
		post_info['has_love'] = 1 if PostLoveModel().judge_post_love(uid,post_info['post_id']) else 0
		if int(post_info['uid']) == int(uid): post_info['has_follow'] = ''
		else:post_info['has_follow'] = '已关注' if FollowModel().get_follow_status(uid,post_info['uid']) else '关注'
		# post['has_follow'] = '已关注' if FollowModel().get_follow_status(uid,post['uid']) else '关注'
		return post_info
Exemplo n.º 4
0
	def get_game_list(self,uid):
		game_list = self.gamemodel.get_game_list()
		for game_info in game_list:
			game_info['gacceptstartdate'] = PublicFunc.stamp_to_Ymd(game_info['gacceptstart'])
			game_info['gacceptenddate'] = PublicFunc.stamp_to_Ymd(game_info['gacceptend'])
			game_info['gfrontpage'] = options.ipnet + game_info['gfrontpage']
			game_info['agreement'] = options.ipnet + '/py/game?action=get_agreement&id=' + str(game_info['gid'])
			game_info['gstatusid'],game_info['gstatus'] = self.get_status_name(game_info['gstarttime'],game_info['gendtime'],game_info['gacceptstart'],game_info['gacceptend'])
			if game_info['gid'] == 7:
				game_info['gintro'] = options.ipnet + '/bjjbz/intro.html?uid=' + str(uid)
				game_info['gintro_wecha'] = options.ipnet + '/bjjbz/intro.html?uid=' + str(uid)
			elif game_info['gid'] == 9:
				# game_info['gintro'] = 'http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&tempkey=6TdVDeLTjka%2FMedRgXr1jw5%2FEhRKAIdReyd2gYGoWvwCSJzZcVIQlw8ahYcN%2BhuSTga1LrgOwZ4xABg1O%2BbrtOuAdiWuSbVezSlYfihfUS3PSw1YoiJG8DhKWPiejoTWzHRVFZZrRPYejqkYKPGd1A%3D%3D&scene=1&srcid=0725qMCq5oIglvAmfbrXsUvp#wechat_redirect'
				# game_info['gintro_wecha'] = 'http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&tempkey=6TdVDeLTjka%2FMedRgXr1jw5%2FEhRKAIdReyd2gYGoWvwCSJzZcVIQlw8ahYcN%2BhuSTga1LrgOwZ4xABg1O%2BbrtOuAdiWuSbVezSlYfihfUS3PSw1YoiJG8DhKWPiejoTWzHRVFZZrRPYejqkYKPGd1A%3D%3D&scene=1&srcid=0725qMCq5oIglvAmfbrXsUvp#wechat_redirect'
				game_info['gintro'] = 'http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&mid=2247483830&idx=1&sn=a5e8ba2a262f3a1da7b65a5c18037315&scene=1&srcid=0725YTSd96e9sFKnqkH9AQZt#rd'
				game_info['gintro_wecha'] = 'http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&mid=2247483830&idx=1&sn=a5e8ba2a262f3a1da7b65a5c18037315&scene=1&srcid=0725YTSd96e9sFKnqkH9AQZt#rd'
			elif game_info['gid'] == 10:
				game_info['gintro'] = 'http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&mid=2247483874&idx=1&sn=6371b0fd66106ce4e21650eb82b88090&scene=23&srcid=0729PXR5Q6FQFYiWnTr1vICx#rd'
				game_info['gintro_wecha'] = 'http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&mid=2247483874&idx=1&sn=6371b0fd66106ce4e21650eb82b88090&scene=23&srcid=0729PXR5Q6FQFYiWnTr1vICx#rd'
			elif game_info['gid'] == 12:
				game_info['gintro'] = "http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&mid=2247483877&idx=1&sn=2efec6568c5cf9b434d43e96b76d9b00#rd"
				game_info['gintro_wecha'] = "http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&mid=2247483877&idx=1&sn=2efec6568c5cf9b434d43e96b76d9b00#rd"
			else:
				game_info['gintro'] = options.ipnet + '/py/game?action=get_intro&id=' + str(game_info['gid']) + \
            	'&uid=' + str(uid) + '&gtype=' + str(game_info['gtype_id'])
            	game_info['gintro_wecha'] = options.ipnet + '/ky/game?action=get_intro&id=' + str(game_info['gid']) + \
            	'&uid=' + str(uid) + '&gtype=' + str(game_info['gtype_id'])
        	del game_info['gacceptstart']
        	del game_info['gacceptend']
		return game_list
Exemplo n.º 5
0
	def get_post_list(self,uid,page):
		"""
		function: 获取互动列表

		"""
		post_list = PostModel().get_post_list(page)
		current_time = PublicFunc.get_current_stamp()
		for post in post_list:
			post['post_id'] = str(post['_id'])
			post['have_love'] = 1 if PostLoveModel().judge_post_love(uid,post['_id']) else 0 
			del post['_id']
			# post['pic_list'] = [{'ori_pic':options.ipnet + pic,'thumb_pic':options.ipnet+options.post_thumb_save_path+'t'+pic[-17:]} for pic in post['pic_list']]
			post['pic_list'] = [{'ori_pic':options.ipnet + pic,'thumb_pic':options.ipnet+pic} for pic in post['pic_list']]
			post['time'] = PublicFunc.time_format_span(post['time'],current_time)
			user_info = UsersModel().get_import_user_info(post['uid'],['avatar','nickname'])
			# qz = user_info['avatar'][:4]
			
			post['avatar'] = user_info['avatar']
			post['nickname'] = user_info['nickname'] if user_info['nickname'] else options.default_nick_name
			post['self_post'] = 0
			if post['uid'] == int(uid): 
				post['has_follow'] = ''
				post['self_post'] = 1
			else: post['has_follow'] = '已关注' if FollowModel().get_follow_status(uid,post['uid']) else '关注'
		return post_list
Exemplo n.º 6
0
	def get_note_comm(self,note_id,page):
		"""
		function: 获取帖子的评论
		input param: 
		         note_id: 帖子id  
		         page 分页
		return xxx
		"""
		comm_num = NoteModel().get_note_comm_num(note_id)
		page = int(page)
		comm_per_page = int(options.note_comm_per_page)
		level = comm_num - page*comm_per_page
		note_comm_list = NoteComModel().get_note_comm(note_id,page)
		current_time = PublicFunc.get_current_stamp()
		for comm in note_comm_list:
			comm['comm_id'] = str(comm['_id'])
			user_info = UsersModel().get_import_user_info(comm['uid'],['avatar','nickname'])
			comm['avatar'] = user_info['avatar']
			comm['nickname'] = user_info['nickname'] if user_info['nickname'] else options.default_nick_name
			comm['level'] = level
			level -= 1 
			comm['time'] = PublicFunc.time_format_span(comm['time'],current_time)
			del comm['_id']
			del comm['note_id']
		return note_comm_list
Exemplo n.º 7
0
	def get_note_info(self,note_id):
		"""获取帖子信息"""
		note_info = self.m_c.find_one({"_id":ObjectId(note_id),'status':0})
		note_info['time'] = PublicFunc.time_format_span(note_info['time'],PublicFunc.get_current_stamp())
		note_info['note_id'] = str(note_info['_id'])
		note_info['is_up'] = 1 if note_info['up'] else 0 
		del note_info['_id']
		del note_info['status']
		return note_info
Exemplo n.º 8
0
	def get_user_note(self,uid,page):
		"""获取我的帖子列表"""
		uid = int(uid)
		note_list = NoteModel().get_user_note(uid,page)
		current_time = PublicFunc.get_current_stamp()
		for note in note_list:
			note['note_id'] = str(note['_id'])
			del note['_id']
			note['time'] = PublicFunc.time_format_span(note['time'],current_time)
		return note_list
Exemplo n.º 9
0
	def get_following_list(self,uid,page):
		"""获取我所关注的人的列表"""
		following_list = self.followmodel.get_following_list(uid,page)
		current_time = PublicFunc.get_current_stamp()
		for f in following_list:
			f['time'] = PublicFunc.time_format_span(f['time'],current_time)
			user_info = UsersModel().get_import_user_info(f['fuid'],['avatar','nickname'])
			f['avatar'] = user_info['avatar']
			f['nickname'] = user_info['nickname'] if user_info['nickname'] else options.default_nick_name
		return following_list
Exemplo n.º 10
0
 def save_trace(self, uid, logitude, latitude):
     current_time = PublicFunc.get_current_stamp()
     current_date = PublicFunc.get_current_datetime()
     result = self.insert_into_db({
         'uid': uid,
         'logitude': logitude,
         'latitude': latitude,
         'timestamp': current_time,
         'date_time': current_date
     })
     return
Exemplo n.º 11
0
 def send_wecha_bind_tel_code(self,tel,uid):
     """向待绑定微信的手机号发送验证码 """
     if not PublicFunc.tel_regex(tel): return '手机号码不合法' #手机号码不合法
     if self.get_uid_via_tel(tel) is None: return '该手机号未注册!'#提醒用户去注册
     if self.judge_tel_bind_status(tel): return '该手机号已经被绑定'#该账号已经被绑定
     if self.cache.exists('bind:tel:' + tel): return '验证码已经发送' #验证码已经发送
     code = PublicFunc.get_random_num(4)
     content = '您要绑定手机号 验证码为' + code + ' 有效期为5分钟'
     PublicFunc.send_sms(tel,content)
     self.cache.set('bind:tel:' + tel,code)
     self.cache.expire('bind:tel:' + tel,options.bind_tel_expires)
     return True #验证码发送成功
Exemplo n.º 12
0
 def init_community(self):
     # result = self.m_c.insert_one({'name':'yinshuai'}).inserted_id
     self.m_c.insert_one({
         'gid': 7,
         'comm_name': '劲松跑团',
         'create_time': PublicFunc.get_current_stamp()
     })
     self.m_c.insert_one({
         'gid': 7,
         'comm_name': '18里店跑团',
         'create_time': PublicFunc.get_current_stamp()
     })
Exemplo n.º 13
0
	def get_comm_list(self,post_id,page):
		"""
		get the comment list of the user post 
		"""
		current_time = PublicFunc.get_current_stamp()
		comm_list = PostComModel().get_comm_list(post_id,page)
		for comm in comm_list:
			comm['time'] = PublicFunc.time_format_span(comm['time'],current_time)
			user_info = UsersModel().get_import_user_info(comm['uid'],['avatar','nickname'])
			comm['avatar'] = user_info['avatar']
			comm['nickname'] = user_info['nickname'] if user_info['nickname'] else options.default_nick_name
		return comm_list
Exemplo n.º 14
0
	def get_lover_list(self,post_id,page):
		""" 获取说说喜欢用户列表"""
		lover_list = PostLoveModel().get_lover_list(post_id,page)
		current_time = PublicFunc.get_current_stamp()
		for lover in lover_list:
			del lover['_id']
			del lover['post_id']
			lover['time'] = PublicFunc.time_format_span(lover['time'],current_time)
			user_info = UsersModel().get_import_user_info(lover['uid'],['avatar','nickname'])
			lover['avatar'] = user_info['avatar']
			lover['nickname'] = user_info['nickname'] if user_info['nickname'] else options.default_nick_name
		return lover_list
Exemplo n.º 15
0
	def get_reward_list(self,page):
		page = int(page)
		per_page = 30
		reward_list = self.find_data(['description','timestamp','id','uid'],get_some=(page*5,per_page)) #aaaaaaa
		current_time = PublicFunc.get_current_stamp()
		for index,reward in enumerate(reward_list):
			user_info = UsersModel.get_instance().get_import_user_info(reward['uid'],['avatar','nickname'])
			reward_list[index]['nickname'] = '小跑男' if not user_info['nickname']  else user_info['nickname']  
			reward_list[index]['avatar'] = user_info['avatar']
			reward_list[index]['time'] = PublicFunc.time_format_span(str(reward['timestamp'])[:-3],current_time) 
			del reward_list[index]['timestamp']
		return reward_list
Exemplo n.º 16
0
 def send_admin_bind_code(self,tel):
     """管理员绑定时候发送验证吗"""
     tel = str(tel)
     if not PublicFunc.tel_regex(tel): return '手机号码不合法' #手机号码不合法
     #该手机号码已经被绑定 reuturn 1 
     if self.cache.exists('admin:bind:tel:' + tel): return '验证码已经发送' #验证码已经发送
     code = PublicFunc.get_random_num(4)
     content = '您要绑定手机号 验证码为' + code + ' 有效期为5分钟'
     self.cache.set('admin:bind:tel:' + tel,code)
     self.cache.expire('admin:bind:tel:' + tel,options.bind_tel_expires)
     if not PublicFunc.send_sms(tel,content): return '发送失败'
     return True
Exemplo n.º 17
0
 def send_wecha_bind_tel_code(self, tel, uid):
     """向待绑定微信的手机号发送验证码 """
     if not PublicFunc.tel_regex(tel): return '手机号码不合法'  #手机号码不合法
     if self.get_uid_via_tel(tel) is None: return '该手机号未注册!'  #提醒用户去注册
     if self.judge_tel_bind_status(tel): return '该手机号已经被绑定'  #该账号已经被绑定
     if self.cache.exists('bind:tel:' + tel): return '验证码已经发送'  #验证码已经发送
     code = PublicFunc.get_random_num(4)
     content = '您要绑定手机号 验证码为' + code + ' 有效期为5分钟'
     PublicFunc.send_sms(tel, content)
     self.cache.set('bind:tel:' + tel, code)
     self.cache.expire('bind:tel:' + tel, options.bind_tel_expires)
     return True  #验证码发送成功
Exemplo n.º 18
0
 def get_follower_list(self, uid, page):
     """获取粉丝列表"""
     follower_list = self.followmodel.get_follower_list(uid, page)
     current_time = PublicFunc.get_current_stamp()
     for f in follower_list:
         f['time'] = PublicFunc.time_format_span(f['time'], current_time)
         user_info = UsersModel().get_import_user_info(
             f['uid'], ['avatar', 'nickname'])
         f['avatar'] = user_info['avatar']
         f['nickname'] = user_info['nickname'] if user_info[
             'nickname'] else options.default_nick_name
     return follower_list
Exemplo n.º 19
0
 def send_admin_bind_code(self, tel):
     """管理员绑定时候发送验证吗"""
     tel = str(tel)
     if not PublicFunc.tel_regex(tel): return '手机号码不合法'  #手机号码不合法
     #该手机号码已经被绑定 reuturn 1
     if self.cache.exists('admin:bind:tel:' + tel):
         return '验证码已经发送'  #验证码已经发送
     code = PublicFunc.get_random_num(4)
     content = '您要绑定手机号 验证码为' + code + ' 有效期为5分钟'
     self.cache.set('admin:bind:tel:' + tel, code)
     self.cache.expire('admin:bind:tel:' + tel, options.bind_tel_expires)
     if not PublicFunc.send_sms(tel, content): return '发送失败'
     return True
Exemplo n.º 20
0
    def add_following(self, uid, fuid):
        """
		添加自己关注的人
		input param: 
				uid:用户id    
				fuid: 关注的人的id
		"""
        uid = int(uid)
        fuid = int(fuid)
        following_info = self.m_c.find_one({
            'uid': uid,
            'status': 0
        }, {
            '_id': 0,
            'following_list': 1
        })
        if not following_info or len(
                following_info['following_list']) < self.following_save_num:
            self.m_c.update({
                'uid': uid,
                'status': 0
            }, {
                "$inc": {
                    "following_num": 1
                },
                "$push": {
                    "following_list": {
                        'uid': fuid,
                        'time': PublicFunc.get_current_stamp()
                    }
                }
            }, True)
        else:
            following_list = following_info['following_list']
            following_list.insert(0, {
                'uid': fuid,
                'time': PublicFunc.get_current_stamp()
            })
            following_list = following_list[0:self.following_save_num]
            self.m_c.update({
                'uid': uid,
                'status': 0
            }, {
                "$inc": {
                    "following_num": 1
                },
                "$set": {
                    "following_list": following_list
                }
            })
        return True
Exemplo n.º 21
0
	def get_dy_list(self,organization_id,page):
		"""
		获取动态列表,根据不同的type有不同的显示范式  type为1表示这种谁谁加入,谁谁报名活动了
		type为2表示发布了什么活动等
		"""
		dy_list = OrganizationStatusMessageModel().get_dy_list(organization_id,page)
		for dy in dy_list:
			dy['target_img'] =  dy['target_img']
			stamp = PublicFunc.date_to_stamp(dy['create_time'])
			dy['create_time'] = PublicFunc.time_format_span(stamp,int(time.time()))
		return_info = {}
		return_info['per_page'] = options.dy_per_page
		return_info['dy_list'] = dy_list
		return return_info
Exemplo n.º 22
0
 def get_game_list(self, uid):
     game_list = self.gamemodel.get_game_list()
     for game_info in game_list:
         game_info['gacceptstartdate'] = PublicFunc.stamp_to_Ymd(
             game_info['gacceptstart'])
         game_info['gacceptenddate'] = PublicFunc.stamp_to_Ymd(
             game_info['gacceptend'])
         game_info['gfrontpage'] = options.ipnet + game_info['gfrontpage']
         game_info[
             'agreement'] = options.ipnet + '/py/game?action=get_agreement&id=' + str(
                 game_info['gid'])
         game_info['gstatusid'], game_info[
             'gstatus'] = self.get_status_name(game_info['gstarttime'],
                                               game_info['gendtime'],
                                               game_info['gacceptstart'],
                                               game_info['gacceptend'])
         if game_info['gid'] == 7:
             game_info[
                 'gintro'] = options.ipnet + '/bjjbz/intro.html?uid=' + str(
                     uid)
             game_info[
                 'gintro_wecha'] = options.ipnet + '/bjjbz/intro.html?uid=' + str(
                     uid)
         elif game_info['gid'] == 9:
             # game_info['gintro'] = 'http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&tempkey=6TdVDeLTjka%2FMedRgXr1jw5%2FEhRKAIdReyd2gYGoWvwCSJzZcVIQlw8ahYcN%2BhuSTga1LrgOwZ4xABg1O%2BbrtOuAdiWuSbVezSlYfihfUS3PSw1YoiJG8DhKWPiejoTWzHRVFZZrRPYejqkYKPGd1A%3D%3D&scene=1&srcid=0725qMCq5oIglvAmfbrXsUvp#wechat_redirect'
             # game_info['gintro_wecha'] = 'http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&tempkey=6TdVDeLTjka%2FMedRgXr1jw5%2FEhRKAIdReyd2gYGoWvwCSJzZcVIQlw8ahYcN%2BhuSTga1LrgOwZ4xABg1O%2BbrtOuAdiWuSbVezSlYfihfUS3PSw1YoiJG8DhKWPiejoTWzHRVFZZrRPYejqkYKPGd1A%3D%3D&scene=1&srcid=0725qMCq5oIglvAmfbrXsUvp#wechat_redirect'
             game_info[
                 'gintro'] = 'http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&mid=2247483830&idx=1&sn=a5e8ba2a262f3a1da7b65a5c18037315&scene=1&srcid=0725YTSd96e9sFKnqkH9AQZt#rd'
             game_info[
                 'gintro_wecha'] = 'http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&mid=2247483830&idx=1&sn=a5e8ba2a262f3a1da7b65a5c18037315&scene=1&srcid=0725YTSd96e9sFKnqkH9AQZt#rd'
         elif game_info['gid'] == 10:
             game_info[
                 'gintro'] = 'http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&mid=2247483874&idx=1&sn=6371b0fd66106ce4e21650eb82b88090&scene=23&srcid=0729PXR5Q6FQFYiWnTr1vICx#rd'
             game_info[
                 'gintro_wecha'] = 'http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&mid=2247483874&idx=1&sn=6371b0fd66106ce4e21650eb82b88090&scene=23&srcid=0729PXR5Q6FQFYiWnTr1vICx#rd'
         elif game_info['gid'] == 12:
             game_info[
                 'gintro'] = "http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&mid=2247483877&idx=1&sn=2efec6568c5cf9b434d43e96b76d9b00#rd"
             game_info[
                 'gintro_wecha'] = "http://mp.weixin.qq.com/s?__biz=MzI4MzM4MDM5MQ==&mid=2247483877&idx=1&sn=2efec6568c5cf9b434d43e96b76d9b00#rd"
         else:
             game_info['gintro'] = options.ipnet + '/py/game?action=get_intro&id=' + str(game_info['gid']) + \
                      '&uid=' + str(uid) + '&gtype=' + str(game_info['gtype_id'])
     game_info['gintro_wecha'] = options.ipnet + '/ky/game?action=get_intro&id=' + str(game_info['gid']) + \
     '&uid=' + str(uid) + '&gtype=' + str(game_info['gtype_id'])
     del game_info['gacceptstart']
     del game_info['gacceptend']
     return game_list
Exemplo n.º 23
0
 def add_user_to_group(self, uid, group_id):
     self.insert_into_db({
         'group_id': group_id,
         'uid': uid,
         'attendtime': PublicFunc.get_current_stamp()
     })
     GroupModel.get_instance().change_group_mem_num(group_id, 1)
Exemplo n.º 24
0
	def get_user_post(self,uid,page,perpage):
		"""获取用户的朋友圈"""
		post_list = PostModel().get_user_post(uid,page,perpage)
		current_time = PublicFunc.get_current_stamp()
		is_today = 1 # 默认是今天
		for post in post_list:
			post['post_id'] = str(post['_id'])
			del post['_id'] 
			if not PublicFunc.get_date_today() == PublicFunc.stamp_to_Ymd(post['time']):is_today = 0
			post['is_today'] = is_today
			date_info = PublicFunc.get_date_info(post['time'],['day','month'])
			# post['pic_list'] = [{'ori_pic':options.ipnet + pic,'thumb_pic':options.ipnet+options.post_thumb_save_path+'t'+pic[-17:]} for pic in post['pic_list']]
			post['pic_list'] = [{'ori_pic':options.ipnet + pic,'thumb_pic':options.ipnet+pic} for pic in post['pic_list']]
			post['day'] = date_info['day']
			post['month'] = date_info['month']
		return post_list
Exemplo n.º 25
0
 def get_sysinfo(self, uid):
     info_list = self.find_data(['*'], order='id desc', uid=uid)
     info_list_all = self.find_data(['*'], order='id desc', uid=0)
     info_list = info_list + info_list_all
     for index, info in enumerate(info_list):
         info_list[index]['time'] = PublicFunc.stamp_to_YmdHM(info['time'])
     return info_list
Exemplo n.º 26
0
    def set_user_apply(self, organization_id, user_id, excuse):
        """
		设置用户为申请状态
		"""
        info = self.find_data(['type'],
                              organization_id=organization_id,
                              user_id=user_id,
                              get_some=False)
        if not info:  #如果没有该条数据
            info = {}
            info['type'] = 0
            self.insert_into_db({
                "organization_id":
                organization_id,
                "user_id":
                user_id,
                "type":
                self.is_applying,
                "msg":
                excuse,
                "change_date":
                PublicFunc.get_current_datetime()
            })
            return
        new_type = info['type'] | self.is_applying
        return self.update_db({'type': new_type},
                              organization_id=organization_id,
                              user_id=user_id)
Exemplo n.º 27
0
    def treat_tel_bind(self, tel, code, uid):
        """
        (当然这里用户使用微信登录的时候才会有)如果微信要绑定手机号的话,那么需要传入手机号,验证码以及用户当前登录的uid,当然,既然要绑定手机号,那么这个手机号必然没有被绑定过
        由于用户当前是使用的微信登录之后获取到的uid 和 token,为了保证uid和token 可用,所以即使这个uid所对应的行当中tel为空也不能软删这条数据
        步骤:
        (1)手机号合法性判断
        (2)手机号是否已经被绑定判定
        (3)判断输入的uid所代表的微信号是否已经绑定手机号
        (4)判断验证码是否存在或者过期
        (5)判断验证码是否正确
        (6)注销old手机号账户
        (7)混合数据
        (8)重新绑定
        """
        if not PublicFunc.tel_regex(tel): return '手机号码不合法'  #手机号码不合法
        if self.get_uid_via_tel(tel) is None: return '该手机号未注册!'  #提醒用户去注册
        if self.judge_tel_bind_status(tel): return '该手机号码已经被绑定'  #该手机号码已经被绑定
        if self.judge_wecha_tel_bind(uid): return '该微信号经被绑定'  #该微信号经被绑定
        code_cache = self.cache.get('bind:tel:' + tel)
        if not code_cache: return '还没有获取验证码'  #还没有获取验证码
        if not str(code) == code_cache: return '验证码错误'  #验证码错误
        self.cache.delete('bind:tel:' + tel)
        ori_uid = self.get_uid_via_tel(tel)  #绑定的手机号由于肯定是注册过的,获取uid
        self.update_db({'status': 1}, tel=tel)  #注销old手机号账户

        # print uid_in_users_table  #在这里可以混数据了   ==================================================================================
        self.update_db({'tel': tel}, uid=uid)  #修改用户主表来绑定手机号
        self.update_tel_in_cache(uid, tel)
        return True
Exemplo n.º 28
0
 def treat_tel_bind(self,tel,code,uid):
     """
     (当然这里用户使用微信登录的时候才会有)如果微信要绑定手机号的话,那么需要传入手机号,验证码以及用户当前登录的uid,当然,既然要绑定手机号,那么这个手机号必然没有被绑定过
     由于用户当前是使用的微信登录之后获取到的uid 和 token,为了保证uid和token 可用,所以即使这个uid所对应的行当中tel为空也不能软删这条数据
     步骤:
     (1)手机号合法性判断
     (2)手机号是否已经被绑定判定
     (3)判断输入的uid所代表的微信号是否已经绑定手机号
     (4)判断验证码是否存在或者过期
     (5)判断验证码是否正确
     (6)注销old手机号账户
     (7)混合数据
     (8)重新绑定
     """
     if not PublicFunc.tel_regex(tel): return '手机号码不合法' #手机号码不合法
     if self.get_uid_via_tel(tel) is None: return '该手机号未注册!' #提醒用户去注册
     if self.judge_tel_bind_status(tel): return '该手机号码已经被绑定'#该手机号码已经被绑定
     if self.judge_wecha_tel_bind(uid): return '该微信号经被绑定'#该微信号经被绑定
     code_cache = self.cache.get('bind:tel:' + tel)
     if not code_cache: return '还没有获取验证码'#还没有获取验证码
     if not str(code) == code_cache: return '验证码错误'#验证码错误
     self.cache.delete('bind:tel:' + tel)
     ori_uid = self.get_uid_via_tel(tel)#绑定的手机号由于肯定是注册过的,获取uid 
     self.update_db({'status':1},tel=tel) #注销old手机号账户
     
     # print uid_in_users_table  #在这里可以混数据了   ==================================================================================
     self.update_db({'tel':tel},uid=uid)#修改用户主表来绑定手机号
     self.update_tel_in_cache(uid,tel)
     return True
Exemplo n.º 29
0
 def get_score_list(self,gid):
 	"""根据赛事id 获取成绩播报列表列表"""
 	score_list =  self.find_data(['*'],order='time desc',gid=gid,status=0)
 	for index,score in enumerate(score_list):
 		score_list[index]['pic'] = options.ipnet + score['pic']
 		score_list[index]['time'] = PublicFunc.stamp_to_YmdHM(score['time'])
     return score_list
Exemplo n.º 30
0
 def get_reward_list(self, page):
     page = int(page)
     per_page = 30
     reward_list = self.find_data(['description', 'timestamp', 'id', 'uid'],
                                  get_some=(page * 5, per_page))  #aaaaaaa
     current_time = PublicFunc.get_current_stamp()
     for index, reward in enumerate(reward_list):
         user_info = UsersModel.get_instance().get_import_user_info(
             reward['uid'], ['avatar', 'nickname'])
         reward_list[index]['nickname'] = '小跑男' if not user_info[
             'nickname'] else user_info['nickname']
         reward_list[index]['avatar'] = user_info['avatar']
         reward_list[index]['time'] = PublicFunc.time_format_span(
             str(reward['timestamp'])[:-3], current_time)
         del reward_list[index]['timestamp']
     return reward_list
Exemplo n.º 31
0
 def write_group_invite(self, uid, group_id):
     if self.insert_into_db({
             'group_id': group_id,
             'uid': uid,
             'invitetime': PublicFunc.get_current_stamp()
     }):
         return True
Exemplo n.º 32
0
    def following_man(self, uid, fuid):
        """
		function: 关注他人,或者取消对他人的关注
		input param: 
				uid 关注者 
				fuid  被关注的人的id 
		"""
        uid = int(uid)
        fuid = int(fuid)
        count = self.m_c.find({'uid': uid, 'fuid': fuid, 'status': 0}).count()
        if count:
            self.m_c.update({
                'uid': uid,
                'fuid': fuid,
                'status': 0
            }, {"$set": {
                'status': 1
            }})
            return 'cancel_success'
        else:
            self.m_c.insert({
                'uid': uid,
                'fuid': fuid,
                'status': 0,
                'time': PublicFunc.get_current_stamp()
            })
            return 'follow_success'
Exemplo n.º 33
0
    def get_sysinfo(self,uid):
	    info_list = self.find_data(['*'],order='id desc',uid=uid)
	    info_list_all = self.find_data(['*'],order='id desc',uid=0)
	    info_list = info_list + info_list_all
	    for index,info in enumerate(info_list):
			info_list[index]['time'] = PublicFunc.stamp_to_YmdHM(info['time']) 
	    return info_list
Exemplo n.º 34
0
 def get_group_user_point_rank(self,group_id,get_num='all'):
     """获取用户积分排名信息,包含了用户的重要信息"""
     group_user_list = self.get_group_user_list(group_id,-1) #取出团队所有成员
     group_user_info_list = self.__get_group_user_info_via_uid_list(group_user_list)
     rank_user_info_list = sorted(group_user_info_list,key=operator.itemgetter('point'),reverse=True)
     if not get_num == 'all': rank_user_info_list = rank_user_info_list[:get_num]
     return PublicFunc.add_rank_string(rank_user_info_list)
Exemplo n.º 35
0
 def treat_admin_bind_code(self,tel,code):
     """处理管理员绑定时候的验证吗 还没有写好"""
     tel = str(tel)
     if not PublicFunc.tel_regex(tel): return '手机号码不合法' #手机号码不合法
     #该手机号码已经被绑定 reuturn 1 
     code_cache = self.cache.get('admin:bind:tel' + tel)
     if not code_cache: return '验证码失效,请重新发送'
     if not code == code_cache: return '验证码错误'
Exemplo n.º 36
0
 def update_user_token(self, uid):
     """temp function """
     token = PublicFunc.create_token(uid)
     change_param = {'token': token}
     self.update_db(change_param, uid=uid)
     self.clear_user_cache(uid)
     self.cache_import_user_info(uid)
     return token
Exemplo n.º 37
0
 def update_user_token(self,uid):
     """temp function """
     token = PublicFunc.create_token(uid)
     change_param = {'token':token}
     self.update_db(change_param,uid=uid)
     self.clear_user_cache(uid)
     self.cache_import_user_info(uid)
     return token
Exemplo n.º 38
0
	def get_act_status(self,regis_start_time,regis_end_time,start_time,end_time):
		current_datatime = PublicFunc.get_current_datetime()
		if current_datatime < regis_start_time: return {'flag':0,'name':'预告'}
		if current_datatime < regis_end_time: return {'flag':1,'name':'报名中'}
		if current_datatime < start_time: return {'flag':2,'name':'马上开始'} 
		if current_datatime < end_time: return {'flag':3,'name':'进行中'}   
		else: return {'flag':4,'name':'已结束'} 
		return '结束' 
Exemplo n.º 39
0
 def add_mem_to_group(self, uid, group_id, is_leader=0):
     return True if self.insert_into_db(
         {
             'is_leader': is_leader,
             'group_id': group_id,
             'uid': uid,
             'attendtime': PublicFunc.get_current_stamp()
         }) else False
Exemplo n.º 40
0
 def treat_admin_bind_code(self, tel, code):
     """处理管理员绑定时候的验证吗 还没有写好"""
     tel = str(tel)
     if not PublicFunc.tel_regex(tel): return '手机号码不合法'  #手机号码不合法
     #该手机号码已经被绑定 reuturn 1
     code_cache = self.cache.get('admin:bind:tel' + tel)
     if not code_cache: return '验证码失效,请重新发送'
     if not code == code_cache: return '验证码错误'
Exemplo n.º 41
0
 def cache_group_info(self,group_id):
 	group_id = str(group_id)
 	if not self.cache.exists('group:id:' + group_id) and self.judge_group_exist(group_id):
 		group_info = self.find_data(['*'],get_some=False,id=group_id)
 		group_info['createtime'] = PublicFunc.stamp_to_YmdHM(group_info['createtime'])
 		group_info['tag_name'] = TagModel.get_instance().get_tag_name(group_info['tag_id'])
 		group_info['avatar'] = options.ipnet + str(group_info['avatar'])
 		self.cache.hmset('group:id:' + group_id,group_info) #write into cache
     	self.cache.expire('group:id:' + group_id,options.group_info_expires)
Exemplo n.º 42
0
	def add_pic(self,uid,album_id,file_name,org_id):
		# create_time = int(time.time())
		create_time = PublicFunc.get_current_datetime()
		type = self.org_pic
		web_path = options.ipnet + "/Uploads/AlbumPic/" + file_name
		self.insert_into_db({'user_id':uid,'create_time':create_time,'type':type,'type_id':org_id,'target_id':album_id,'file_path':'','web_path':web_path,
							'file_name':file_name,'file_path':self.file_path,'file_old_name':'','old_width':0,'old_height':0,'old_size':0,
							'msg':''})
		return 
Exemplo n.º 43
0
	def attend_act(self,uid,activity_id,truename,sex,tel):
		has_attend = ActivitySignUpModel().judge_have_attend(uid,activity_id)
		if int(has_attend): return "您已经报过名了"
		else:
			ActivityInfoModel().incr_attend_num(activity_id)
			ActivitySignUpModel().attend_activity(activity_id,uid,truename,tel,sex)
			avatar = UsersModel().get_import_user_info(uid,['avatar'])['avatar']
			url_req = options.ipnet + ':8088/napi/userSignUpActivity.shtml?uid=%s&aid=%s' % (uid,activity_id)
			result = PublicFunc.do_curl_get(url_req)
			return True
Exemplo n.º 44
0
 def get_live_list(self,gid):
 	"""根据赛事id 获取赛事实况列表"""
     if int(gid):
 	   live_list =  self.find_data(['*'],order='time desc',gid=gid,status=0)
     else:
         live_list = self.find_data(['*'],order='time desc',status=0)
 	for index,live in enumerate(live_list):
 	   live_list[index]['pic'] = options.ipnet + live['pic']
 	   live_list[index]['time'] = PublicFunc.stamp_to_YmdHM(live['time'])
     return live_list
Exemplo n.º 45
0
	def get_status_name(self,gstarttime,gendtime,gacceptstart,gacceptend):
		"""
		根据时间参数获取赛事状态
		 gstatusid  0 game start  1 sign start   2 sign not start   3 sign end    4 game end  
		"""
		current_time = PublicFunc.get_current_stamp()
		if current_time > int(gendtime):return 4,"赛事结束"
		elif current_time > int(gstarttime): return 0,"赛事开始"
		elif current_time > int(gacceptend): return 3,"报名结束"
		elif current_time > int(gacceptstart): return 1,"接受报名"
		else: return 2,"报名未开始"
Exemplo n.º 46
0
	def get_note_list(self,code,page):
		"""
		function:获取帖子列表
             置顶的排在前面,第二顺序为发布时间,时间越晚越靠前
		"""
		note_per_page = int(options.note_per_page)
		page = int(page)
		if code:
			note_list = list(self.m_c.find({'status':0,'code':code},{'content':0,'status':0}).sort([('up',-1),('time',-1)]).skip(note_per_page*page).limit(note_per_page))
		else:
			note_list = list(self.m_c.find({'status':0},{'content':0,'status':0}).sort([('up',-1),('time',-1)]).skip(note_per_page*page).limit(note_per_page))
		current_time = PublicFunc.get_current_stamp()
		for note in note_list:
			note['time'] = PublicFunc.time_format_span(note['time'],current_time)
			user_info = UsersModel.get_instance().get_import_user_info(note['uid'],['nickname','avatar'])
			note['avatar'] = user_info['avatar'] 
			note['nickname'] = user_info['nickname'] if user_info['nickname'] else options.default_nick_name
			note['is_up'] = 1 if int(note['up']) else 0 
			del note['up']
			note['note_id'] = str(note['_id'])
			del note['_id']
		return note_list
Exemplo n.º 47
0
 def get_interact(self,comm_id,page):
 	"""直接根据团队id获取这个互动  这块还是先查到这条数据的id 再查找多条数据"""
 	# return [rows for rows in self.m_c.find({search_key:int(id)})]
 	page = int(page)
 	per_page = 10 
 	interact_info = self.m_c.find({'comm_id':comm_id},{'content':1,'time':1,'_id':0,'uid':1}).skip(per_page*page).limit(per_page).sort([('time',-1)])
 	interact_list = [] 
 	current_time = PublicFunc.get_current_stamp()
 	index = page * per_page
 	for info in interact_info:
 		index += 1 
 		info['time'] = PublicFunc.time_format_span(info['time'],current_time)
 		info['index'] = index
 		if not info['uid']:
 			info['avatar'] = 'http://101.200.214.68/Uploads/head.png'
 			info['nickname'] = '游客'
 		else:
 			user_info = UsersModel.get_instance().get_import_user_info(info['uid'],['avatar','username'])
 			info['avatar'] = user_info['avatar']
 			info['nickname'] = user_info['username']
 		del info['uid']
 		interact_list.append(info)
 	return interact_list
Exemplo n.º 48
0
 def attend_community(self,uid,comm_id):
 	""" 
 	function: 加入跑团 
 	author: yinshuai 
 	input param: 
 	         uid:用户id 
 	         comm_id: 跑团主键id
 	return_param: 
 	         True or except 
 	"""
 	uid = int(uid)
 	member_dict = {'uid':uid,'attend_time':PublicFunc.get_current_stamp()}
 	self.m_c.update({'_id':ObjectId(comm_id)},{'$inc':{"member_num":1},'$addToSet':{'comm_member':member_dict}})
 	return True
Exemplo n.º 49
0
	def get_note_info(self,note_id):
		"""
		function: 获取帖子信息 这里在获取帖子的评论的时候,默认获取首页数据
		input param: 
				note_id 帖子id
		"""
		note_basic_info = NoteModel().get_note_info(ObjectId(note_id))#获取帖子基本信息
		note_user_info = UsersModel().get_import_user_info(note_basic_info['uid'],['avatar','nickname'])#获取发帖人信息
		note_basic_info['avatar'] = note_user_info['avatar']
		note_basic_info['nickname'] = note_user_info['nickname']
		note_comm_list = NoteComModel().get_note_comm(note_id,0)#获取评论信息
		note_comm_num = note_basic_info['com_num']
		current_time = PublicFunc.get_current_stamp()
		for comm in note_comm_list:
			comm['comm_id'] = str(comm['_id'])
			user_info = UsersModel().get_import_user_info(comm['uid'],['avatar','nickname'])
			comm['avatar'] = user_info['avatar']
			comm['nicknamefr'] = user_info['nickname'] if user_info['nickname'] else options.default_nick_name
			comm['level'] = note_comm_num
			comm['time'] = PublicFunc.time_format_span(comm['time'],current_time)
			note_comm_num -= 1
			del comm['_id']
			del comm['note_id']
		return note_basic_info,note_comm_list
Exemplo n.º 50
0
	def login(self,tel,password):
		"""
		用户登录接口,登录成功之后要判断mongo里面是否有这个用户了,如果没有的话,新建
		"""
		user_exist = UsersModel().check_tel_register(tel)
		if not user_exist: return 0#用户还没有注册
		login_info  = self.usersmodel.login(tel,password) #mysql  
		if not password == login_info['password']: return 1 #
		#if the user has not clear the token before!! then continue use this token!!
		token = login_info['token']
		if not token:
			token = PublicFunc.create_token(login_info['uid'])
		change_param = {'token':token,'login_times':login_info['login_times']+1,'last_login':int(time.time())}
		self.usersmodel.update_db(change_param,tel=tel)
		self.usersmodel.clear_user_cache(login_info['uid'])
		self.usersmodel.cache_import_user_info(login_info['uid'])
		bind_layer_show = 1 if self.usersmodel.judge_show_bind_layer(login_info['uid']) else 0
		return token,login_info['uid'],bind_layer_show
Exemplo n.º 51
0
	def add_following(self,uid,fuid):
		"""
		添加自己关注的人
		input param: 
				uid:用户id    
				fuid: 关注的人的id
		"""
		uid = int(uid)
		fuid = int(fuid)
		following_info = self.m_c.find_one({'uid':uid,'status':0},{'_id':0,'following_list':1})
		if not following_info or len(following_info['following_list']) < self.following_save_num:
			self.m_c.update({'uid':uid,'status':0},{"$inc":{"following_num":1},"$push":{"following_list":{'uid':fuid,'time':PublicFunc.get_current_stamp()}}},True)
		else:
			following_list = following_info['following_list']
			following_list.insert(0,{'uid':fuid,'time':PublicFunc.get_current_stamp()})
			following_list = following_list[0:self.following_save_num]
			self.m_c.update({'uid':uid,'status':0},{"$inc":{"following_num":1},"$set":{"following_list":following_list}})
		return True