本文整理汇总了Python中models.Team类的典型用法代码示例。如果您正苦于以下问题:Python Team类的具体用法?Python Team怎么用?Python Team使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Team类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: bench_test
def bench_test(self):
User.objects.create_user("dillen", "[email protected]", "letmein")
team1 = Team(team_name="Winners",owner=User.objects.get(username__exact="dillen"))
p1 = Player(full_name="abc1",position="WR",team=team1,benched=False)
p2 = Player(full_name="abc2",position="WR",team=team1,benched=False)
team1.wr_count = 2
p3 = Player(full_name="abc3",position="WR",team=team1)
p4 = Player(full_name="abc4",position="WR")
team1.save()
p1.save()
p2.save()
p3.save()
p4.save()
#Bench someone already benched
self.assertEqual(bench(p3),False)
self.assertEqual(team1.wr_count,2)
self.assertEqual(p3.benched,True)
#Bench someone not on a team
self.assertEqual(bench(p4),False)
self.assertEqual(team1.wr_count,2)
self.assertEqual(p4.benched,True)
#Bench a WR
self.assertEqual(bench(p2),False)
self.assertEqual(team1.wr_count,1)
self.assertEqual(p1.benched,False)
self.assertEqual(p2.benched,True)
开发者ID:epkatz,项目名称:7-Fantasy-Football,代码行数:32,代码来源:tests.py
示例2: get
def get(self, first_eid):
df = DatafeedUsfirstEvents()
event = df.getEvent(first_eid)
event = EventUpdater.createOrUpdate(event)
teams = df.getEventRegistration(first_eid)
eventteams_count = 0
for team_dict in teams:
# This could be refactored to do a lot fewer DB requests by batching the Team and EventTeam gets.
# -gregmarra 5 Dec 2010
team = Team.get_by_key_name("frc" + str(team_dict["number"]))
if team is None:
team = Team(
team_number = int(team_dict["number"]),
first_tpid = int(team_dict["tpid"]),
key_name = "frc" + str(team_dict["number"])
)
team.put()
et = EventTeam.get_or_insert(
key_name = event.key().name() + "_" + team.key().name(),
event = event,
team = team)
eventteams_count = eventteams_count + 1
template_values = {
'event': event,
'eventteams_count': eventteams_count,
}
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_event_get.html')
self.response.out.write(template.render(path, template_values))
开发者ID:Apple101Review,项目名称:the-blue-alliance,代码行数:33,代码来源:datafeed_controller.py
示例3: post
def post(self):
post = self.request.POST
team = Team(name=post['team_name'])
team.save()
self.response.out.write("submitted")
开发者ID:Ziyad,项目名称:man-up,代码行数:7,代码来源:handlers.py
示例4: post
def post(self):
request_data = json.loads(self.request.body)
logging.info(request_data)
player = current_user_player()
# VALIDATION
if not validate_request_data(self.response, request_data, ['team_name']):
return
elif not validate_logged_inn(self.response):
return
elif not _validate_has_no_team(self.response, player):
return
# REGISTER TEAM
new_team = Team(
name=request_data['team_name'],
owner=player.key
).put().get()
# JOIN TEAM WITH PLAYER
player.team = new_team.key
player.put()
ndb.get_context().clear_cache() # Required to get the new player as part of the get_data
set_json_response(self.response, {'team': new_team.get_data('full')})
开发者ID:Andrioden,项目名称:dotacareer,代码行数:25,代码来源:teams.py
示例5: post
def post(self, user_token):
team = Team.all().filter('user_token =', user_token).get()
if team is None:
# just make sure this pledge exists
user_info = config_NOCOMMIT.pledge_service.loadPledgeInfo(user_token)
if user_info is None:
return self.notfound()
form = TeamForm(self.request.POST, team)
if not form.validate():
return self.render_template("new_from_pledge.html", form=form)
if team is None:
gravatar = "https://secure.gravatar.com/avatar/%s?%s" % (
hashlib.md5(user_info['email'].lower()).hexdigest(),
urllib.urlencode({'s': str('120')}))
team = Team.create(title=form.title.data,
description=form.description.data,
zip_code=form.zip_code.data,
user_token=user_token,
gravatar=gravatar)
else:
form.populate_obj(team)
self.add_to_user(team)
team.primary_slug = Slug.new(team)
try:
result = config_NOCOMMIT.pledge_service.updateMailchimp(team)
except Exception as e:
logging.error('Exception updating mailChimp: ' + str(e))
logging.info(traceback.format_exc())
team.put()
if self.logged_in:
return self.redirect("/t/%s" % team.primary_slug)
return self.redirect("/dashboard/add_admin_from_pledge/%s" % user_token)
开发者ID:Lessig2016,项目名称:teams,代码行数:32,代码来源:main.py
示例6: add_team
def add_team():
if 'user_id' in session:
user_id = session['user_id']
user = User.query.get(user_id)
else:
return redirect(url_for('index'))
if request.method == 'POST':
team = Team(title = request.form['title'],
intro = request.form['intro'])
image_url = request.form['image_url']
if image_url:
team.image_url = image_url
else:
team.image_url = app.config['DEFAULT_TEAM_IMG']
team.admins.append(user)
user.teams.append(team)
db.session.add(team)
db.session.commit()
# add tags
add_tags = request.form['tags'].split(',')
for t in add_tags:
t = t.strip()
if Tag.query.filter_by(title=t).count() == 0 and t:
new_t = Tag(title = t)
db.session.add(new_t)
team.tags.append(new_t)
db.session.commit()
return redirect(url_for('profile'))
return render_template('add_team.html',
title = 'add_team')
开发者ID:fairychild5,项目名称:yearbook,代码行数:33,代码来源:views.py
示例7: accept_invitation
def accept_invitation(uname):
user = user_manager.find_user_by_username(uname)
if user.team_id:
flash('This user has already formed a team with someone else. Please pick another teammate.', 'error')
return redirect(url_for('user'))
else:
team = Team()
team.members.append(current_user)
team.members.append(user)
team.name = current_user.username
db.session.add(team)
user.request_teammate = None
current_user.request_teammate = None
lst1 = db.session.query(User).filter(User.request_teammate==user.id).all()
lst2 = db.session.query(User).filter(User.request_teammate==current_user.id).all()
lst1.extend(lst2)
for usr in lst1:
usr.request_teammate = None
send_mail(usr, 'fail_invitation')
send_mail(user, 'new_team', u1=user, u2=current_user)
send_mail(current_user, 'new_team', u1=user, u2=current_user)
db.session.commit()
team.name = "New Team No." + str(team.id)
team.idea = Idea()
db.session.commit()
return redirect(url_for('team_page'))
开发者ID:berc-web,项目名称:berc_web,代码行数:32,代码来源:__init__.py
示例8: register
def register():
"""
Registration form
"""
from lib.forms.registration import RegistrationForm
from lib.database import db_session
form = RegistrationForm(request.form)
if request.method == 'POST' and form.validate():
from models import Team
team = Team(form.team_name.data, form.institution.data,
form.team_members.data, md5(form.password.data).hexdigest())
db_session.add(team)
# trying to add to db
try:
db_session.flush()
except:
form.team_name.errors.append(u'Команда с таким названием уже зарегистрирована.')
else:
# if success, generate TEAM_ID
team.generate_team_id()
db_session.commit()
# store session
session['team_id'] = team.team_id
return render_template('registration_success.html', team_id = team.team_id, active_register = True)
return render_template('registration.html', form = form, active_registration = True)
开发者ID:komissarex,项目名称:centipede,代码行数:25,代码来源:centipede.py
示例9: _create
def _create(self, args):
draft_id = args[0]
team = Team(draft_id=draft_id)
self._update_fields(team, self.request_body_json)
if team.order == 0:
team.is_turn = True
self.db.add(team)
self.db.commit()
return team.to_dict()
开发者ID:jkgneu12,项目名称:draft,代码行数:11,代码来源:api.py
示例10: init_teams
def init_teams():
'''
Initialize the Team table with the team names retrieved from Kimono.
It removes all the entries and re-adds them.
'''
logger.info('Initializing teams...')
url = settings.KIMONO['teams_url']
teams = _get_results_collection1(url)
teams_name = [team['name'] for team in teams]
for team_name in teams_name:
if not Team.objects.filter(name__iexact=team_name).exists():
t = Team()
t.name = team_name
t.save()
开发者ID:brescia123,项目名称:fg-backend,代码行数:14,代码来源:db_manager.py
示例11: create_accepted_scrim
def create_accepted_scrim():
from consts import UGC_PLATINUM
from consts import SCRIM_ACCEPTED
from datetime import datetime, timedelta
team1 = Team()
team1.name = "Team Test Finished Scrim1"
team1.skill_level = UGC_PLATINUM
team1.time_zone = "CET"
db.session.add(team1)
team2 = Team()
team2.name = "Team Test Finished Scrim2"
team2.skill_level = UGC_PLATINUM
team2.time_zone = "CET"
db.session.add(team2)
now = datetime.utcnow()
past_day = now - timedelta(days=now.weekday() - 4)
scrim_accepted = Scrim()
scrim_accepted.date = past_day
scrim_accepted.map1 = "Map1"
scrim_accepted.map2 = "Map2"
scrim_accepted.team1_id = team1.id
scrim_accepted.team1 = team1
scrim_accepted.team2_id = team2.id
scrim_accepted.team2 = team2
scrim_accepted.type = "Accepted scrim"
scrim_accepted.state = SCRIM_ACCEPTED
db.session.add(scrim_accepted)
db.session.commit()
return team1.id
开发者ID:gitter-badger,项目名称:scrimfinder,代码行数:35,代码来源:bots.py
示例12: create_team
def create_team(name, motto):
if Team.by_name(name) is not None:
logging.info("Team with name '%s' already exists, skipping" % (name))
return Team.by_name(name)
logging.info("Create Team: %s" % name)
team = Team(
name=unicode(name[:16]),
motto=unicode(motto[:32]),
)
level_0 = GameLevel.all()[0]
team.game_levels.append(level_0)
dbsession.add(team)
dbsession.flush()
return team
开发者ID:CRYPTOlab,项目名称:RootTheBox,代码行数:14,代码来源:helpers.py
示例13: ls
def ls(self):
current_user = self.get_current_user()
if self.get_argument('data').lower() == 'accounts':
data = {}
for team in Team.all():
if team == current_user.team:
continue
else:
data[team.name] = {
'money': team.money,
'flags': len(team.flags),
'bots': team.bot_count,
}
self.write({'accounts': data})
elif self.get_argument('data').lower() == 'users':
data = {}
target_users = User.not_team(current_user.team.id)
for user in target_users:
data[user.handle] = {
'account': user.team.name,
'algorithm': user.algorithm,
'password': user.bank_password,
}
self.write({'users': data})
else:
self.write({'Error': 'Invalid data type'})
self.finish()
开发者ID:CRYPTOlab,项目名称:RootTheBox,代码行数:27,代码来源:UpgradeHandlers.py
示例14: getTeamInfo
def getTeamInfo(self, team_key):
"""
Return a Team dict with basic information.
"""
memcache_key = "api_team_info_%s" % team_key
team_dict = memcache.get(memcache_key)
if team_dict is None:
team = Team.get_by_key_name(team_key)
if Team is not None:
team_dict = dict()
team_dict["key"] = team.key().name()
team_dict["team_number"] = team.team_number
team_dict["name"] = team.name
team_dict["nickname"] = team.nickname
team_dict["website"] = team.website
team_dict["event_keys"] = [a.event.key().name() for a in team.events]
team_dict["location"] = team.address
try:
team.do_split_address()
team_dict["location"] = team.split_address["full_address"]
team_dict["locality"] = team.split_address["locality"]
team_dict["region"] = team.split_address["region"]
team_dict["country"] = team.split_address["country"]
except Exception, e:
logging.error("Failed to include Address for api_team_info_%s" % team_key)
memcache.set(memcache_key, team_dict, 3600)
else:
return None
开发者ID:Apple101Review,项目名称:the-blue-alliance,代码行数:30,代码来源:api_helper.py
示例15: addTeamDetails
def addTeamDetails(self, team_dict, year):
"""
Consume a Team dict, and return it with a year's Events filtered and Matches added
"""
# TODO Matches should live under Events - gregmarra 1 feb 2011
# TODO Filter Events by year - gregmarra 1 feb 2011
memcache_key = "api_team_details_%s_%s" % (team_dict["key"], year)
matches_list = memcache.get(memcache_key)
if matches_list is None:
matches = list()
team = Team.get_by_key_name(team_dict["key"])
for e in [a.event for a in team.events]:
match_list = e.match_set.filter("team_key_names =", team.key().name()).fetch(500)
matches.extend(match_list)
matches_list = list()
for match in matches:
match_dict = dict()
match_dict["key"] = match.key().name()
match_dict["event"] = match.event.key().name()
match_dict["comp_level"] = match.comp_level
match_dict["set_number"] = match.set_number
match_dict["match_number"] = match.match_number
match_dict["team_keys"] = match.team_key_names
match_dict["alliances"] = simplejson.loads(match.alliances_json)
matches_list.append(match_dict)
memcache.set(memcache_key, matches_list, 600)
team_dict["matches"] = matches_list
return team_dict
开发者ID:Apple101Review,项目名称:the-blue-alliance,代码行数:32,代码来源:api_helper.py
示例16: edit_users
def edit_users(self):
''' Update user objects in the database '''
form = Form(
uuid="User not selected",
account="Please enter an account name",
handle="Please enter a handle name",
hash_algorithm="Please select a hash algorithm",
team_uuid="Please select a team",
)
if form.validate(self.request.arguments):
errors = []
user = User.by_uuid(self.get_argument('uuid'))
if user is not None:
# Update user account name
if user.account != self.get_argument('account'):
if User.by_account(self.get_argument('account')) is None:
logging.info("Updated user account %s -> %s" %
(user.account, self.get_argument('account'),))
user.account = unicode(self.get_argument('account'))
else:
errors.append("Account name is already in use")
# Update user handle
if user.handle != self.get_argument('handle'):
if User.by_handle(self.get_argument('handle')) is None:
logging.info("Updated user handle %s -> %s" %
(user.handle, self.get_argument('handle'),))
user.handle = unicode(self.get_argument('handle'))
else:
errors.append("Handle is already in use")
# Update hashing algoritm
if self.get_argument('hash_algorithm') in user.algorithms:
if user.algorithm != self.get_argument('hash_algorithm'):
if 0 < len(self.get_argument('password', '')):
logging.info("Updated %s's hashing algorithm %s -> %s" %
(user.handle, user.algorithm, self.get_argument('hash_algorithm'),)
)
user.algorithm = self.get_argument('hash_algorithm')
else:
errors.append("You must provide a password when updating the hashing algorithm")
else:
errors.append("Not a valid hash algorithm")
# Update password
if 0 < len(self.get_argument('password', '')):
user.password = self.get_argument('password')
# Update team
team = Team.by_uuid(self.get_argument('team_uuid'))
if team is not None:
if user.team_id != team.id:
logging.info("Updated %s's team %s -> %s" %
(user.handle, user.team_id, team.name))
user.team_id = team.id
else:
errors.append("Team does not exist in database")
dbsession.add(user)
dbsession.flush()
else:
errors.append("User does not exist")
self.render("admin/view/user_objects.html", errors=errors)
else:
self.render("admin/view/user_objects.html", errors=form.errors)
开发者ID:mach327,项目名称:RootTheBox,代码行数:60,代码来源:AdminHandlers.py
示例17: _create_or_get_team
def _create_or_get_team(team_name):
logging.info('create_or_get_team: {}'.format(team_name))
team = Team.query().filter(Team.name == team_name).get()
if not team:
team = Team(name = team_name)
logging.info('returning {}'.format(team))
return team
开发者ID:bojoer,项目名称:battle-code-runner,代码行数:7,代码来源:main.py
示例18: get
def get(self, user_token):
team = Team.all().filter('user_token =', user_token).get()
if team is None:
user_info = config_NOCOMMIT.pledge_service.loadPledgeInfo(user_token)
if user_info is None:
return self.notfound()
user_pledge_dollars = int(user_info["pledge_amount_cents"]) / 100
goal_dollars = user_pledge_dollars * 10
if user_info["name"]:
signature = "_Thank you,_\n\n_%s_" % user_info["name"]
else:
signature = "Thank you!"
title = user_info["name"] or DEFAULT_TITLE
form = TeamForm(data={
"goal_dollars": str(goal_dollars),
"title": title,
"zip_code": str(user_info["zip_code"] or ""),
"description": PREVIOUS_PLEDGE_DESC.format(
pledge_dollars=user_pledge_dollars,
signature=signature,
title=title)})
else:
self.add_to_user(team)
form = TeamForm(obj=team)
self.render_template("new_from_pledge.html", form=form)
开发者ID:Lessig2016,项目名称:teams,代码行数:25,代码来源:main.py
示例19: post
def post(self, *args, **kwargs):
''' Called to purchase an item '''
uuid = self.get_argument('uuid', '')
item = MarketItem.by_uuid(uuid)
if not item is None:
user = self.get_current_user()
team = Team.by_id(user.team.id) # Refresh object
if user.has_item(item.name):
self.render('market/view.html',
user=user,
errors=["You have already purchased this item."]
)
elif team.money < item.price:
message = "You only have $%d" % (team.money,)
self.render('market/view.html', user=user, errors=[message])
else:
logging.info("%s (%s) purchased the market item '%s' for $%d" % (
user.handle, team.name, item.name, item.price
))
self.purchase_item(team, item)
event = self.event_manager.create_purchased_item_event(user, item)
self.new_events.append(event)
self.redirect('/user/market')
else:
self.render('market/view.html',
user=self.get_current_user(),
errors=["Item does not exist."]
)
开发者ID:SYNchroACK,项目名称:RootTheBox,代码行数:28,代码来源:MarketHandlers.py
示例20: team_create
def team_create():
if not g.user:
return redirect('/login')
form = TeamForm(request.form)
if request.method == 'POST':
num_teams = g.user.teams.count()
max_teams = config_setting('USER_MAX_TEAMS', 0)
if max_teams >= 0 and num_teams >= max_teams and not g.user.admin:
flash('You already have the maximum number of teams ({}) stored'.format(num_teams))
elif form.validate():
data = form.data
public_team = data['public_team']
auths = form.get_auth_list()
team = Team.create(g.user, data['name'],
data['country_flag'], data['logo'], auths, public_team)
db.session.commit()
app.logger.info(
'User {} created team {}'.format(g.user.id, team.id))
return redirect('/teams/{}'.format(team.user_id))
else:
get5.flash_errors(form)
return render_template('team_create.html', user=g.user, form=form,
edit=False, is_admin=g.user.admin)
开发者ID:mattikus,项目名称:get5-web,代码行数:31,代码来源:team.py
注:本文中的models.Team类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论