本文整理汇总了Python中api_db_utils.APIDB.add_owner_to_club方法的典型用法代码示例。如果您正苦于以下问题:Python APIDB.add_owner_to_club方法的具体用法?Python APIDB.add_owner_to_club怎么用?Python APIDB.add_owner_to_club使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api_db_utils.APIDB
的用法示例。
在下文中一共展示了APIDB.add_owner_to_club方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: coach_club_create
# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import add_owner_to_club [as 别名]
def coach_club_create(req):
"""
``POST`` @ |ca| + ``/clubs``
Create a club.
"""
j_req = json_from_request(req, mandatory_props=["name", "url", "isOpen"], optional_props=['tags', "description"])
club = APIDB.create_club(**j_req)
APIDB.add_owner_to_club(req.user, club)
# users the rendering of club details, add 201 code
req.model = club
return HttpCreated(coach_club_details(req, None))
示例2: coach_club_membership_create
# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import add_owner_to_club [as 别名]
def coach_club_membership_create(req, uskey_club):
"""
``POST`` @ |ca| + ``/clubs/<uskey_club>/memberships``
Add a membership for the user specified in the body ``userId``. |uroleOT|
"""
# FIXME: how delete works?
j_req = json_from_request(req, ["userId", "membershipType"], [("endDate", None)])
user = APIDB.get_user_by_id(j_req['user_id'])
membership_type = j_req.pop('membership_type')
if membership_type == "MEMBER":
APIDB.add_member_to_club(user, req.model, status="ACCEPTED", end_date=j_req['end_date'])
elif membership_type == "TRAINER":
APIDB.add_trainer_to_club(user, req.model, status="ACCEPTED", end_date=j_req['end_date'])
elif membership_type == "OWNER":
APIDB.add_owner_to_club(user, req.model, end_date=j_req['end_date'])
else:
raise BadParameters("Value %s is not valid for field 'type'" % j_req['type'])
req.model = APIDB.get_membership(user, req.model)
return HttpCreated(coach_club_membership(req, None))
示例3: Key
# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import add_owner_to_club [as 别名]
__author__ = 'Stefano Tranquillini <[email protected]>'
from datetime import datetime, timedelta
from api_db_utils import APIDB
from models import User
from gaebasepy.gc_utils import date_to_js_timestamp
user = User.query(User.email == '[email protected]').get()
club = APIDB.create_club(name="gymCentral Free Club",
description="This club is provided by gymCentral, with a free demo course for everyone who wants to feel the experience of our service.",
is_open=True, url="http://gymcentral.net")
# club created
# club = Key('Club',6192449487634432).get()
APIDB.add_owner_to_club(user, club)
# APIDB.add_trainer_to_club(iman, club,status="ACCEPTED")
# Course
data = dict(name="Strength and balance", description="Free course to improve your strength and balance.",
start_date=date_to_js_timestamp(datetime(2015, 1, 1)),
end_date=date_to_js_timestamp(datetime(2015, 12, 31)),
course_type="SCHEDULED", max_level=2)
course = APIDB.create_course(club, **data)
APIDB.add_trainer_to_course(user, course)
# Course created
# course = Key('Course',4785074604081152).get()
# Indicators
data = dict(name="How are you today?", indicator_type="INTEGER", description="How are you today", required=True,
answer_type='CHECKBOXES',
possible_answers=[dict(name='1', text='Very bad', value='1'), dict(name='2', text='Not so good', value='2'),
dict(name='3', text='Ok', value='3'), dict(name='4', text='Good', value='4'),
dict(name='5', text='Very good', value='5')])