本文整理汇总了Python中models.user.User.all_active方法的典型用法代码示例。如果您正苦于以下问题:Python User.all_active方法的具体用法?Python User.all_active怎么用?Python User.all_active使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.user.User
的用法示例。
在下文中一共展示了User.all_active方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: info
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all_active [as 别名]
def info(bid):
bref = Bref.get(bid)
reminder_emails = [(u.name, u.email) for u in User.all_active()]
planner_emails = [(u.name, u.id) for u in User.all_active()
if u.team.type == TEAM_TYPE_PLANNER]
form = BrefForm(request.form)
form.title.data = bref.title
form.agent.data = bref.agent
form.brand.data = bref.brand
form.product.data = bref.product
form.target.data = bref.target
form.background.data = bref.background
form.push_target.data = bref.push_target
form.push_theme.data = bref.push_theme
form.push_time.data = bref.push_time
form.budget.data = bref.budget
form.is_temp.data = bref.is_temp
form.agent_type.data = bref.agent_type
form.use_type.data = bref.use_type
form.level.data = bref.level
form.intent_medium.data = bref.intent_medium
form.suggest.data = bref.suggest
form.desc.data = bref.desc
return tpl('/planning/bref/info.html', bref=bref,
reminder_emails=reminder_emails, planner_emails=planner_emails, form=form)
示例2: index
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all_active [as 别名]
def index():
if request.method == 'POST':
if request.values.get('action', '') == 'excel':
start_date = request.values.get('start_date')
end_date = request.values.get('end_date')
start_date = datetime.datetime.strptime(start_date, '%Y-%m-%d')
end_date = datetime.datetime.strptime(end_date, '%Y-%m-%d')
outs = _format_out()
leaves = _format_leave()
all_dus = _format_onduty(start_date, end_date)
# 打卡最后一次时间
last_onduty_date = _get_last_onduty_date()
duty_obj = []
for user in User.all_active():
u_outs = [k for k in outs if k['creator_id'] == int(user.id)]
u_leaves = [k for k in leaves if k[
'creator_id'] == int(user.id)]
dutys = _get_onduty(all_dus, u_outs, u_leaves,
user, start_date, end_date, last_onduty_date)
duty_obj.append({'count': sum(item['warning_count'] for item in dutys),
'user': user})
return write_ondutys_excel(duty_obj, start_date, end_date)
else:
onduty_file = request.files['file']
data = onduty_file.readlines()
for k in data:
p = k.strip().split()
if len(p) == 7:
sn = p[0]
check_time = datetime.datetime.strptime(
p[1] + ' ' + p[2], '%Y-%m-%d %H:%M:%S')
user = User.query.filter_by(sn=sn).first()
if user:
if not UserOnDuty.query.filter_by(sn=sn, check_time=check_time).first():
UserOnDuty.add(
user=user,
sn=sn,
check_time=check_time,
create_time=datetime.datetime.now(),
type=0
)
return redirect(url_for('account_onduty.index'))
now_date = datetime.datetime.now()
now_month_first_day = now_date.replace(day=1)
end_date = (now_month_first_day - datetime.timedelta(days=1)).date()
start_date = end_date.replace(day=1)
users = User.all_active()
name = request.values.get('name', '')
location = int(request.values.get('location', 0))
if name:
users = [k for k in users if k.name == name]
if location:
users = [k for k in users if k.location == location]
return tpl('/account/onduty/index.html', users=users, name=name, location=location,
start_date=start_date, end_date=end_date)
示例3: unusual
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all_active [as 别名]
def unusual():
start_date = request.values.get('start_date', '')
end_date = request.values.get('end_date', '')
if not start_date and not end_date:
start_date, end_date = _get_last_week_date()
else:
start_date = datetime.datetime.strptime(start_date, '%Y-%m-%d')
end_date = datetime.datetime.strptime(end_date, '%Y-%m-%d')
all_active_user = User.all_active()
salers = [u for u in all_active_user if u.location == 1 and u.is_out_saler]
outs = _format_out()
leaves = _format_leave()
all_dus = _format_onduty(start_date, end_date)
# 打卡最后一次时间
last_onduty_date = _get_last_onduty_date()
users = []
for user in salers:
u_outs = [k for k in outs if k['creator_id'] == int(user.id)]
u_leaves = [k for k in leaves if k['creator_id'] == int(user.id)]
dutys = _get_onduty(all_dus, u_outs, u_leaves, user,
start_date, end_date, last_onduty_date)
users.append({'count': sum(item['warning_count'] for item in dutys),
'user': user})
return tpl('/account/onduty/unusual_index.html', users=users, location=1,
start_date=start_date.date(), end_date=end_date.date())
示例4: index
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all_active [as 别名]
def index(order_id):
order = searchAdClientOrder.get(order_id)
if not order:
abort(404)
invoices = searchAdInvoice.query.filter_by(client_order=order)
invoices_data = {
'PASS': [{'invoice': x, 'form': get_invoice_from(x)} for x in
invoices if x.invoice_status == INVOICE_STATUS_PASS],
'NORMAL': [{'invoice': x, 'form': get_invoice_from(x)} for x in
invoices if x.invoice_status == INVOICE_STATUS_NORMAL],
'APPLY': [{'invoice': x, 'form': get_invoice_from(x)} for x in
invoices if x.invoice_status == INVOICE_STATUS_APPLY],
'APPLYPASS': [{'invoice': x, 'form': get_invoice_from(x)} for x in
invoices if x.invoice_status == INVOICE_STATUS_APPLYPASS],
'FAIL': [{'invoice': x, 'form': get_invoice_from(x)} for x in
invoices if x.invoice_status == INVOICE_STATUS_FAIL],
}
reminder_emails = [(u.name, u.email) for u in User.all_active()]
new_invoice_form = InvoiceForm()
new_invoice_form.client_order.choices = [(order.id, order.client.name)]
new_invoice_form.company.data = order.agent.name
new_invoice_form.bank.data = order.agent.bank
new_invoice_form.bank_id.data = order.agent.bank_num
new_invoice_form.address.data = order.agent.address
new_invoice_form.phone.data = order.agent.phone_num
new_invoice_form.tax_id.data = order.agent.tax_num
new_invoice_form.back_time.data = datetime.date.today()
return tpl('/saler/searchAd_order/invoice/index.html', order=order,
invoices_data=invoices_data, new_invoice_form=new_invoice_form,
INVOICE_STATUS_CN=INVOICE_STATUS_CN, reminder_emails=reminder_emails,
INVOICE_TYPE_CN=INVOICE_TYPE_CN)
示例5: info
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all_active [as 别名]
def info(order_id):
if not g.user.is_finance():
abort(404)
order = ClientMediumOrder.get(order_id)
if not order:
abort(404)
invoices_data = {
'PASS': [{'invoice': x, 'form': get_invoice_from(x)}
for x in ClientMediumInvoice.query.filter_by(client_medium_order=order)
if x.invoice_status == INVOICE_STATUS_PASS],
'APPLYPASS': [{'invoice': x, 'form': get_invoice_from(x)}
for x in ClientMediumInvoice.query.filter_by(client_medium_order=order)
if x.invoice_status == INVOICE_STATUS_APPLYPASS],
}
reminder_emails = [(u.name, u.email) for u in User.all_active()]
new_invoice_form = ClientMediumInvoiceForm()
new_invoice_form.client_medium_order.choices = [(order.id, order.medium.name)]
new_invoice_form.company.data = order.agent.name
new_invoice_form.bank.data = order.agent.bank
new_invoice_form.bank_id.data = order.agent.bank_num
new_invoice_form.address.data = order.agent.address
new_invoice_form.phone.data = order.agent.phone_num
new_invoice_form.tax_id.data = order.agent.tax_num
new_invoice_form.back_time.data = datetime.date.today()
return tpl('/finance/client_medium_order/invoice/info.html', order=order,
invoices_data=invoices_data, INVOICE_STATUS_CN=INVOICE_STATUS_CN,
reminder_emails=reminder_emails, INVOICE_TYPE_CN=INVOICE_TYPE_CN,
new_invoice_form=new_invoice_form)
示例6: index
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all_active [as 别名]
def index(order_id):
order = ClientMediumOrder.get(order_id)
if not order:
abort(404)
invoices = ClientMediumInvoice.query.filter_by(client_medium_order=order)
invoices_data = {
'PASS': [{'invoice': x, 'form': get_invoice_from(x)} for x in
invoices if x.invoice_status == INVOICE_STATUS_PASS],
'NORMAL': [{'invoice': x, 'form': get_invoice_from(x)} for x in
invoices if x.invoice_status == INVOICE_STATUS_NORMAL],
'APPLY': [{'invoice': x, 'form': get_invoice_from(x)} for x in
invoices if x.invoice_status == INVOICE_STATUS_APPLY],
'APPLYPASS': [{'invoice': x, 'form': get_invoice_from(x)} for x in
invoices if x.invoice_status == INVOICE_STATUS_APPLYPASS],
'FAIL': [{'invoice': x, 'form': get_invoice_from(x)} for x in
invoices if x.invoice_status == INVOICE_STATUS_FAIL],
}
reminder_emails = [(u.name, u.email) for u in User.all_active()]
new_invoice_form = ClientMediumInvoiceForm()
new_invoice_form.client_medium_order.choices = [(order.id, order.medium.name)]
new_invoice_form.back_time.data = datetime.date.today()
return tpl('/saler/client_medium_order/invoice/index.html', order=order,
invoices_data=invoices_data, new_invoice_form=new_invoice_form,
INVOICE_STATUS_CN=INVOICE_STATUS_CN, reminder_emails=reminder_emails,
INVOICE_TYPE_CN=INVOICE_TYPE_CN)
示例7: invoice
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all_active [as 别名]
def invoice(invoice_id):
invoice = AgentInvoice.get(invoice_id)
if not invoice:
abort(404)
form = get_invoice_form(invoice)
reminder_emails = [(u.name, u.email) for u in User.all_active()]
return tpl('/saler/client_order/agent/invoice.html', form=form, invoice=invoice, reminder_emails=reminder_emails,
INVOICE_TYPE_CN=INVOICE_TYPE_CN, AGENT_INVOICE_STATUS_CN=AGENT_INVOICE_STATUS_CN)
示例8: invoice
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all_active [as 别名]
def invoice(invoice_id):
invoice = searchAdMediumInvoice.get(invoice_id)
if not invoice:
abort(404)
form = get_invoice_from(invoice)
reminder_emails = [(u.name, u.email) for u in User.all_active()]
return tpl('/saler/searchAd_order/medium/invoice.html', form=form, invoice=invoice, reminder_emails=reminder_emails,
INVOICE_TYPE_CN=INVOICE_TYPE_CN, MEDIUM_INVOICE_STATUS_CN=MEDIUM_INVOICE_STATUS_CN)
示例9: leave_create
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all_active [as 别名]
def leave_create(uid):
try:
user = User.get(uid)
except:
return jsonify({'ret': False, 'msg': u'用户找不到'})
if request.method == 'POST':
try:
type = int(request.values.get('type', 1))
except:
return jsonify({'ret': False, 'msg': u'请假类型错误'})
try:
start_time = datetime.datetime.strptime(
request.values.get('start'), '%Y-%m-%d %H')
end_time = datetime.datetime.strptime(
request.values.get('end'), '%Y-%m-%d %H')
except:
return jsonify({'ret': False, 'msg': u'开始结束时间错误'})
day = request.values.get('day', '0')
half = request.values.get('half', '1')
reason = request.values.get('reason', '')
senders_str = request.values.get('senders', '')
if senders_str:
senders_ids = senders_str.split('|')
try:
senders = User.gets(senders_ids)
except:
return jsonify({'ret': False, 'msg': u'抄送人错误'})
else:
senders = []
leave = Leave.add(type=type,
start_time=start_time,
end_time=end_time,
rate_day=day + '-' + half,
reason=reason,
status=1,
senders=senders,
creator=user,
create_time=datetime.date.today())
return jsonify({'ret': True,
'data': {'uid': user.id,
'start_time': leave.start_time.strftime('%Y-%m-%d %H'),
'end_time': leave.end_time.strftime('%Y-%m-%d %H'),
}
})
days = [{'key': k, 'value': k} for k in range(0, 21)]
days += [{'key': k, 'value': k} for k in [30, 98, 113, 128]]
return jsonify({'ret': True, 'data': {
'type': [{'key': k[0], 'value': k[1]}for k in LEAVE_TYPE_CN.items()],
'day': days,
'half': [{'key': '0', 'value': u'整'},
{'key': '1', 'value': u'上半天'},
{'key': '2', 'value': u'下半天'}],
'senders': [{'id': m.id, 'name': m.name} for m in User.all_active()],
'default': u"%s,[email protected](请假时长大于等于5天由黄亮审批)" % (user.team_leaders_cn)
}
})
示例10: pay_info
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all_active [as 别名]
def pay_info(invoice_id):
if not g.user.is_finance():
abort(404)
invoice = MediumInvoice.get(invoice_id)
form = get_invoice_from(invoice)
reminder_emails = [(u.name, u.email) for u in User.all_active()]
return tpl('/finance/client_order/medium_pay/pay_info.html',
form=form, invoice=invoice, reminder_emails=reminder_emails,
INVOICE_TYPE_CN=INVOICE_TYPE_CN)
示例11: merget_client_target_personal_info
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all_active [as 别名]
def merget_client_target_personal_info():
if request.method == 'POST':
outsource_ids = request.values.getlist('outsources')
outsources = OutSource.gets(outsource_ids)
emails = request.values.getlist('email')
msg = request.values.get('msg', '')
merger_outsources = []
for o in outsources:
o.status = OUTSOURCE_STATUS_APPLY_MONEY
o.create_time = datetime.date.today()
o.save()
merger_outsource = MergerPersonalOutSource.add(outsources=outsources,
invoice=request.values.get(
'invoice', ''),
pay_num=request.values.get(
'pay_num', 0),
num=request.values.get(
'num', 0),
remark=request.values.get(
'remark', ''),
status=1)
merger_outsource.save()
merger_outsources.append(merger_outsource)
flash(u'合并付款申请成功', 'success')
title = u'【费用报备】%s' % (u'合并付款申请审批')
for k in merger_outsources:
apply_context = {"sender": g.user,
"to": emails,
"msg": msg,
"title": title,
"action": -1,
"merger_outsource": k}
merger_outsource_apply_signal.send(
current_app._get_current_object(), apply_context=apply_context)
return redirect(url_for("outsource.merget_client_target_personal_info"))
apply_outsources = OutSource.get_personal_outsources(2)
# 审核中的合并付款
apply_merger_outsources = MergerPersonalOutSource.get_outsource_by_status(
MERGER_OUTSOURCE_STATUS_APPLY)
m_outsources = []
for k in apply_merger_outsources:
m_outsources += k.outsources
apply_money_outsources = [
k for k in OutSource.get_personal_outsources(3) if k not in m_outsources]
reminder_emails = [(u.name, u.email) for u in User.all_active()]
form = MergerOutSourceForm(request.form)
return tpl('merger_client_target_personal_info.html',
apply_outsources=apply_outsources, reminder_emails=reminder_emails,
apply_merger_outsources=apply_merger_outsources,
apply_money_outsources=apply_money_outsources,
OUTSOURCE_STATUS_APPLY_MONEY=OUTSOURCE_STATUS_APPLY_MONEY,
OUTSOURCE_STATUS_PAIED=OUTSOURCE_STATUS_PAIED,
OUTSOURCE_STATUS_PASS=OUTSOURCE_STATUS_PASS,
form=form, INVOICE_RATE=INVOICE_RATE)
示例12: _get_unusual
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all_active [as 别名]
def _get_unusual(start_date, end_date):
all_active_user = User.all_active()
salers = [u for u in all_active_user if u.location == 1 and u.is_out_saler]
last_check_date = _get_last_onduty_date()
if last_check_date < start_date:
for saler in salers:
saler.unusual_count = 0
else:
for saler in salers:
saler = _get_unusual_by_user(saler, start_date, end_date)
return salers
示例13: douban_outsources
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all_active [as 别名]
def douban_outsources(order_id):
order = DoubanOrder.get(order_id)
if not order:
abort(404)
new_outsource_form = DoubanOutsourceForm()
new_outsource_form.douban_order.choices = [(order.id, order.name)]
reminder_emails = [(u.name, u.email) for u in User.all_active()]
context = {'new_outsource_form': new_outsource_form,
'reminder_emails': reminder_emails,
'order': order}
return tpl('douban_outsources.html', **context)
示例14: client_outsources
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all_active [as 别名]
def client_outsources(order_id):
order = ClientOrder.get(order_id)
if not order:
abort(404)
new_outsource_form = OutsourceForm()
new_outsource_form.medium_order.choices = [
(mo.id, mo.medium.name) for mo in order.medium_orders]
reminder_emails = [(u.name, u.email) for u in User.all_active()]
context = {'new_outsource_form': new_outsource_form,
'reminder_emails': reminder_emails,
'order': order}
return tpl('client_outsources.html', **context)
示例15: index
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import all_active [as 别名]
def index(order_id):
order = searchAdClientOrder.get(order_id)
if not order:
abort(404)
invoices = searchAdMediumInvoice.query.filter_by(client_order=order)
reminder_emails = [(u.name, u.email) for u in User.all_active()]
new_invoice_form = MediumInvoiceForm()
new_invoice_form.client_order.choices = [(order.id, order.client.name)]
new_invoice_form.medium.choices = [(k.id, k.name)for k in order.mediums]
new_invoice_form.add_time.data = datetime.date.today()
return tpl('/saler/searchAd_order/medium/index.html', order=order, reminder_emails=reminder_emails,
new_invoice_form=new_invoice_form, invoices=invoices,
MEDIUM_INVOICE_STATUS_CN=MEDIUM_INVOICE_STATUS_CN, INVOICE_TYPE_CN=INVOICE_TYPE_CN)