Example #1
0
def john_dc20151026():
    _conditions = ['''user_id in (select user_id from user where assign_operator_id in (SELECT id from operator where team like 'C%'))''']
    _conditions.append("created<'2015-06-01' and created=(SELECT max(created) from `order` as b where `order`.user_id=b.user_id)")
    _data = Order.query.filter(db.and_(*_conditions))
    
    print _data
    return render_template('john/dcd20151026.html',data=_data)
Example #2
0
 def find_is_closed(campus: Campus, day: datetime.date) -> 'Optional[ClosingDays]':
     return ClosingDays.query.filter(db.and_(ClosingDays.campus_id == campus.id,
                                             ClosingDays.first_day <= day,
                                             db.or_(
                                                 ClosingDays.last_day == None,
                                                 ClosingDays.last_day >= day
                                             )
                                             )).first()
Example #3
0
def john_dcg20140915():
    _conditions = [User.user_type==2]
    _conditions.append(User.product_intention == 1)
    pagination = User.query.filter(db.and_(*_conditions)).order_by(desc(User.expect_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=['user_origin','op','user_type','username','phone','show_abandon'])
Example #4
0
 def username_auth(self, uid, password, auth_type=0):
     if password is None:
         return False
     auth = Auth.query.filter(db.and_(
         Auth.uid == uid,
         Auth.auth_type == auth_type
     )).first()
     return auth.auth_hash == hashlib.md5(password).hexdigest()
Example #5
0
 def validate_phone(self, field):
     _user_id = int(self.user_id.data)
     if not _user_id:
         if User.query.filter(User.phone==field.data).first() is not None:
             raise ValidationError(u'电话号码已存在')
     else:
         if User.query.filter(db.and_(User.phone==field.data,User.user_id!=_user_id)).first() is not None:
             raise ValidationError(u'电话号码已存在')
Example #6
0
    def find_subscribed_users_by_day(day: Day, provider=None) -> 'List[AppUser]':
        q = AppUser.query
        if provider:
            q = q.filter_by(provider=provider)

        return q.join(AppUser.subscriptions).filter(db.and_(UserDayCampusPreference.day == day,
                                                            UserDayCampusPreference.active == expression.true(),
                                                            AppUser.enabled == expression.true()
                                                            )).order_by(AppUser.provider, AppUser.internal_id).all()
Example #7
0
def sendSMS():
    '''批量发送短信处理'''
    print 'start to send sms',
    SMS = models.SMS
    _all_sms = SMS.query.filter(db.or_(SMS.status==1,
                                       db.and_(SMS.status==9,SMS.fail_times<=3)))
    for sms in _all_sms:
        print '%d|%d'%(sms.seqid,int(sms.send_sms()))
    print 'complete.'
Example #8
0
def sendSMS():
    '''批量发送短信处理'''
    print 'start to send sms',
    SMS = models.SMS
    _all_sms = SMS.query.filter(
        db.or_(SMS.status == 1, db.and_(SMS.status == 9, SMS.fail_times <= 3)))
    for sms in _all_sms:
        print '%d|%d' % (sms.seqid, int(sms.send_sms()))
    print 'complete.'
Example #9
0
 def find_closing_days_including(campus: Campus,
                                 start_date: datetime.date,
                                 end_date: datetime.date) -> 'List[ClosingDays]':
     return ClosingDays.query.filter(db.and_(ClosingDays.campus_id == campus.id,
                                             ClosingDays.first_day <= end_date,
                                             db.or_(
                                                 ClosingDays.last_day == None,
                                                 ClosingDays.last_day >= start_date
                                             )
                                             )).all()
Example #10
0
def john_dc20141016():
    _conditions = []
    _conditions.append("user.user_type=2 and user.assign_operator_id is not null  and user.product_intention = 0" )
    #_conditions.append("order.team='B1' OR order.team='B2'" )
    #_conditions.append(User.product_intention == 1)
    pagination = User.query.filter(db.and_(*_conditions)).order_by(desc(User.expect_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=['user_origin','op','user_type','username','phone','show_abandon'])
Example #11
0
def john_dc20151026():
    _conditions = [
        '''user_id in (select user_id from user where assign_operator_id in (SELECT id from operator where team like 'C%'))'''
    ]
    _conditions.append(
        "created<'2015-06-01' and created=(SELECT max(created) from `order` as b where `order`.user_id=b.user_id)"
    )
    _data = Order.query.filter(db.and_(*_conditions))

    print _data
    return render_template('john/dcd20151026.html', data=_data)
Example #12
0
def john_dcd20140916():
    _conditions = []
    _conditions.append("user.assign_operator_id in (4,90,113,38,147)" )
    #_conditions.append("order.team='B1' OR order.team='B2'" )
    _conditions.append(User.join_time >= '2014-05-01')
    #_conditions.append(Order.express_number == 2)
    pagination = User.query.filter(db.and_(*_conditions)).order_by(desc(User.expect_time))
    print pagination
    return render_template('john/dcd20140916.html',
                           pagination=pagination,
                           show_queries=['user_origin','op','user_type','username','phone','show_abandon'])
Example #13
0
def john_dcd20140903():
    _conditions = [User.user_type==1]
    _conditions.append(User.origin<>18)
    _conditions.append(User.origin<>11)
    _conditions.append(User.join_time >= '2014-05-01')
    _conditions.append(User.join_time <= '2014-09-01')    
    pagination = User.query.filter(db.and_(*_conditions)).order_by(desc(User.expect_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=['user_origin','op','user_type','username','phone','show_abandon'])
Example #14
0
def john_dcd20140627():
    _conditions = []
    _conditions.append("assign_operator_id in (select id from operator where team='A2')" )
    #_conditions.append("assign_time>0")
    _conditions.append("order_num=0")
    _conditions.append("ADDDATE(assign_time,interval 55 hour)<now()")
    pagination = User.query.filter(db.and_(*_conditions))#.order_by(desc(User.assign_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=['user_origin','op','user_type','username','phone','show_abandon'])
Example #15
0
def john_dcg20140915():
    _conditions = [User.user_type == 2]
    _conditions.append(User.product_intention == 1)
    pagination = User.query.filter(db.and_(*_conditions)).order_by(
        desc(User.expect_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=[
                               'user_origin', 'op', 'user_type', 'username',
                               'phone', 'show_abandon'
                           ])
Example #16
0
def john_dcd20141014():
    _conditions = []
    _conditions.append("(user.assign_operator_id in (4,90,113,38,147) and user.product_intention in (0,2,3,4))")# (0,2,3,4))" )
    #_conditions.append("order.team='B1' OR order.team='B2'" )
    _conditions.append(User.join_time >= '2014-01-01')
    _conditions.append(User.join_time < '2014-05-01')
    #_conditions.append(User.product_intention == 1)
    pagination = User.query.filter(db.and_(*_conditions)).order_by(desc(User.expect_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=['user_origin','op','user_type','username','phone','show_abandon'])
Example #17
0
def john_dc20150106():

    _conditions = []
    _conditions.append(User.user_type == 2)
    _conditions.append(User.join_time >= '2014-06-01')
    _conditions.append(User.join_time < '2015-01-01')
    #_conditions.append(User.product_intention == 1)
    pagination = User.query.filter(db.and_(*_conditions)).order_by(desc(User.expect_time))
    print pagination
    return render_template('john/dcd20150106.html',
                           pagination=pagination,
                           show_queries=['user_origin','op','user_type','username','phone','show_abandon'])
Example #18
0
def john_dc20150212():

    _conditions = []
    _conditions.append("(user.assign_operator_id in (8,40,41,42,43,45,47,48,84,87,154,194,201,210,231,232,227,228,229,219,222,223,224,225) or user.user_type=2)")# (0,2,3,4))" )
    #_conditions.append("order.team='B1' OR order.team='B2'" )
    #_conditions.append(User.user_type == 2)
    #_conditions.append(User.product_intention == 1)
    pagination = User.query.filter(db.and_(*_conditions)).order_by(desc(User.expect_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=['user_origin','op','user_type','username','phone','show_abandon'])
Example #19
0
def john_dcd20140519():
    _conditions = []
    #_conditions.append("user.assign_operator_id in (select id from operator where team='C1' OR team='C2')" )
    _conditions.append("order.team='C1' OR order.team='C2'" )
    _conditions.append(Order.created >= '2014-01-01')
    _conditions.append(Order.created <= '2014-05-01')
    _conditions.append(Order.express_number == 2)
    pagination = User.query.join(Order, Order.user_id == User.user_id).filter(db.and_(*_conditions)).order_by(desc(User.expect_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=['user_origin','op','user_type','username','phone','show_abandon'])
Example #20
0
def john_dcd20140702():
    _conditions = []
    _conditions.append("user.assign_operator_id in (37,39,57,123,59,60,61,85,86,91,124,92,98,102,112,125,135,137)" )
    #_conditions.append("order.team='B1' OR order.team='B2'" )
    #_conditions.append(Order.created >= '2014-01-01')
    #_conditions.append(Order.created <= '2014-05-01')
    #_conditions.append(Order.express_number == 2)
    pagination = User.query.filter(db.and_(*_conditions)).order_by(desc(User.expect_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=['user_origin','op','user_type','username','phone','show_abandon'])
Example #21
0
def john_dc201506122():

    _conditions = []
    _conditions.append("user.origin in (17,18) and user_id in (select user_id from qxhdm_orderyf)" )
    #_conditions.append("(user.assign_operator_id in (8,40,41,42,43,45,47,48,84,87,154,194,201,210,231,232,227,228,229,219,222,223,224,225) or user.user_type=2)")# (0,2,3,4))" )
    #_conditions.append("user.user_type=1" )
    _conditions.append(User.join_time < '2015-03-01')

    pagination = User.query.filter(db.and_(*_conditions)).order_by(desc(User.expect_time))
    print pagination
    return render_template('john/dcd20150612.html',
                           pagination=pagination,
                           show_queries=['user_origin','op','user_type','username','phone','show_abandon'])
Example #22
0
def john_dcd20140903():
    _conditions = [User.user_type == 1]
    _conditions.append(User.origin <> 18)
    _conditions.append(User.origin <> 11)
    _conditions.append(User.join_time >= '2014-05-01')
    _conditions.append(User.join_time <= '2014-09-01')
    pagination = User.query.filter(db.and_(*_conditions)).order_by(
        desc(User.expect_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=[
                               'user_origin', 'op', 'user_type', 'username',
                               'phone', 'show_abandon'
                           ])
Example #23
0
def john_dcd20140916():
    _conditions = []
    _conditions.append("user.assign_operator_id in (4,90,113,38,147)")
    #_conditions.append("order.team='B1' OR order.team='B2'" )
    _conditions.append(User.join_time >= '2014-05-01')
    #_conditions.append(Order.express_number == 2)
    pagination = User.query.filter(db.and_(*_conditions)).order_by(
        desc(User.expect_time))
    print pagination
    return render_template('john/dcd20140916.html',
                           pagination=pagination,
                           show_queries=[
                               'user_origin', 'op', 'user_type', 'username',
                               'phone', 'show_abandon'
                           ])
Example #24
0
def john_dc20141016():
    _conditions = []
    _conditions.append(
        "user.user_type=2 and user.assign_operator_id is not null  and user.product_intention = 0"
    )
    #_conditions.append("order.team='B1' OR order.team='B2'" )
    #_conditions.append(User.product_intention == 1)
    pagination = User.query.filter(db.and_(*_conditions)).order_by(
        desc(User.expect_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=[
                               'user_origin', 'op', 'user_type', 'username',
                               'phone', 'show_abandon'
                           ])
Example #25
0
def john_dc20150106():

    _conditions = []
    _conditions.append(User.user_type == 2)
    _conditions.append(User.join_time >= '2014-06-01')
    _conditions.append(User.join_time < '2015-01-01')
    #_conditions.append(User.product_intention == 1)
    pagination = User.query.filter(db.and_(*_conditions)).order_by(
        desc(User.expect_time))
    print pagination
    return render_template('john/dcd20150106.html',
                           pagination=pagination,
                           show_queries=[
                               'user_origin', 'op', 'user_type', 'username',
                               'phone', 'show_abandon'
                           ])
Example #26
0
def john_dcd20140519():
    _conditions = []
    #_conditions.append("user.assign_operator_id in (select id from operator where team='C1' OR team='C2')" )
    _conditions.append("order.team='C1' OR order.team='C2'")
    _conditions.append(Order.created >= '2014-01-01')
    _conditions.append(Order.created <= '2014-05-01')
    _conditions.append(Order.express_number == 2)
    pagination = User.query.join(Order, Order.user_id == User.user_id).filter(
        db.and_(*_conditions)).order_by(desc(User.expect_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=[
                               'user_origin', 'op', 'user_type', 'username',
                               'phone', 'show_abandon'
                           ])
Example #27
0
def john_dc20150429():

    _conditions = []
    #_conditions.append("((user.user_type=2 and user.assign_operator_id is null) or user.assign_operator_id in (select id from operator where team like 'A%' OR  team like 'B%')) and user.product_intention = 1" )
    #_conditions.append("(user.assign_operator_id in (8,40,41,42,43,45,47,48,84,87,154,194,201,210,231,232,227,228,229,219,222,223,224,225) or user.user_type=2)")# (0,2,3,4))" )
    _conditions.append("user.user_type=2" )
    #_conditions.append(User.user_type == 1)
    #_conditions.append(User.product_intention == 0)
    #_conditions.append(User.join_time >= '2014-01-01')
    #_conditions.append(User.join_time < '2014-09-01')

    pagination = User.query.filter(db.and_(*_conditions)).order_by(desc(User.expect_time))
    print pagination
    return render_template('john/dcd20150429.html',
                           pagination=pagination,
                           show_queries=['user_origin','op','user_type','username','phone','show_abandon'])
Example #28
0
def john_dcd20140627():
    _conditions = []
    _conditions.append(
        "assign_operator_id in (select id from operator where team='A2')")
    #_conditions.append("assign_time>0")
    _conditions.append("order_num=0")
    _conditions.append("ADDDATE(assign_time,interval 55 hour)<now()")
    pagination = User.query.filter(
        db.and_(*_conditions))  #.order_by(desc(User.assign_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=[
                               'user_origin', 'op', 'user_type', 'username',
                               'phone', 'show_abandon'
                           ])
Example #29
0
def john_dc20150212():

    _conditions = []
    _conditions.append(
        "(user.assign_operator_id in (8,40,41,42,43,45,47,48,84,87,154,194,201,210,231,232,227,228,229,219,222,223,224,225) or user.user_type=2)"
    )  # (0,2,3,4))" )
    #_conditions.append("order.team='B1' OR order.team='B2'" )
    #_conditions.append(User.user_type == 2)
    #_conditions.append(User.product_intention == 1)
    pagination = User.query.filter(db.and_(*_conditions)).order_by(
        desc(User.expect_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=[
                               'user_origin', 'op', 'user_type', 'username',
                               'phone', 'show_abandon'
                           ])
Example #30
0
def john_dc20150612():

    _conditions = []
    #_conditions.append("user.user_type=1 and user.assign_operator_id is null" )
    #_conditions.append("(user.assign_operator_id in (8,40,41,42,43,45,47,48,84,87,154,194,201,210,231,232,227,228,229,219,222,223,224,225) or user.user_type=2)")# (0,2,3,4))" )
    #_conditions.append("user.user_type=1" )
    _conditions.append(User.origin == 18)
    _conditions.append(User.is_valid == 2)

    pagination = User.query.filter(db.and_(*_conditions)).order_by(
        desc(User.expect_time))
    print pagination
    return render_template('john/dcd20150612.html',
                           pagination=pagination,
                           show_queries=[
                               'user_origin', 'op', 'user_type', 'username',
                               'phone', 'show_abandon'
                           ])
Example #31
0
def john_dcd20140702():
    _conditions = []
    _conditions.append(
        "user.assign_operator_id in (37,39,57,123,59,60,61,85,86,91,124,92,98,102,112,125,135,137)"
    )
    #_conditions.append("order.team='B1' OR order.team='B2'" )
    #_conditions.append(Order.created >= '2014-01-01')
    #_conditions.append(Order.created <= '2014-05-01')
    #_conditions.append(Order.express_number == 2)
    pagination = User.query.filter(db.and_(*_conditions)).order_by(
        desc(User.expect_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=[
                               'user_origin', 'op', 'user_type', 'username',
                               'phone', 'show_abandon'
                           ])
Example #32
0
def john_dcd20141014():
    _conditions = []
    _conditions.append(
        "(user.assign_operator_id in (4,90,113,38,147) and user.product_intention in (0,2,3,4))"
    )  # (0,2,3,4))" )
    #_conditions.append("order.team='B1' OR order.team='B2'" )
    _conditions.append(User.join_time >= '2014-01-01')
    _conditions.append(User.join_time < '2014-05-01')
    #_conditions.append(User.product_intention == 1)
    pagination = User.query.filter(db.and_(*_conditions)).order_by(
        desc(User.expect_time))
    print pagination
    return render_template('john/dcd20131111.html',
                           pagination=pagination,
                           show_queries=[
                               'user_origin', 'op', 'user_type', 'username',
                               'phone', 'show_abandon'
                           ])
Example #33
0
def john_dc20150429():

    _conditions = []
    #_conditions.append("((user.user_type=2 and user.assign_operator_id is null) or user.assign_operator_id in (select id from operator where team like 'A%' OR  team like 'B%')) and user.product_intention = 1" )
    #_conditions.append("(user.assign_operator_id in (8,40,41,42,43,45,47,48,84,87,154,194,201,210,231,232,227,228,229,219,222,223,224,225) or user.user_type=2)")# (0,2,3,4))" )
    _conditions.append("user.user_type=2")
    #_conditions.append(User.user_type == 1)
    #_conditions.append(User.product_intention == 0)
    #_conditions.append(User.join_time >= '2014-01-01')
    #_conditions.append(User.join_time < '2014-09-01')

    pagination = User.query.filter(db.and_(*_conditions)).order_by(
        desc(User.expect_time))
    print pagination
    return render_template('john/dcd20150429.html',
                           pagination=pagination,
                           show_queries=[
                               'user_origin', 'op', 'user_type', 'username',
                               'phone', 'show_abandon'
                           ])
Example #34
0
 def check_name(self, name):
     return User.query.filter(db.and_(
         User.name == name, User.email != self.id)).count() == 0
Example #35
0
def cards():
	postdata = request.get_json()
	attributes = postdata.get('attributes')
	species = postdata.get('species')
	stars = postdata.get('stars')
	monster_types = postdata.get('monster_types')
	spell_families = postdata.get('spell_families')
	trap_families = postdata.get('trap_families')
	archetypes = postdata.get('archetypes')
	search = postdata.get('search')

	order = postdata.get('order') or 'name'
	if order not in columns_from_model(model_by_tablename(db, 'cards')):
		abort(404)
	
	if order == 'attack':
		order = db.cast(MonsterCard.attack, db.Integer)
	if order == 'defense':
		order = db.cast(MonsterCard.defense, db.Integer)

	inverse = postdata.get('inverse') if postdata.get('inverse')!=None else False

	
	filters = []
	if attributes:
		filters.append(MonsterCard.attribute.in_(attributes))
	if species:
		filters.append(MonsterCard.species.in_(species))
	if stars:
		filters.append(MonsterCard.stars.in_(stars))
	if monster_types:
		filters.append(MonsterCard.types.any(MonsterType.value.in_(monster_types)))
	if spell_families:
		filters.append(SpellCard.spell_family.in_(spell_families))
	if trap_families:
		filters.append(TrapCard.trap_family.in_(trap_families))
	if archetypes:
		filters.append(Card.archetypes.any(Archetype.value.in_(archetypes)))
	if search:
		filters.append(Card.name.like('%' + search + '%'))
	if inverse:
		order = db.desc(order)

	if len(filters):

		result = db.session.query(card_plus).filter(
				db.and_(
					*filters
				)
			).order_by(
				order
			).all()

	else:
		result = db.session.query(card_plus).all()

	response = get_paginated_list(
					result,
					'/api/cards',
					start=request.args.get('start', 1),
					limit=request.args.get('limit', 20)
				)

	return Response(json.dumps(response), mimetype='application/json')


	
Example #36
0
 def check_name(self, name):
     return User.query.filter(
         db.and_(User.name == name, User.email != self.id)).count() == 0