示例#1
0
def get_template(request):
    count_per_page = int(request.GET.get('count_per_page', 15))
    cur_page = int(request.GET.get('page', '1'))
    
    templates = MarketToolsTemplateMessageDetail.objects.filter(owner=request.user)
    pageinfo, templates = paginator.paginate(templates, cur_page, count_per_page, query_string=request.META['QUERY_STRING'])
    template_ids = [t.template_message_id for t in templates]
    messages = MarketToolsTemplateMessage.objects.filter(id__in=template_ids)
    id2template = {}
    for message in messages:
        id2template[message.id] = message
    items = []
    for template in templates:
        item = {}
        template_message_id = template.template_message_id
        item['template_detail_id'] = template.id
        item['template_id'] = template.template_id
        item['title'] = id2template[template_message_id].title
        item['industry_name'] = TYPE2INDUSTRY.get(id2template[template_message_id].industry, '')
        if template.status == 1:
            item['status'] = u'已启用'
        else:
            item['status'] = u'未启用'
        if template.type == 0:
            item['type'] = u'主营行业'
        else:
            item['type'] = u'副营行业'
        items.append(item)
    response = create_response(200)
    response.data.items = items
    response.data.pageinfo = paginator.to_dict(pageinfo)
    response.data.sortAttr = ''
        
    return response.get_response()
示例#2
0
	def api_get(request):
		member_id = request.GET.get('mid')

		cards = mall_models.MemberHasCard.objects.filter(
			member_id=member_id,
			is_deleted=False
		).order_by('-id')

		#进行分页
		count_per_page = int(request.GET.get('count_per_page', COUNT_PER_PAGE))
		cur_page = int(request.GET.get('page', '1'))
		pageinfo, cards = paginator.paginate(cards, cur_page, count_per_page)

		items = []
		for card in cards:
			items.append({
				'id': card.id,
				'bank_name': card.bank_name,
				'card_number': card.card_number,
				'valid_time': card.valid_time
			})

		response_data = {
			'items': items,
			'pageinfo': paginator.to_dict(pageinfo),
			'sortAttr': 'id'
		}

		response = create_response(200)
		response.data = response_data
		return response.get_response()
示例#3
0
	def api_get(request):
		#获取业务数据
		cur_page = request.GET.get('page', 1)
		users = User.objects.filter(is_active=True, id__gt=3).order_by('-id')
		users = db_util.filter_query_set(users, request, filter2field)
		pageinfo, users = paginator.paginate(users, cur_page, COUNT_PER_PAGE)

		user_ids = [user.id for user in users]
		accounts = UserProfile.objects.filter(user_id__in=user_ids)
		user_id2AppStatus = {account.user_id: account.app_status for account in accounts}
		user_id2Status = {account.user_id: account.status for account in accounts}
		#组装数据
		rows = []
		for user in users:
			rows.append({
				'id': user.id,
				'username': user.username,
				'displayName': user.first_name,
				'createdAt': user.date_joined.strftime('%Y-%m-%d %H:%M'),
				'AppStatus': APP_STATUS2NAME[user_id2AppStatus[user.id]],
				'status': user_id2Status[user.id]
			})
		data = {
			'rows': rows,
			'pagination_info': pageinfo.to_dict()
		}

		#构造response
		response = create_response(200)
		response.data = data

		return response.get_response()
示例#4
0
	def get_datas(request):
		name = request.GET.get('name', '')
		status = int(request.GET.get('status', -1))
		start_time = request.GET.get('start_time', '')
		end_time = request.GET.get('end_time', '')
		__STRIPPER_TAG__
		now_time = datetime.today().strftime('%Y-%m-%d %H:%M')
		params = {'owner_id':request.manager.id}
		datas_datas = app_models.{{resource.item_class_name}}.objects(**params)
		for data_data in datas_datas:
			data_start_time = data_data.start_time.strftime('%Y-%m-%d %H:%M')
			data_end_time = data_data.end_time.strftime('%Y-%m-%d %H:%M')
			if data_start_time <= now_time and now_time < data_end_time:
				data_data.update(set__status=app_models.STATUS_RUNNING)
			elif now_time >= data_end_time:
				data_data.update(set__status=app_models.STATUS_STOPED)
		if name:
			params['name__icontains'] = name
		if status != -1:
			params['status'] = status
		if start_time:
			params['start_time__gte'] = start_time
		if end_time:
			params['end_time__lte'] = end_time
		datas = app_models.{{resource.item_class_name}}.objects(**params).order_by('-id')	
		__STRIPPER_TAG__
		#进行分页
		count_per_page = int(request.GET.get('count_per_page', COUNT_PER_PAGE))
		cur_page = int(request.GET.get('page', '1'))
		pageinfo, datas = paginator.paginate(datas, cur_page, count_per_page, query_string=request.META['QUERY_STRING'])
		__STRIPPER_TAG__
		return pageinfo, datas
示例#5
0
    def api_get(request):
        #获取业务数据
        project_id = request.GET['project_id']
        cur_page = request.GET.get('page', 1)
        tasks = models.Task.objects.filter(project_id=project_id,
                                           is_deleted=False,
                                           type=models.TASK_TYPE_REQUIREMENT)
        tasks = db_util.filter_query_set(tasks, request)
        tasks = tasks.order_by('-id')
        pageinfo, tasks = paginator.paginate(tasks, cur_page, COUNT_PER_PAGE)

        #组装数据
        rows = []
        for task in tasks:
            task_creater = task.creater
            rows.append({
                'id': task.id,
                'title': task.title,
                'importance': task.importance,
                'storyPoint': task.story_point,
                'creater': {
                    "id": task_creater.id,
                    "name": task_creater.name,
                    "thumbnail": task_creater.thumbnail
                },
                'tags': [],
                'createdAt': task.created_at.strftime('%Y.%m.%d')
            })
        data = {'rows': rows, 'pagination_info': pageinfo.to_dict()}

        #构造response
        response = create_response(200)
        response.data = data

        return response.get_response()
示例#6
0
 def api_get(request):
     webapp_id = request.user_profile.webapp_id
     member_id = request.GET.get('member_id', None)
     cur_page = int(request.GET.get('page', '1'))
     count = int(request.GET.get('count_per_page', COUNT_PER_PAGE))
     shared_url_infos = []
     if member_id:
         member = Member.objects.get(id=member_id, webapp_id=webapp_id)
         shared_url_infos = get_member_shared_urls(member)
     pageinfo, shared_url_infos = paginator.paginate(
         shared_url_infos, cur_page, count)
     items = []
     for shared_url_info in shared_url_infos:
         items.append({
             "id": shared_url_info.id,
             "title": shared_url_info.title,
             "pv": shared_url_info.pv,
             "followers": shared_url_info.followers,
             "leadto_buy_count": shared_url_info.leadto_buy_count,
         })
     response = create_response(200)
     response.data = {
         'items': items,
         'pageinfo': paginator.to_dict(pageinfo)
     }
     return response.get_response()
示例#7
0
def get_integral_adjust_accounts(request):
	count_per_page = int(request.GET.get('count_per_page', '1'))
	cur_page = int(request.GET.get('page', '1'))
	items = []
	user_profile = UserProfile.objects.get(user_id=request.GET.get('user_id'))
	group_datas = Order.by_webapp_id(user_profile.webapp_id).filter(status__gte=2).values('integral_each_yuan').annotate(count=Count('integral_each_yuan'))
	webapp_id = user_profile.webapp_id
	for group_data in group_datas:
		integral_each_yuan = group_data['integral_each_yuan']
		if integral_each_yuan and int(integral_each_yuan) != -1:
			integral_count = Order.by_webapp_id(webapp_id).filter(status__gte=2, integral_each_yuan=integral_each_yuan).aggregate(Sum('integral'))
			integral_sum = 0
			if integral_count["integral__sum"] is not None:
				integral_sum = integral_count["integral__sum"]

			integral_money_sums = Order.by_webapp_id(webapp_id).filter(status__gte=2, integral_each_yuan=integral_each_yuan).aggregate(Sum('integral_money'))
			integral_money_sum = 0.00
			if integral_money_sums["integral_money__sum"] is not None:
				integral_money_sum = integral_money_sums["integral_money__sum"]

			items.append({
				'integral_each_yuan': integral_each_yuan,
				'integral': integral_sum,
				'integral_money_sum': '%.2f' %  integral_money_sum
			})

	pageinfo, items = paginator.paginate(items, cur_page, count_per_page, query_string=request.META['QUERY_STRING'])	

	response = create_response(200)
	response.data.pageinfo = paginator.to_dict(pageinfo)
	response.data.items = items
	return response.get_response()
示例#8
0
def get_accounts(request):
	response = create_response(200)
	card_has_accounts = WeizoomCardHasAccount.get_all_weizoom_card_accounts(request.user)

	count_per_page = int(request.GET.get('count_per_page', 15))
	cur_page = int(request.GET.get('page', '1'))
	pageinfo, card_has_accounts = paginator.paginate(card_has_accounts, cur_page, count_per_page, query_string=request.META['QUERY_STRING'])	
	
	account_ids = [c.account_id for c in card_has_accounts]
	users = User.objects.filter(id__in=account_ids)
	id2users = {}
	for user in users:
		id2users[user.id] = user
	
	items = []
	for card_has_account in card_has_accounts:
		account_id = card_has_account.account_id 
		items.append({
			'id': card_has_account.id,
			'account_id': account_id,
			'username': id2users.get(account_id, '').username,
			'nickname': card_has_account.account_name
		})
	
	response.data.items = items
	response.data.pageinfo = paginator.to_dict(pageinfo)
	response.data.sortAttr = request.GET.get('sort_attr', '-created_at')
		
	return response.get_response()
示例#9
0
def get_weizoom_card_rules(request):
	count_per_page = int(request.GET.get('count_per_page', '1'))
	cur_page = int(request.GET.get('page', '1'))
	weizoom_card_rule_id = int(request.GET.get('weizoom_card_rule_id', '-1'))
	
	weizoom_card_rules = WeizoomCardRule.objects.filter(owner=request.user).order_by('-created_at')
	pageinfo, weizoom_card_rules = paginator.paginate(weizoom_card_rules, cur_page, count_per_page, query_string=request.META['QUERY_STRING'])	
	
	cur_weizoom_card_rules = []
	for c in weizoom_card_rules:
		cur_weizoom_card_rule = JsonResponse()
		cur_weizoom_card_rule.id = c.id
		cur_weizoom_card_rule.name = c.name
		cur_weizoom_card_rule.count = c.count
		cur_weizoom_card_rule.remark = c.remark
		cur_weizoom_card_rule.money = '%.2f' % c.money
		cur_weizoom_card_rule.expired_time = datetime.strftime(c.expired_time, '%Y-%m-%d %H:%M')
		cur_weizoom_card_rule.created_at = datetime.strftime(c.created_at, '%Y-%m-%d %H:%M')
		cur_weizoom_card_rules.append(cur_weizoom_card_rule)
		
	response = create_response(200)
	response.data.items = cur_weizoom_card_rules
	response.data.sortAttr = request.GET.get('sort_attr', '-created_at')
	response.data.pageinfo = paginator.to_dict(pageinfo)
	
	return response.get_response()
示例#10
0
    def get_datas(request):
        name = request.GET.get('participant_name', '')
        webapp_id = request.user_profile.webapp_id
        member_ids = []
        if name:
            hexstr = byte_to_hex(name)
            members = member_models.Member.objects.filter(
                webapp_id=webapp_id, username_hexstr__contains=hexstr)
            temp_ids = [member.id for member in members]
            member_ids = temp_ids if temp_ids else [-1]
        # webapp_user_ids = [webapp_user.id for webapp_user in member_models.WebAppUser.objects.filter(member_id__in=member_ids)]
        start_time = request.GET.get('start_time', '')
        end_time = request.GET.get('end_time', '')
        params = {'belong_to': request.GET['id']}
        if member_ids:
            params['member_id__in'] = member_ids
        if start_time:
            params['created_at__gte'] = start_time
        if end_time:
            params['created_at__lte'] = end_time
        datas = app_models.exsurveyParticipance.objects(
            **params).order_by('-id')

        #进行分页
        count_per_page = int(request.GET.get('count_per_page', COUNT_PER_PAGE))
        cur_page = int(request.GET.get('page', '1'))
        pageinfo, datas = paginator.paginate(
            datas,
            cur_page,
            count_per_page,
            query_string=request.META['QUERY_STRING'])

        return pageinfo, datas
示例#11
0
    def api_get(request):
        filter_name = request.GET.get('filter_name', '')
        categories = mall_models.ProductCategory.objects.filter(
            owner=request.manager)
        if filter_name:
            categories = categories.filter(name__contains=filter_name)
        count_per_page = int(request.GET.get('count_per_page', 10))
        cur_page = int(request.GET.get('page', '1'))
        pageinfo, categories = paginator.paginate(
            categories,
            cur_page,
            count_per_page,
            query_string=request.META['QUERY_STRING'])

        items = []
        for category in categories:
            data = {
                'id': category.id,
                'name': category.name,
                'created_at': category.created_at.strftime("%Y-%m-%d %H:%M")
            }
            items.append(data)

        response = create_response(200)
        response.data = {
            'items': items,
            'pageinfo': paginator.to_dict(pageinfo),
            'sortAttr': '',
            'data': {}
        }
        return response.get_response()
示例#12
0
def get_store(request):
	count_per_page = int(request.GET.get('count_per_page', '1'))
	cur_page = int(request.GET.get('page', '1'))

	filter_attr = request.GET.get('filter_attr')
	if filter_attr == 'city':
		stores =Store.objects.filter(owner=request.user, city=request.GET.get('filter_value')).order_by('-created_at')
	else:
		stores = Store.objects.filter(owner=request.user).order_by('-created_at')
	
	pageinfo, stores = paginator.paginate(stores, cur_page, count_per_page, query_string=request.META['QUERY_STRING'])	
	
	cur_stores = []
	for c in stores:
		cur_store = JsonResponse()
		cur_store.id = c.id
		cur_store.name = c.name
		cur_store.city = c.city
		cur_store.created_at = datetime.strftime(c.created_at, '%Y-%m-%d %H:%M')
		cur_stores.append(cur_store)

	cur_citys = list(Store.objects.filter(owner=request.user).values('city').distinct())

	response = create_response(200)
	response.data.items = cur_stores
	response.data.all_city = cur_citys
	response.data.sortAttr = request.GET.get('sort_attr', '-created_at')
	response.data.pageinfo = paginator.to_dict(pageinfo)
	
	return response.get_response()
示例#13
0
def __get_request_members_list(request, webapp_id):
	#获取当前页数
	cur_page = int(request.GET.get('page', '1'))
	#获取每页个数
	count = int(request.GET.get('count_per_page', COUNT_PER_PAGE))
	#处理排序
	#sort_attr = request.GET.get('sort_attr', '-created_at')

	# filter_attr = request.GET.get('filter_attr', None)
	search_type = request.GET.get('search_type', '0')
	start_time = request.GET.get('start_time', None)
	end_time = request.GET.get('end_time', None)
	if int(search_type) == 0:
		if start_time and end_time:
			members = Member.objects.filter(webapp_id=webapp_id, is_for_test=False, update_time__gte=start_time, update_time__lt=end_time)
			total_count = members.count()
		
		elif start_time:
			members = Member.objects.filter(webapp_id=webapp_id, is_for_test=False, update_time__gte=start_time)
			total_count = members.count()

		elif end_time:
			members = Member.objects.filter(webapp_id=webapp_id, is_for_test=False, update_time__lt=end_time)
			total_count = members.count()
		else:
			members = Member.objects.filter(webapp_id=webapp_id, is_for_test=False)
			total_count = members.count()
	else:
		members = Member.objects.filter(webapp_id=webapp_id, is_for_test=False)
		total_count = members.count()

	pageinfo, members = paginator.paginate(members, cur_page, count, query_string=request.GET.get('query', None))

	return pageinfo, list(members), total_count
示例#14
0
def get_member_logs(request):
	member_id = request.GET.get('member_id', '')
	if member_id:
		member_logs = MemberIntegralLog.objects.filter(member_id=member_id).order_by('-id')
	else:
		member_logs = ''

	#进行分页
	count_per_page = int(request.GET.get('count_per_page', 10))
	cur_page = int(request.GET.get('page', '1'))
	pageinfo, member_logs = paginator.paginate(member_logs, cur_page, count_per_page, query_string=request.META['QUERY_STRING'])
	data = []
	for log in member_logs:
		data.append(
			{'event_type': log.event_type,
			'integral_count': log.integral_count,
			'created_at': log.created_at.strftime('%Y/%m/%d %H:%M:%S'),
			'manager': log.manager,
			'reason': log.reason,
			'current_integral': log.current_integral
			})

	response = create_response(200)
	response.data = {
		'items': data,
		'pageinfo': paginator.to_dict(pageinfo),
	}

	return response.get_response()
	def get_datas(request):
		name = request.GET.get('participant_name', '')
		webapp_id = request.user_profile.webapp_id
		member_ids = []
		if name:
			hexstr = byte_to_hex(name)
			members = member_models.Member.objects.filter(webapp_id=webapp_id,username_hexstr__contains=hexstr)
			member_ids = [member.id for member in members]

		start_time = request.GET.get('start_time', '')
		end_time = request.GET.get('end_time', '')
		__STRIPPER_TAG__
		params = {'belong_to':request.GET['id']}
		if name:
			params['webapp_user_id__in'] = member_ids
		if start_time:
			params['created_at__gte'] = start_time
		if end_time:
			params['created_at__lte'] = end_time
		datas = app_models.{{resource.item_class_name}}.objects(**params).order_by('-id')	
		__STRIPPER_TAG__
		#进行分页
		count_per_page = int(request.GET.get('count_per_page', COUNT_PER_PAGE))
		cur_page = int(request.GET.get('page', '1'))
		pageinfo, datas = paginator.paginate(datas, cur_page, count_per_page, query_string=request.META['QUERY_STRING'])
		__STRIPPER_TAG__
		return pageinfo, datas
示例#16
0
def get_newses(request):
    materials = Material.objects.filter(
        owner=request.user, is_deleted=False).order_by('-created_at')
    cur_page = request.GET.get('page', 1)
    count_per_page = request.GET.get('count_per_page', 20)
    response = create_response(200)
    if not cur_page == "0":
        pageinfo, materials = paginator.paginate(
            materials,
            cur_page,
            count_per_page,
            query_string=request.META['QUERY_STRING'])
        response.data.pageinfo = paginator.to_dict(pageinfo)
    else:
        pass

    material_ids = [m.id for m in materials]
    id2material = __get_materials(material_ids)
    newses = []
    for id in material_ids:
        data = dict()
        data['id'] = id
        data['newses'] = id2material[id]
        if len(data['newses']) == 0:
            #空素材,略过
            pass
        else:
            newses.append(data)

    response.data.items = newses

    return response.get_response()
示例#17
0
def get_red_envelopes(request):
    red_envelopes = RedEnvelope.objects.filter(owner=request.user,
                                               is_deleted=False)
    response = create_response(200)

    #进行分页
    count_per_page = int(request.GET.get('count_per_page', 15))
    cur_page = int(request.GET.get('page', '1'))
    pageinfo, red_envelopes = paginator.paginate(
        red_envelopes,
        cur_page,
        count_per_page,
        query_string=request.META['QUERY_STRING'])

    response.data.items = []
    for red_envelope in red_envelopes:
        cur_red_envelope = JsonResponse()
        cur_red_envelope.id = red_envelope.id
        cur_red_envelope.name = red_envelope.name
        response.data.items.append(cur_red_envelope)

    response.data.pageinfo = paginator.to_dict(pageinfo)
    response.data.sortAttr = request.GET.get('sort_attr', '-created_at')

    return response.get_response()
示例#18
0
    def api_get(request):
        """
        """
        notices = notices_models.Notice.objects.all().order_by('-id')
        notices_json = []
        # 进行分页
        count_per_page = int(request.GET.get('count_per_page', 4))
        cur_page = int(request.GET.get('page', '1'))
        pageinfo, notices = paginator.paginate(
            list(notices),
            cur_page,
            count_per_page,
            query_string=request.META['QUERY_STRING'])
        for notice in notices:
            dict_notice = notice.to_dict()
            dict_notice['created_at'] = notice.created_at.strftime('%Y-%m-%d')
            notices_json.append(dict_notice)

        response = create_response(200)

        response.data = {
            'items': notices_json,
            'pageinfo': paginator.to_dict(pageinfo),
            'sortAttr': '',
            'data': {},
        }
        return response.get_response()
示例#19
0
    def api_get(request):
        cur_page = int(request.GET.get('page', '1'))
        count_per_page = 10
        # 处理排序
        sort_attr = request.GET .get('sort_attr', None);
        name = request.GET.get('name', None);
        if not sort_attr:
            sort_attr = '-created_at'
        if not name:
            suppliers = list(Supplier.objects.filter(owner_id=request.manager.id).filter(is_delete=False).order_by('-id'))
        else:
            suppliers = list(Supplier.objects.filter(owner_id=request.manager.id).filter(name__contains=name).filter(is_delete=False).order_by('-id'))

        pageinfo, part_suppliers = paginator.paginate(suppliers, cur_page, count_per_page,
                                                         query_string=request.META['QUERY_STRING'])
        result_supplier = []
        for supplier in part_suppliers:
            result_supplier.append({
                "id": supplier.id,
                "name": supplier.name,
                "responsible_person": supplier.responsible_person,
                "supplier_tel": supplier.supplier_tel,
                "supplier_address": supplier.supplier_address,
                "create_at": datetime.strftime(supplier.created_at, '%Y-%m-%d %H:%M'),
                "remark": supplier.remark
            })


        response = create_response(200)
        response.data = {
            'items': result_supplier,
            'pageinfo': paginator.to_dict(pageinfo),
            'sortAttr': sort_attr
        }
        return response.get_response()
示例#20
0
	def api_get(request):
		"""
        查询已上架商品
        """
		product_name = request.GET.get('product_name','')
		bar_code = request.GET.get('bar_code', '')

		owner_id = request.manager.id

		#过滤掉已经关联过的商品
		related_products = app_models.EvaluatesRelatedProducts.objects()
		related_products_ids = [p.product_id for p in related_products]

		#查询
		param = {
			'owner_id': owner_id
		}
		if product_name:
			param['name__icontains'] = product_name
		if bar_code:
			param['bar_code__icontains'] = bar_code

		products = mall_models.Product.objects.exclude(id__in = related_products_ids).filter(**param).order_by('-created_at')
		EvaluatesProducts.fill_display_price(products)

		# 分页
		count_per_page = int(request.GET.get('count_per_page', COUNT_PER_PAGE))
		current_page = int(request.GET.get('page', '1'))
		pageinfo, products = paginator.paginate(products, current_page,count_per_page,
																		 query_string=request.META['QUERY_STRING'])

		evaluates = app_models.ProductEvaluates.objects(owner_id=owner_id).order_by("-created_at")
		#构造商品对应的评价数映射
		product_id2evaluate_count = {}
		for evaluate in evaluates:
			product_id = evaluate.product_id
			if product_id in product_id2evaluate_count:
				product_id2evaluate_count[product_id] += 1
			else:
				product_id2evaluate_count[product_id] = 1

		items = []
		for product in products:
			product_id = product.id
			items.append({
				'id': product_id,
				'bar_code': product.bar_code,
				'product_name': product.name,
				'price': product.display_price,
				'evaluate_count': product_id2evaluate_count.get(product_id,0)
			})

		response = create_response(200)
		response.data = {
			'items': items,
			'pageinfo': paginator.to_dict(pageinfo),
			'sortAttr': '',
			'data': {}
		}
		return response.get_response()
示例#21
0
def get_records(request):
	user = request.user.get_profile()
	records = ShakeRecord.objects.filter(owner=request.user).order_by('-created_at')
	
	#进行分页
	count_per_page = int(request.GET.get('count_per_page', 15))
	cur_page = int(request.GET.get('page', '1'))
	pageinfo, records = paginator.paginate(records, cur_page, count_per_page, query_string=request.META['QUERY_STRING'])	
		
	response = create_response(200)
	
	response.data.items = []
	for record in records:
		member = record.member
		one_record = JsonResponse()
		if member:
			one_record.username = member.username_for_html
			one_record.user_id = member.id
		else:
			one_record.username = u'未知'
			one_record.user_id = 0

		one_record.money = str(record.money)
		one_record.name = record.shake_detail.shake.name
		one_record.is_sended = record.is_sended
		one_record.created_at = record.created_at.strftime('%Y-%m-%d %H:%M:%S')
		one_record.id = record.id
		response.data.items.append(one_record)
	
	response.data.pageinfo = paginator.to_dict(pageinfo)
	response.data.sortAttr = request.GET.get('sort_attr', '-created_at')
	return response.get_response()
示例#22
0
文件: views.py 项目: chengdg/weizoom
def get_complain(request):
    complains = MemberComplainRecord.objects.filter(
        complain_settings__owner=request.user).order_by('-created_at')
    cur_page = int(request.GET.get('page', '1'))

    for complain in complains:
        if complain.webapp_user_id != -1:
            try:
                member = WebAppUser.get_member_by_webapp_user_id(
                    complain.webapp_user_id)
                if member and member.is_for_test == False:
                    complain.member_username = member.username_for_html
                    complain.member_id = member.id
                else:
                    complain.member_username = u'非会员'
            except:
                complain.member_username = u'非会员'
        else:
            complain.member_username = u'非会员'

    pageinfo, complains = paginator.paginate(
        complains,
        cur_page,
        COUNT_PER_PAGE,
        query_string=request.META['QUERY_STRING'])

    c = RequestContext(
        request, {
            'first_nav_name': FIRST_NAV_NAME,
            'second_navs': export.get_second_navs(request),
            'second_nav_name': SECOND_NAV_NAME,
            'complains': complains,
            'pageinfo': json.dumps(paginator.to_dict(pageinfo)),
        })
    return render_to_response('complain/editor/member_complain_list.html', c)
示例#23
0
def mui_get_session_histories(request):
    session_id = request.GET['s_id']
    current_page = int(request.GET.get('cur_page', '1'))
    count = int(request.GET.get('count', 10))
    isManager = request.GET.get('isManager', 'false')
    isSystemMenager = request.GET.get('isSystemMenager', 'false')
    # user_id = request.GET['user_id']
    session = Session.objects.get(id=session_id)
    messages = Message.objects.filter(session=session_id).order_by('-id')
    #进行分页
    pageinfo, messages = paginator.paginate(messages, current_page, count)

    sender_usernames = [m.from_weixin_user_username for m in messages]
    recevier_usernames = [m.to_weixin_user_username for m in messages]
    weixin_user_usernames = set(sender_usernames + recevier_usernames)
    weixin_users = WeixinUser.objects.filter(
        username__in=weixin_user_usernames)
    username2weixin_user = dict([u.username, u] for u in weixin_users)

    mpuser = get_system_user_binded_mpuser(request.user)

    try:
        mpuser_preview_info = MpuserPreviewInfo.objects.get(mpuser=mpuser)
    except Exception, e:
        print e.message
        response = create_response(500)
        response.errMsg = u'获取公众号预览信息失败'
        return response.get_jsonp_response(request)
示例#24
0
def get_courses(request):
    shengjing_course_configs = ShengjingCourseConfig.objects.filter(
        owner=request.user).order_by('-update_time')

    count_per_page = int(request.GET.get('count_per_page', 15))
    cur_page = int(request.GET.get('page', '1'))
    pageinfo, shengjing_course_configs = paginator.paginate(
        shengjing_course_configs,
        cur_page,
        count_per_page,
        query_string=request.META['QUERY_STRING'])

    response = create_response(200)
    cur_shengjing_course_configs = []
    for config in shengjing_course_configs:
        cur_course_config = JsonResponse()
        cur_course_config.id = config.id
        cur_course_config.name = config.name
        cur_course_config.created_at = config.created_at.strftime('%Y-%m-%d')
        cur_course_config.update_time = config.update_time.strftime('%Y-%m-%d')
        cur_shengjing_course_configs.append(cur_course_config)

    response.data.items = cur_shengjing_course_configs
    response.data.sortAttr = request.GET.get('sort_attr', '-display_index')
    response.data.pageinfo = paginator.to_dict(pageinfo)

    return response.get_response()
示例#25
0
    def api_get(request):
        self_shops = models.SelfShops.objects.filter(
            is_deleted=False).order_by('-created_at')
        cur_page = request.GET.get('page', 1)
        pageinfo, self_shops = paginator.paginate(
            self_shops,
            cur_page,
            COUNT_PER_PAGE,
            query_string=request.META['QUERY_STRING'])

        that_rows, store_name2id = get_self_shops_dict('all')
        rows = []
        for self_shop in self_shops:

            # self_shop_id = store_name2id.get(self_shop.weapp_user_id)
            rows.append({
                'selfShopId': self_shop.weapp_user_id,
                'selfShopName': self_shop.self_shop_name,
                'userName': self_shop.weapp_user_id,
                'settlementType': self_shop.settlement_type,
                'splitRatio': self_shop.split_atio,
                'riskMoney': self_shop.risk_money,
                'remark': self_shop.remark,
                'isSynced': self_shop.is_synced,
                'corpAccount': self_shop.corp_account
            })
        data = {'rows': rows, 'pagination_info': pageinfo.to_dict()}

        response = create_response(200)
        response.data = data
        return response.get_response()
示例#26
0
def get_messages_from_messages(user,
                               user_profile,
                               cur_page,
                               count,
                               content=None,
                               start_time=None,
                               end_time=None,
                               filter_items=None,
                               query_string=None):
    mpuser = get_system_user_binded_mpuser(user)
    if mpuser is None:
        return []

    messages = Message.objects.filter(mpuser=mpuser)
    if content:
        messages = messages.filter(content__contains=content)
    if start_time and end_time:
        messages = messages.filter(weixin_created_at__gte=start_time,
                                   weixin_created_at__lte=end_time)
    messages = messages.filter(is_reply=False)
    messages = get_message_detail_items(user, user_profile.webapp_id, messages,
                                        filter_items)
    pageinfo, messages = paginator.paginate(messages,
                                            cur_page,
                                            count,
                                            query_string=query_string)

    return pageinfo, messages
示例#27
0
文件: rebate.py 项目: chengdg/weizoom
	def api_get(request):
		"""
		查看微众卡使用详情
		"""
		cur_page = int(request.GET.get('page',1))
		count_per_page = int(request.GET.get('count_per_page',10))

		rebate_cards = RebateCardDetails.get_rebate_cards(request)
		pageinfo, rebate_cards = paginator.paginate(rebate_cards, cur_page, count_per_page, query_string=request.META['QUERY_STRING'])
		member_ids = [rebate_card.member_id for rebate_card in rebate_cards]
		members = member_models.Member.objects.filter(id__in=member_ids)
		rebate_cards_list = []
		for card in rebate_cards:
			try:
				username = members.get(id=card.member_id).username_for_html
			except:
				username = u'未知'
			try:
				rebate_cards_list.append({
					'card_number': card.card_number,
					'card_password': decrypt_password(card.card_password),
					'username': username
				})
			except Exception,e:
				print(e)
				response = create_response(500)
				return response.get_response()
示例#28
0
def get_weizoom_cards(request):
	count_per_page = int(request.GET.get('count_per_page', '1'))
	cur_page = int(request.GET.get('page', '1'))
	weizoom_card_rule_id = int(request.GET.get('weizoom_card_rule_id', '-1'))
	query = request.GET.get('query', None)
	weizoom_cards = WeizoomCard.objects.filter(owner=request.user, weizoom_card_rule_id=weizoom_card_rule_id)
	#获得已经过期的微众卡id
	today = datetime.today()
	card_ids_need_expire = []
	for card in weizoom_cards:
		#记录过期并且是未使用的微众卡id
		if card.expired_time < today:
			card_ids_need_expire.append(card.id)
	
	if len(card_ids_need_expire) > 0:
		WeizoomCard.objects.filter(id__in=card_ids_need_expire).update(is_expired=True)
	
	#处理过滤
	filter_attr = request.GET.get('filter_attr', None)
	filter_value = int(request.GET.get('filter_value', -1))
	if filter_attr and (filter_value != -1):
		params = {filter_attr: filter_value}
		weizoom_cards = weizoom_cards.filter(**params)
		
	if query:
		weizoom_cards = weizoom_cards.filter(weizoom_card_id=query)
	
	pageinfo, weizoom_cards = paginator.paginate(weizoom_cards, cur_page, count_per_page, query_string=request.META['QUERY_STRING'])	
	target_user_ids = []
	for weizoom_card in weizoom_cards:
		target_user_ids.append(weizoom_card.target_user_id)
	card_has_accounts = WeizoomCardHasAccount.objects.filter(owner=request.user, account__in=target_user_ids)
	user2name = {}
	for card_has_account in card_has_accounts:
		user2name[card_has_account.account_id] = card_has_account.account_name
	
	cur_weizoom_cards = []
	for c in weizoom_cards:
		cur_weizoom_card = JsonResponse()
		cur_weizoom_card.id = c.id
		cur_weizoom_card.status = c.status
		cur_weizoom_card.weizoom_card_id = c.weizoom_card_id
		cur_weizoom_card.password = c.password
		cur_weizoom_card.money = '%.2f' % c.money
		if c.activated_at:
			cur_weizoom_card.activated_at = c.activated_at.strftime('%Y-%m-%d %H:%M:%S')
		else:
			cur_weizoom_card.activated_at = ''
		cur_weizoom_card.target_name = user2name.get(c.target_user_id, u'')
		cur_weizoom_card.is_expired = c.is_expired
		cur_weizoom_cards.append(cur_weizoom_card)
		
	response = create_response(200)
	response.data.items = cur_weizoom_cards
	response.data.sortAttr = request.GET.get('sort_attr', '-created_at')
	response.data.pageinfo = paginator.to_dict(pageinfo)
	
	return response.get_response()
示例#29
0
def get_managers(request):
    count_per_page = int(request.GET.get('count_per_page', '1'))
    cur_page = int(request.GET.get('page', '1'))
    is_manage = 'manage' in request.GET
    if is_manage:
        card_managers = WeiZoomCardManager.objects.all()
    else:
        card_managers = WeiZoomCardManager.objects.exclude(
            user_id=request.user.id)
    pageinfo, card_managers = paginator.paginate(
        card_managers,
        cur_page,
        count_per_page,
        query_string=request.META['QUERY_STRING'])
    weizoomcardpermissions = WeiZoomCardPermission.objects.all()
    card_manager2weizoomcardpermission = {}
    for weizoomcardpermission in weizoomcardpermissions:
        card_manager2weizoomcardpermission[
            weizoomcardpermission.user_id] = weizoomcardpermission
    cur_card_managers = []
    for card_manager in card_managers:
        cur_card_manager = JsonResponse()
        cur_card_manager.id = card_manager.id
        cur_card_manager.user_id = card_manager.user_id
        cur_card_manager.username = card_manager.username
        cur_card_manager.nickname = card_manager.nickname
        try:
            cur_card_manager.can_create_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_create_card
            cur_card_manager.can_export_batch_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_export_batch_card
            cur_card_manager.can_add_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_add_card
            cur_card_manager.can_batch_stop_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_batch_stop_card
            cur_card_manager.can_batch_active_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_batch_active_card
            cur_card_manager.can_view_card_details = card_manager2weizoomcardpermission[
                card_manager.user_id].can_view_card_details
            cur_card_manager.can_stop_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_stop_card
            cur_card_manager.can_active_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_active_card
            cur_card_manager.can_delay_card = card_manager2weizoomcardpermission[
                card_manager.user_id].can_delay_card
            cur_card_manager.can_change_shop_config = card_manager2weizoomcardpermission[
                card_manager.user_id].can_change_shop_config
            cur_card_manager.can_view_statistical_details = card_manager2weizoomcardpermission[
                card_manager.user_id].can_view_statistical_details
            cur_card_manager.can_export_statistical_details = card_manager2weizoomcardpermission[
                card_manager.user_id].can_export_statistical_details
        except:
            pass
        cur_card_managers.append(cur_card_manager)
    response = create_response(200)
    response.data.items = cur_card_managers
    response.data.pageinfo = paginator.to_dict(pageinfo)
    return response.get_response()
示例#30
0
    def api_get(request):
        channel_qrcode_id = int(request.GET['qrcode_id'])
        start_date = request.GET.get('start_date', '')
        end_date = request.GET.get('end_date', '')
        is_show = request.GET.get('is_show', '0')

        sort_attr = request.GET.get('sort_attr', '-created_at')

        if is_show == '1':
            member_ids = [relation.member_id for relation in \
                MemberChannelQrcodeHasMember.objects.filter(member_channel_qrcode_id=channel_qrcode_id, is_new=True)]
        else:
            member_ids = [relation.member_id for relation in \
                MemberChannelQrcodeHasMember.objects.filter(member_channel_qrcode_id=channel_qrcode_id)]

        filter_data_args = {}
        filter_data_args['id__in'] = member_ids

        if start_date:
            filter_data_args['created_at__gte'] = start_date

        if end_date:
            filter_data_args['created_at__lte'] = end_date

        channel_members = member_model.Member.objects.filter(
            **filter_data_args).order_by(sort_attr)
        count_per_page = int(request.GET.get('count_per_page', 15))
        cur_page = int(request.GET.get('page', '1'))
        pageinfo, channel_members = paginator.paginate(
            channel_members,
            cur_page,
            count_per_page,
            query_string=request.META['QUERY_STRING'])

        return_channel_members_json_array = []

        for channel_member in channel_members:
            member_info = member_model.MemberInfo.get_member_info(
                channel_member.id)
            if member_info:
                channel_member.name = member_info.name
            else:
                channel_member.name = ''

            return_channel_members_json_array.append(
                build_member_basic_json(channel_member))

        response = create_response(200)
        response.data = {
            'items': return_channel_members_json_array,
            'pageinfo': paginator.to_dict(pageinfo),
            'sortAttr': sort_attr,
            'data': {}
        }

        return response.get_response()
示例#31
0
文件: views.py 项目: Mark24Code/boom
def list_customers(request):
	page = int(request.GET.get('page', 1))
	count = int(request.GET.get('count_per_page', 20))
	keyword = request.GET.get('keyword', '').strip()
	customers = Customer.objects.filter(owner=request.user)
	if keyword:
		customers = customers.filter(Q(tel_number__icontains=keyword) | Q(plate_number__icontains=keyword) | Q(name__icontains=keyword))
	pageinfo, customers = paginate(customers, page, count, query_string=request.META['QUERY_STRING'])
	c = RequestContext(request, {
		'customers': customers,
		'pageinfo': pageinfo.to_dict(),
		'keyword': keyword
	})
	return render_to_response('account/list_customers.html', c)
示例#32
0
文件: views.py 项目: MrSun24/PT
def get_note_info(request):
	cur_page = int(request.GET.get('cur_page', 1))
	count_per_page = int(request.GET.get('count_per_page', COUNT_PER_PAGE))

	notes = app_model.Note.objects.filter(owner=request.user).order_by('-created_at')

	note_list = []
	for note in notes:
		note_list.append({
			'id': note.id,
			'title': note.title,
			'content': note.content,
			'status': u'未上架' if note.status == 0 else u'已上架',
			'created_at': note.created_at.strftime('%Y-%m-%d %H:%M:%S')
		})
	page_info, note_list = paginate(note_list, cur_page, count_per_page)

	return page_info.to_dict(), note_list
示例#33
0
文件: views.py 项目: MrSun24/PT
def get_personal_bills(request):
	"""
	获取账单
	"""
	cur_page = int(request.GET.get('cur_page', 1))
	count_per_page = int(request.GET.get('count_per_page', COUNT_PER_PAGE))

	person_bills = app_model.PersonalBill.objects.filter(owner=request.user).order_by('-use_time', '-created_at')

	page_info, person_bills = paginate(person_bills, cur_page, count_per_page)

	person_bills_list = []
	for bill in person_bills:
		person_bills_list.append({
			'id': bill.id,
			'usage': bill.usage,
			'money': '%.2f' % bill.money,
			'pay_type_name': app_model.PAY_TYPE[bill.pay_type],
			'pay_type': str(bill.pay_type),
			'use_time': bill.use_time.strftime('%Y-%m-%d')
		})

	return page_info.to_dict(), json.dumps(person_bills_list)