当前位置: 首页>>代码示例>>Python>>正文


Python models.Team类代码示例

本文整理汇总了Python中models.Team的典型用法代码示例。如果您正苦于以下问题:Python Team类的具体用法?Python Team怎么用?Python Team使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Team类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的models.Team类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。