本文整理汇总了Python中models.user.User.gets方法的典型用法代码示例。如果您正苦于以下问题:Python User.gets方法的具体用法?Python User.gets怎么用?Python User.gets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.user.User
的用法示例。
在下文中一共展示了User.gets方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import gets [as 别名]
def index():
if not g.user.is_super_admin():
abort(403)
form = FrameworkOrderForm(request.form)
if request.method == 'POST' and form.validate():
order = FrameworkOrder.add(group=Group.get(form.group.data),
agents=Agent.gets(form.agents.data),
description=form.description.data,
money=int(
round(float(form.money.data or 0))),
client_start=form.client_start.data,
client_end=form.client_end.data,
reminde_date=form.reminde_date.data,
direct_sales=User.gets(
form.direct_sales.data),
agent_sales=User.gets(form.agent_sales.data),
contract_type=form.contract_type.data,
creator=g.user,
contract_status=2,
contract=request.values.get('contract'),
create_time=datetime.now())
order.add_comment(g.user, u"导入了框架订单")
flash(u'导入框架订单成功', 'success')
return redirect(order.info_path())
else:
form.client_start.data = datetime.now().date()
form.client_end.data = datetime.now().date()
form.reminde_date.data = datetime.now().date()
return tpl('insert_framework_order.html', form=form)
示例2: index
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import gets [as 别名]
def index():
if not g.user.is_super_admin():
abort(403)
form = ClientOrderForm(request.form)
mediums = [(m.id, m.name) for m in Medium.all()]
if request.method == 'POST' and form.validate():
if ClientOrder.query.filter_by(contract=request.values.get('contract')).count() > 0:
flash(u'合同号已存在', 'danger')
return redirect(url_for('util_insert_orders.index'))
order = ClientOrder.add(agent=Agent.get(form.agent.data),
client=Client.get(form.client.data),
campaign=form.campaign.data,
money=int("%.0f" % (form.money.data or 0)),
client_start=form.client_start.data,
client_end=form.client_end.data,
reminde_date=form.reminde_date.data,
direct_sales=User.gets(form.direct_sales.data),
agent_sales=User.gets(form.agent_sales.data),
contract_type=form.contract_type.data,
resource_type=form.resource_type.data,
sale_type=form.sale_type.data,
contract=request.values.get('contract', ''),
creator=g.user,
contract_status=2,
create_time=datetime.now())
order.add_comment(g.user,
u"导入了客户订单:%s - %s - %s" % (
order.agent.name,
order.client.name,
order.campaign
))
medium_ids = request.values.getlist('medium')
medium_moneys = request.values.getlist('medium_money')
medium_moneys2 = request.values.getlist('medium_money2')
medium_contracts = request.values.getlist('medium_contract')
if medium_ids and medium_moneys and len(medium_ids) == len(medium_moneys):
for x in range(len(medium_ids)):
medium = Medium.get(medium_ids[x])
mo = Order.add(campaign=order.campaign,
medium=medium,
sale_money=int("%.0f" % (form.money.data or 0)),
medium_money=int(medium_moneys[x] or 0),
medium_money2=int(medium_moneys2[x] or 0),
medium_contract=medium_contracts[x],
medium_start=order.client_start,
medium_end=order.client_end,
creator=g.user)
order.medium_orders = order.medium_orders + [mo]
order.add_comment(g.user, u"导入了媒体订单: %s %s元" %
(medium.name, mo.sale_money))
order.save()
flash(u'导入客户订单成功!', 'success')
insert_executive_report(order, '')
return redirect(order.info_path())
else:
form.client_start.data = datetime.now().date()
form.client_end.data = datetime.now().date()
form.reminde_date.data = datetime.now().date()
return tpl('insert_order.html', form=form, mediums=mediums)
示例3: client_orders_distribute
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import gets [as 别名]
def client_orders_distribute():
if request.method == 'POST':
order_id = request.values.get('order_id', '')
operator = request.values.get('operater_ids', '')
order = ClientOrder.get(order_id)
if operator:
operater_users = User.gets(operator.split(','))
to_users = operater_users
for k in order.medium_orders:
k.operaters = operater_users
k.save()
else:
for k in order.medium_orders:
k.operaters = []
k.save()
to_users = []
if to_users:
context = {"to_users": to_users + [g.user],
"operater_users": operater_users,
"action_msg": u'分配执行人员',
"info": '',
"order": order}
outsource_distribute_signal.send(
current_app._get_current_object(), context=context)
return redirect(url_for('outsource.client_orders_distribute'))
orders = [k for k in ClientOrder.query.all() if k.medium_orders and k.contract != '']
operaters = User.gets_by_team_type(
TEAM_TYPE_OPERATER) + User.gets_by_team_type(TEAM_TYPE_OPERATER_LEADER)
return display_orders(orders, 'client_orders_distribute.html', title=u"客户订单分配", operaters=operaters)
示例4: update
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import gets [as 别名]
def update(user_id, lid):
leave = Leave.get(lid)
form = UserLeaveForm(request.form)
if request.method == 'POST':
status = request.values.get('status')
leave.type = form.type.data
leave.start_time = datetime.datetime.strptime(
request.values.get('start'), '%Y-%m-%d %H'),
leave.end_time = datetime.datetime.strptime(
request.values.get('end'), '%Y-%m-%d %H'),
leave.rate_day = request.values.get(
'day', '0') + '-' + request.values.get('half', '1'),
leave.reason = form.reason.data
leave.status = status
leave.senders = User.gets(form.senders.data)
leave.create_time = datetime.date.today()
leave.save()
if int(status) == LEAVE_STATUS_APPLY:
flash(u'已发送申请', 'success')
account_leave_apply_signal.send(
current_app._get_current_object(), leave=leave)
else:
flash(u'修改成功', 'success')
return redirect(url_for('account_leave.index', user_id=user_id))
form.type.data = leave.type
form.reason.data = leave.reason
form.senders.data = [u.id for u in leave.senders]
days = [{'key': k, 'value': k} for k in range(0, 21)]
days += [{'key': k, 'value': k} for k in [30, 98, 113, 128]]
return tpl('/account/leave/create.html', form=form, leave=leave, days=days)
示例5: create
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import gets [as 别名]
def create(user_id):
form = UserLeaveForm(request.form)
if request.method == 'POST':
status = request.values.get('status')
leave = Leave.add(type=form.type.data,
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'),
rate_day=request.values.get(
'day', '0') + '-' + request.values.get('half', '1'),
reason=form.reason.data,
status=status,
senders=User.gets(form.senders.data),
creator=g.user,
create_time=datetime.date.today())
if int(status) == LEAVE_STATUS_NORMAL:
flash(u'添加成功', 'success')
else:
flash(u'已发送申请', 'success')
account_leave_apply_signal.send(
current_app._get_current_object(), leave=leave)
return redirect(url_for('account_leave.index', user_id=user_id))
days = [{'key': k, 'value': k} for k in range(0, 21)]
days += [{'key': k, 'value': k} for k in [30, 98, 113, 128]]
return tpl('/account/leave/create.html', form=form, leave=None, days=days)
示例6: leave_create
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import gets [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)
}
})
示例7: index
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import gets [as 别名]
def index():
print g.user.is_contract()
if not (g.user.is_super_admin() or g.user.is_contract()):
abort(403)
form = DoubanOrderForm(request.form)
if request.method == 'POST' and form.validate():
if DoubanOrder.query.filter_by(contract=request.values.get('contract')).count() > 0:
flash(u'合同号已存在', 'danger')
return redirect(url_for('util_insert_douban_orders.index'))
order = DoubanOrder.add(client=Client.get(form.client.data),
agent=Agent.get(form.agent.data),
campaign=form.campaign.data,
money=int(round(float(form.money.data or 0))),
medium_CPM=form.medium_CPM.data,
sale_CPM=form.sale_CPM.data,
client_start=form.client_start.data,
client_end=form.client_end.data,
reminde_date=form.reminde_date.data,
direct_sales=User.gets(form.direct_sales.data),
agent_sales=User.gets(form.agent_sales.data),
operaters=User.gets(form.operaters.data),
designers=User.gets(form.designers.data),
planers=User.gets(form.planers.data),
contract_type=form.contract_type.data,
resource_type=form.resource_type.data,
sale_type=form.sale_type.data,
creator=g.user,
contract=request.values.get('contract'),
contract_status=2,
create_time=datetime.now())
order.add_comment(g.user,
u"导入了直签豆瓣订单:%s - %s - %s" % (
order.agent.name,
order.client.name,
order.campaign
))
insert_executive_report(order, '')
flash(u'导入订单成功', 'success')
return redirect(order.info_path())
else:
form.client_start.data = datetime.now().date()
form.client_end.data = datetime.now().date()
form.reminde_date.data = datetime.now().date()
return tpl('insert_douban_order.html', form=form)
示例8: update
# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import gets [as 别名]
def update(oid):
out = Out.get(oid)
joiners_form = JoinersForm(request.form)
joiners_form.joiners.data = [u.id for u in out.joiners]
m_persions = []
if g.user.is_out_saler:
m_persions += [{'key': '1' + '-' +
str(k.id) + '-' + k.name, 'name': k.name} for k in Client.all()]
m_persions += [{'key': '2' + '-' +
str(k.id) + '-' + k.name, 'name': k.name} for k in Agent.all()]
m_persions += [{'key': '3' + '-' +
str(k.id) + '-' + k.name, 'name': k.name} for k in Medium.all()]
m_persions.append({'key': 100, 'name': u'其他'})
if request.method == 'POST':
if g.user.is_out_saler:
creator_type = 1
else:
creator_type = 2
start_time = request.values.get('start_time', '')
end_time = request.values.get('end_time', '')
# m_person有两种类型,一种是其他所以填写,一种是代理+客户+媒体组合而成,例如:1-1,2-1,3-1(具体请查看m_persions)
m_persion = request.values.get('m_persion', '')
m_persion_type = int(request.values.get('m_persion_type', 1))
reason = request.values.get('reason', '')
persions = request.values.get('persions', '')
address = request.values.get('address', '')
joiners = User.gets(request.values.getlist('joiners'))
out.start_time = datetime.datetime.strptime(
start_time, '%Y-%m-%d %H:%M')
out.end_time = datetime.datetime.strptime(end_time, '%Y-%m-%d %H:%M')
out.reason = reason
out.joiners = joiners
out.persions = persions
out.address = address
out.m_persion = m_persion
out.m_persion_type = m_persion_type
out.creator_type = creator_type
out.status = int(request.values.get('action', 0))
out.create_time = datetime.datetime.now()
out.save()
# 先删除外出报表,在从新添加
OutReport.query.filter_by(out_id=oid).delete()
for k in list(set(joiners + [out.creator])):
OutReport.add(
start_time=datetime.datetime.strptime(
start_time, '%Y-%m-%d %H:%M'),
end_time=datetime.datetime.strptime(
end_time, '%Y-%m-%d %H:%M'),
reason=reason,
out=out,
meeting_s='',
persions=persions,
address=address,
m_persion=m_persion,
m_persion_type=m_persion_type,
creator_type=creator_type,
status=int(request.values.get('action', 0)),
creator=k,
create_time=datetime.datetime.now()
)
if int(int(request.values.get('action', 0))) == OUT_STATUS_APPLY:
flash(u'已发送申请', 'success')
account_out_apply_signal.send(
current_app._get_current_object(), out=out, status=1)
else:
flash(u'添加成功,请及时申请外出报备', 'success')
return redirect(url_for('account_out.index'))
return tpl('/account/out/update.html', out=out, m_persions=m_persions, joiners_form=joiners_form)