コード例 #1
0
 def teamdata(self, request, response, pathmatch):
     team = Team(id=pathmatch.group('id'))
     print(team.members()[0])
     response.send_template("ajax_teamdata.mustache", {
         'team': [team],
         'persons': team.members()
     })
コード例 #2
0
    def new_team(self, request, response, pathmatch):

        if 'name' not in request.params or not request.params['name']:
            response.send(code=400, body="<p>Nicht alle notwendigen Felder ausgefüllt. 'Name' fehlt.</p>")
            return

        persons = []
        if 'person' in request.params and request.params['person']:
            if isinstance(request.params['person'], list):
                persons = request.params['person']
            else:
                persons = [request.params['person']]
        team = Team(name=request.params['name'], persons=persons)

        team.store()

        response.send(code=200, body="")
コード例 #3
0
    def new_person(self, request, response, pathmatch):

        d=dict()

        for p in ['firstname', 'lastname', 'email']:
            if p not in request.params or not request.params[p]:
                response.send(code=400, body="<p>Nicht alle notwendigen Felder ausgefüllt. {} fehlt.</p>".format(p))
                return
            d[p]=request.params[p]

        for p in ['hobby', 'team']:
            if p in request.params and request.params[p]:
                if isinstance(request.params[p], list):
                    d[p]=request.params[p]
                else:
                    d[p]=[request.params[p]]
            else:
                d[p]=[]

        person = Person(firstname=d['firstname'], lastname=d['lastname'], email=d['email'], hobbies=d['hobby'])
        person.store()

        for tid in d['team']:
            try:
                team = Team(id=tid)
                team.add_person(person)
                team.store()
            except Exception:
                pass

        response.send(code=200, body="")
コード例 #4
0
 def delete_person_team(self, request, response, pathmatch):
     """Remove a person from an existing team."""
     person = Person(id=pathmatch.group('id'))
     try:
         team = Team(id=pathmatch.group('teamid'))
         team.remove_person(person)
         team.store()
         response.send(code=200, body="")
     except Exception: # TODO: raise better exceptions in team model class
         response.send(code=404, body="Team does not exists.")
コード例 #5
0
 def new_person_form(self, request, response, pathmatch):
     teams = Team.find()
     response.send_template("ajax_new_person.mustache", locals())
コード例 #6
0
 def persondata(self, request, response, pathmatch):
     person = Person(id=pathmatch.group('id'))
     response.send_template("ajax_persondata.mustache", {'person': [person], 'teams': person.get_teams(), 'allteams': Team.find()})
コード例 #7
0
 def delete_team(self, request, response, pathmatch):
     team = Team(id=pathmatch.group('id'))
     team.delete();
     response.send(code=200, body="")
コード例 #8
0
 def teams(self, request, response, pathmatch):
     teams = Team.find()
     response.send_template("ajax_teams.mustache", {'teams': teams})
コード例 #9
0
 def teamlist(self, request, response, pathmatch):
     teams = Team.find()
     response.send_template("teams.mustache", {})