示例#1
0
    def post(self):
        user_email = self.request.get('user_email')

        user_query = LegacyUser.query(LegacyUser.email == user_email)
        user = user_query.get()
        user_id = None

        if user is None:
            self.response.headers['Content-Type'] = 'application/json'
            self.response.write(json.dumps({
                'success': False
            }))
            return
        else:
            user_id = user.key.id()

        team_name = self.request.get('team_name')
        members = json.loads(self.request.get('members'))

        team = Team(
            name = team_name,
            user = user_id,
            guts_scores = self.request.get('guts_scores'),
            team_scores = self.request.get('team_scores'),
            paid = False,
            year = 2013
        )
        team.put()

        team_id = team.key.id()

        for member in members:
            individual = Individual(
                name = member['name'],
                team = team_id,
                user = user_id,
                paid = True,
                year = 2013,

                speed_scores = member['speed_scores'],
                accuracy_scores = member['accuracy_scores']
            )

            individual.put()

        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(json.dumps({
            'success': True
        }))
示例#2
0
    def post(self):
        user_email = self.request.get('user_email')

        user_query = LegacyUser.query(LegacyUser.email == user_email)
        user = user_query.get()
        user_id = None

        if user is None:
            self.response.headers['Content-Type'] = 'application/json'
            self.response.write(json.dumps({'success': False}))
            return
        else:
            user_id = user.key.id()

        team_name = self.request.get('team_name')
        members = json.loads(self.request.get('members'))

        team = Team(name=team_name,
                    user=user_id,
                    guts_scores=self.request.get('guts_scores'),
                    team_scores=self.request.get('team_scores'),
                    paid=False,
                    year=2013)
        team.put()

        team_id = team.key.id()

        for member in members:
            individual = Individual(name=member['name'],
                                    team=team_id,
                                    user=user_id,
                                    paid=True,
                                    year=2013,
                                    speed_scores=member['speed_scores'],
                                    accuracy_scores=member['accuracy_scores'])

            individual.put()

        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(json.dumps({'success': True}))
示例#3
0
    def post(self):

        # Create and insert a record
        # for this registration.
        user_id = int(self.auth.get_user_by_session()['user_id'])
        query = Individual.query(Individual.user == user_id, Individual.year == YEAR)

        for member in query:
            member.key.delete()

        individuals = json.loads(self.request.get('individuals'))

        for individual in individuals:
            record = Individual(
                    name = individual['name'],
                    team = individual['team'],
                    user = user_id,
                    paid = (individual['paid'] if 'paid' in individual else False),
                    year = YEAR
            )
            record.put()

        teams = json.loads(self.request.get('teams'))

        for team in teams:
            print team
            record = Team.get_by_id(team['id'])
            record.name = team['name']
            record.put()

        user = self.user_model.get_by_id(user_id)
        user.refresh()
        user.put()

        # Inform the client of success.
        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(json.dumps({
            'success': True
        }))
示例#4
0
    def post(self):

        # Create and insert a record
        # for this registration.
        user_id = int(self.auth.get_user_by_session()['user_id'])
        query = Individual.query(Individual.user == user_id,
                                 Individual.year == YEAR)

        for member in query:
            member.key.delete()

        individuals = json.loads(self.request.get('individuals'))

        for individual in individuals:
            record = Individual(
                name=individual['name'],
                team=individual['team'],
                user=user_id,
                paid=(individual['paid'] if 'paid' in individual else False),
                year=YEAR)
            record.put()

        teams = json.loads(self.request.get('teams'))

        for team in teams:
            print team
            record = Team.get_by_id(team['id'])
            record.name = team['name']
            record.put()

        user = self.user_model.get_by_id(user_id)
        user.refresh()
        user.put()

        # Inform the client of success.
        self.response.headers['Content-Type'] = 'application/json'
        self.response.write(json.dumps({'success': True}))