本文整理汇总了Python中models.users.Users.get方法的典型用法代码示例。如果您正苦于以下问题:Python Users.get方法的具体用法?Python Users.get怎么用?Python Users.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.users.Users
的用法示例。
在下文中一共展示了Users.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: modify
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get [as 别名]
def modify(self):
userInput= self.getInput()
userObj = Users.get(Users.id == int(userInput['id']))
current_user = Users.get(Users.name == self.isLogin())
if userObj.id != current_user.id and not self.isAdmin():
return self.error(msg = '权限不足!', url=self.makeUrl('/admin/users/list'))
thumbnail_id = int(userInput['thumbnail']) if userInput.has_key('thumbnail') else 0
if thumbnail_id:
thumbnail_data = Images.get(Images.id == thumbnail_id).thumbnail
else:
import base64
from imaging import imaging
thumbnail_data = base64.b64encode(buffer(imaging.default_thumbnail()))
try:
userObj = Users.get(Users.id == int(userInput['id']))
userObj.email = userInput['email']
userObj.name = userInput['name']
userObj.cellphone = userInput['cellphone']
userObj.description = userInput['desc']
userObj.gender = int(userInput['gender'])
userObj.avatur = thumbnail_data
if self.isAdmin():
userObj.role = userInput['role']
userObj.save()
except Exception, e:
return self.error(msg = '会员修改失败: %s' % e, url=self.makeUrl('/admin/users/list'))
示例2: edit
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get [as 别名]
def edit(self):
inputParams = self.getInput()
album_id = int(inputParams['id'])
album = Albums.get(Albums.id == album_id)
current_user = Users.get(Users.name == self.isLogin())
if current_user.id != album.owner.id and not self.isAdmin():
return self.error(msg = '权限不足!', url=self.makeUrl('/admin/albums/list'))
self.privData['ALBUM_ID'] = album.id
self.privData['ALBUM_NAME'] = album.name
self.privData['ALBUM_DESC'] = album.description
self.privData['ENABLE_SELECT_THUMBNAIL'] = False
imagesList = Images().select()
if not self.isAdmin():
imagesList = imagesList.where(Images.owner == current_user)
imagesList = imagesList.where(Images.album == album)
if imagesList.count():
self.privData['ENABLE_SELECT_THUMBNAIL'] = True
self.privData['ALBUMS_LIST'] = [album]
self.privData['IMG_ALBUMS_LIST'] = {album.id: imagesList}
self.privData['CURRENT_IMG'] = imagesList[0]
self.privData['CURRENT_ALBUM'] = album
self.privData['SUBMIT_NAME'] = "thumbnail"
return self.display('albumEdit')
示例3: add
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get [as 别名]
def add(self):
chatroomsList = Chatrooms().select()
userName = self.isLogin()
if userName != 'admin':
return self.error(msg = '权限不足!', url=self.makeUrl('/admin/chatrooms/list'))
user = Users.get(Users.name == userName)
albumsList = Albums().select().where(Albums.owner == user.id)
imagesList = Images().select().where(Images.owner == user.id)
if not albumsList.count():
return self.error(msg = '请创建至少一个专辑!', url=self.makeUrl('/admin/chatrooms/list'))
if not imagesList.count():
return self.error(msg = '请创建至少一个图片!', url=self.makeUrl('/admin/chatrooms/list'))
album_images_map = {}
excluded_albums = []
for album in albumsList:
album_images = imagesList.where(Images.album == album.id)
if album_images.count():
album_images_map[album.id] = album_images
else:
excluded_albums.append(album.id)
self.privData['ALBUMS_LIST'] = \
[album for album in albumsList if album.id not in excluded_albums]
self.privData['IMG_ALBUMS_LIST'] = album_images_map
# 默认专辑为当前用户的第一个专辑
self.privData['CURRENT_ALBUM'] = self.privData['ALBUMS_LIST'][0]
# 默认图片为默认专辑的第一张图片
self.privData['CURRENT_IMG'] = album_images_map[self.privData['CURRENT_ALBUM'].id][0]
self.privData['SUBMIT_NAME'] = "thumbnail"
return self.display('chatroomAdd')
示例4: confirm_select_order
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get [as 别名]
def confirm_select_order(self):
inputs = self.getInput()
try:
product = Products.get(Products.id == int(inputs['product']))
user =Users.get(Users.name == self.isLogin())
price = inputs['price']
if inputs.has_key('add'):
order = Orders.create(
owner = user,
price = price,
description = product.category.name,
)
else:
if not inputs.has_key('selected'):
return self.orders_list()
order = Orders.get(Orders.id == int(inputs['selected']))
details = OrderDetails.create(
name = product.category.name + " "+product.diameter,
product = product,
count = user,
price = price,
ratio = 0.0,
order = order,
)
return web.seeother(self.makeUrl('/wap/edit_price_sheet', {'id': order.id}))
except Exception, e:
print 'exc',e
return self.error(msg='保存订单失败!')
示例5: save_my_information
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get [as 别名]
def save_my_information(self):
inputs = web.input()
try:
try:
if len(inputs['imgfile'])>10:
htmlimg = httpUploadedFile(inputs['imgfile'])
userimg=Images().create(
uuid = htmlimg.uuid(),
description = self.htmlunquote("上传图片"),
thumbnail = self.wap_imgsave(htmlimg)
)
except Exception, e:
print e
userimg=Images().get(Images.id == 1)
user = Users.get(Users.id == int(inputs['userid']))
user.name = inputs['name']
user.cellphone = inputs['cellphone']
user.gender = inputs['gender']
user.email = inputs['email']
user.job = inputs['job']
user.avatur=userimg
user.address = inputs['address']
user.save()
return self.my_information()
示例6: save
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get [as 别名]
def save(self):
inputParams= self.getInput()
try:
current_user = Users.get(Users.name == self.isLogin())
inputParams['longitude'] = inputParams['longitude'] if inputParams['longitude'] else 116.397428
inputParams['latitude'] = inputParams['latitude'] if inputParams['latitude'] else 39.90923
Groups.create(
name = inputParams['name'],
owner = current_user,
address = inputParams['address'],
phoneno = inputParams['phoneno'],
cellphone = inputParams['cellphone'],
faxno = inputParams['faxno'],
postcode = inputParams['postcode'],
contact = inputParams['contact'],
description = self.htmlunquote(inputParams['description']),
thumbnail = int(inputParams['thumbnail']),
team_description = self.htmlunquote(inputParams['team_description']),
regions = inputParams['regions'],
service_modes = inputParams['service_modes'],
specials = inputParams['specials'],
swipeshow_album = int(inputParams['swipeshow_album']),
groups_album = int(inputParams['groups_album']),
price1 = float(inputParams['price1']),
price2 = float(inputParams['price2']),
longitude = float(inputParams['longitude']),
latitude = float(inputParams['latitude']),
category = int(inputParams['category']),
)
except Exception, e:
return self.error(msg = '新增公司失败: %s' % e, url=self.makeUrl('/admin/groups/list'))
示例7: update
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get [as 别名]
def update(self):
inputParams= self.getInput()
group = Groups.get(Groups.id == int(inputParams['id']))
current_user = Users.get(Users.name == self.isLogin())
if current_user.id != group.owner.id and not self.isAdmin() or not current_user.role.type < 100:
return self.error(msg = '权限不足!', url=self.makeUrl('/admin/groups/list'))
try:
group.regions = inputParams['regions']
group.name = inputParams['name']
group.owner = current_user
group.phoneno = inputParams['phoneno']
group.cellphone = inputParams['cellphone']
group.faxno = inputParams['faxno']
group.postcode = inputParams['postcode']
group.contact = inputParams['contact']
group.description = self.htmlunquote(inputParams['description'])
group.thumbnail = int(inputParams['thumbnail'])
group.team_description = self.htmlunquote(inputParams['team_description'])
group.regions = inputParams['regions']
group.service_modes = inputParams['service_modes']
group.specials = inputParams['specials']
group.swipeshow_album = int(inputParams['swipeshow_album'])
group.groups_album = int(inputParams['groups_album'])
group.price1 = float(inputParams['price1'])
group.price2 = float(inputParams['price2'])
group.address = inputParams['address']
group.longitude = float(inputParams['longitude'])
group.latitude = float(inputParams['latitude'])
group.category = int(inputParams['category'])
group.save()
except Exception, e:
return self.error(msg = '公司修改失败: %s' % e, url=self.makeUrl('/admin/groups/list'))
示例8: save_price_sheet
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get [as 别名]
def save_price_sheet(self):
inputs = self.getInput()
print inputs
try:
if inputs.has_key('add'):
return web.seeother(self.makeUrl('/wap/categories', {'parent': 1, 'order': int(inputs['id'])}))
order = Orders.get(Orders.id == int(inputs['id']))
attrs = {}
for k, v in inputs.items():
try:
attr, oid = k.split('_')
except Exception, e:
continue
if not attrs.has_key(oid):
attrs[oid] = {}
attrs[oid][attr] = v
if not inputs['customer'] or not inputs['description']:
raise Exception("询价方或备注不能为空!")
order.customer = inputs['customer']
order.description = inputs['description']
order.owner = Users.get(Users.name == self.isLogin())
order.save()
for k, v in attrs.items():
#import pdb;pdb.set_trace()
import traceback
if not v['count'] or not v['ratio']:
raise Exception("数量或利润率不能为空!")
nameform = v['name']
diameterform = v['diameter']
oldinput= v['can']
name, diameter = oldinput.split(' ')
details = OrderDetails.get(OrderDetails.id == int(k))
details.name = oldinput
flag = v['bool']
if flag.find("True")>=0:
details.flag=True
elif details.name!=(details.product.category.name+' '+details.product.diameter):
details.flag=True
else:
details.flag=False
try:
product = Products().get(Products.name==name,Products.diameter == diameter)
except Exception,e:
details.price = float(v['input'])
details.count = v['count']
details.ratio = float(v['ratio'])/100.0
details.save()
details.price = float(v['input'])
details.count = v['count']
details.ratio = float(v['ratio'])/100.0
details.save()
示例9: edit_my_information
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get [as 别名]
def edit_my_information(self):
inputs = self.getInput()
try:
user = Users.get(Users.id == inputs['id'])
self.privData['USER'] = user
return self.display('edit-my-information')
except Exception,e:
return self.error(msg='获取当前用户信息失败!')
示例10: my_information
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get [as 别名]
def my_information(self):
try:
user =Users.get(Users.name == self.isLogin())
self.privData['USER'] = user
return self.display('my-information')
except Exception, e:
print e
return self.error(msg='获取用户信息失败!')
示例11: answnerEdit
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get [as 别名]
def answnerEdit(self):
inputParams = self.getInput()
answner = Answners.get(Answners.id == inputParams['id'])
current_user = Users.get(Users.name == self.isLogin())
if not self.isAdmin() or answner.question.group.owner != current_user:
return self.error(msg = '权限不足!', url=self.makeUrl('/admin/questions/list'))
self.privData['ANSWNER'] = answner
return self.display('answnerEdit')
示例12: orders_list
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get [as 别名]
def orders_list(self):
try:
#import pdb; pdb.set_trace()
user = Users.get(Users.name == self.isLogin())
ordersList = Orders.select().where(Orders.owner == user).order_by(Orders.id.desc())
self.privData['ORDERS_LIST'] = ordersList
return self.display('orders-list')
except Exception, e:
print e
return self.error(msg='获取报价单列表失败!')
示例13: savepwd
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get [as 别名]
def savepwd(self):
inputData = self.getInput()
#password = hashlib.md5(inputData['oldpwd']).hexdigest()
userID = inputData['id']
newpwd1 = hashlib.md5(inputData['newpwdone']).hexdigest()
newpwd2 = hashlib.md5(inputData['newpwdtwo']).hexdigest()
if newpwd1 != newpwd2:
return self.error(msg = '两次密码输入不一致', url=self.makeUrl('/admin/users/list'))
user = Users.get(Users.id == userID)
user.password = newpwd1
try:
user = Users.get(Users.id == userID)
user.password = newpwd1
except Exception, e:
return self.error(msg = '会员密码修改失败: %s' % e, url=self.makeUrl('/admin/users/list'))
示例14: delete
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get [as 别名]
def delete(self):
inputParams = self.getInput()
try:
current_user = Users.get(Users.name == self.isLogin())
if not self.isAdmin():
return self.error(msg = '权限不足!', url=self.makeUrl('/admin/agents/list'))
question = Questionss.get(Questions.id == int(inputParams['id']))
question.delete_instance()
except Exception, e:
return self.error(msg = '删除问题失败: %s' % e, url=self.makeUrl('/admin/questions/list'))
示例15: answnerDelete
# 需要导入模块: from models.users import Users [as 别名]
# 或者: from models.users.Users import get [as 别名]
def answnerDelete(self):
userInput = self.getInput()
try:
answner = Answners.get(Answners.id == int(userInput['id']))
current_user = Users.get(Users.name == self.isLogin())
if not self.isAdmin() or answner.question.group.owner != current_user:
return self.error(msg = '权限不足!', url=self.makeUrl('/admin/questions/list'))
answner.delete_instance()
except Exception, e:
return self.error(msg = '删除回复失败: %s' % e, url=self.makeUrl('/admin/questions/list'))