示例#1
0
    def askforleave(cls, match_id, status):
        match = Match.getone(match_id)
        people = People.getone(current_user.key_id)
        if people and people.key in match.registerdPeople:
            logging.debug("You have already signed up! Now switch leave")
            play = Play.getbyMatchPeople(match_id, current_user.key_id)
            if play:
                play.leave = status
                play.put()
        elif people and people.key:
            match.signup(current_user.key_id)
            Play.create(current_user.key_id, match_id, leave=status)
        memcache.flush_all()

        return True
示例#2
0
    def signup(cls, match_id, code):
        match = Match.getone(match_id)

        people = People.getone(current_user.key_id)
        if people and people.key in match.registerdPeople:
            logging.debug("You have already signed up")
            return True

        if match and code == match.signupCode:
            logging.debug("Sign up user {}".format(current_user.key_id))
            match.signup(current_user.key_id)
            Play.create(current_user.key_id, match_id)
            memcache.flush_all()
            return True
        return False
示例#3
0
    def get(self, match_id):
        registered_people = memcache.get(match_id, "match_players")
        if not registered_people:

            match = Match.getone(match_id)
            if match is None:
                raise MatchNotExistsError
            registered_people = []
            for ple in match.registerdPeople:
                player = ple.get()
                play = Play.getbyMatchPeople(match_id, player.key.id())

                registered_people.append({
                    "name": player.name,
                    "id": player.key.id(),
                    "playId": play.key.id(),
                    "signupTime": play.signupTime,
                    "signinTime": play.signinTime,
                    "admin": player.admin,
                    "team": play.team or None,
                    "leave": play.leave,
                    "signupMissing": play.signupMissing,
                    "signinOntime": True if play.signinTime and play.signinTime <= match.signinLatest else False,
                    "signinLate": True if play.signinTime and play.signinTime > match.signinLatest else False,
                    "finePaid": 0 if play.finePaid is None else play.finePaid
                })
            memcache.set(match_id, registered_people, namespace="match_players")
        else:
            logging.debug("get match players from memcache")

        return {"people": registered_people}
示例#4
0
    def get(self):
        plays = Play.getbyPeople(current_user.key_id)
        leaves = 0
        signups = 0
        ontime = 0
        late = 0
        finePaid = 0
        vistors = 0
        for play in plays:
            match = play.match.get()
            if match.status is not None and match.status == 'OPEN':
                logging.debug("play")
                if play.leave:
                    leaves = leaves + 1
                else:
                    signups = signups + 1
                if play.isOntime():
                    ontime = ontime + 1
                if not play.leave and play.isLate():
                    late = late + 1
                if play.signupMissing:
                    vistors = vistors + 1
                finePaid += play.finePaid

        return {
            "leave": leaves,
            "signup": signups,
            "ontime": ontime,
            "late": late,
            "vistor": vistors,
            "finePaid": finePaid
        }
示例#5
0
    def get(self):
        plays = Play.getbyPeople(current_user.key_id)
        leaves = 0
        signups = 0
        ontime = 0
        late = 0
        finePaid = 0
        vistors = 0
        for play in plays:
            match = play.match.get()
            if match.status is not None and match.status == 'OPEN':
                logging.debug("play")
                if play.leave:
                    leaves = leaves + 1
                else:
                    signups = signups + 1
                if play.isOntime():
                    ontime = ontime + 1
                if not play.leave and play.isLate():
                    late = late + 1
                if play.signupMissing:
                    vistors = vistors + 1
                finePaid += play.finePaid

        return {"leave": leaves, "signup": signups, "ontime":ontime, "late": late, "vistor": vistors, "finePaid" : finePaid}
示例#6
0
    def get(self, match_id):
        plays = Play.getbyMatch(match_id)
        for play in plays:
            play.__setattr__('people_detail', play.people.get())
            play.__setattr__('id', play.key.id())

        return {"plays": plays}
示例#7
0
    def get(self, match_id):
        plays = Play.getbyMatch(match_id)
        for play in plays:
            play.__setattr__('people_detail', play.people.get())
            play.__setattr__('id', play.key.id())

        return {"plays": plays}
示例#8
0
    def get(self):
        plays = Play.getall()
        for play in plays:
            play.__setattr__('match_detail', play.match.get())
            play.__setattr__('people_detail', play.people.get())
            play.__setattr__('id', play.key.id())

        return {"plays": plays}
示例#9
0
    def manualFine(cls, match_id, people_id, dollar):

        play = Play.getbyMatchPeople(match_id, people_id)
        play.finePaid = dollar
        play.put()

        memcache.flush_all()
        return {"status": True}
示例#10
0
    def get(self):
        plays = Play.getall()
        for play in plays:
            play.__setattr__('match_detail', play.match.get())
            play.__setattr__('people_detail', play.people.get())
            play.__setattr__('id', play.key.id())

        return {"plays": plays}
示例#11
0
    def manualSignin(cls, match_id, people_id):
        match = Match.getone(match_id)
        match.signin(people_id)

        play = Play.getbyMatchPeople(match_id, people_id)
        play.signinTime = match.signinLatest
        play.put()
        memcache.flush_all()
        return {"status": True}
示例#12
0
 def post(self, play_id):
     play = Play.getone(play_id)
     if not play:
         raise PlayNotExistsError
     args = teamup_parser.parse_args()
     team = args.get('team')
     play.team = team
     play.put()
     memcache.flush_all()
     return {"status": True}
示例#13
0
 def post(self, play_id):
     play = Play.getone(play_id)
     if not play:
         raise PlayNotExistsError
     args = teamup_parser.parse_args()
     team = args.get('team')
     play.team = team
     play.put()
     memcache.flush_all()
     return {"status": True}
示例#14
0
    def post(self):
        logging.debug("creating play")
        args = parser.parse_args()
        play = Play.create(args.get('peopleId'), args.get('matchId'))
        play_details = args
        play_details['id'] = play.id()

        match = Match.getone(args.get('matchId'))
        match.register(args.get('peopleId'))

        logging.debug(match)

        return {'play': play_details}
示例#15
0
    def post(self):
        logging.debug("creating play")
        args = parser.parse_args()
        play = Play.create(args.get('peopleId'), args.get('matchId'))
        play_details = args
        play_details['id'] = play.id()

        match = Match.getone(args.get('matchId'))
        match.register(args.get('peopleId'))

        logging.debug(match)

        return {'play': play_details}
示例#16
0
    def get(self):
        matches = Match.getall()
        matches_json = []
        for match in matches:
            plays = Play.getbyMatch(match.key.id())
            leaves = 0
            ontimes = 0
            for play in plays:

                if play.leave:
                    leaves += 1
                if play.signinTime and play.signinTime <= match.signinLatest:
                    ontimes += 1

            matches_json.append({
                "id": match.key.id(),
                "start": match.startTime,
                "leave": leaves,
                "ontime": ontimes,
                "signup": len(match.registerdPeople)
            })
        return {"matches": matches_json}
示例#17
0
    def signin(cls, match_id, code):
        match = Match.getone(match_id)

        if datetime.now() < match.signinEarliest:
            logging.debug("You are too early for sign in")
            return {"status": False, "reason": "You are too early for sign in", "code": -1}
        if datetime.now() > match.signinLatest:
            logging.debug("You are too late for sign in")
            logging.debug("Sign in user {}".format(current_user.key_id))
            match.signin(current_user.key_id)

            play = Play.getbyMatchPeople(match_id, current_user.key_id)

            if play is None:
                logging.debug("this guy didn't sign up, but is sign-in now")
                match.signup(current_user.key_id)
                Play.create(current_user.key_id, match_id, missing=True)
            else:
                play.signinTime = datetime.now()
                play.put()
            memcache.flush_all()

            return {"status": False, "reason": "You are too late for sign in", "code": 1}

        people = People.getone(current_user.key_id)
        if people and people.key in match.participatedPeople:
            logging.debug("You have already signed in")
            return {"status": False, "reason": "You have already signed in", "code": 0}

        if match and code == match.signinCode:
            logging.debug("Sign in user {}".format(current_user.key_id))
            match.signin(current_user.key_id)
            play = Play.getbyMatchPeople(match_id, current_user.key_id)

            if play is None:
                logging.debug("this guy didn't sign up, but is sign-in now")
                match.signup(current_user.key_id)
                Play.create(current_user.key_id, match_id, missing=True)
            else:
                play.signinTime = datetime.now()
                play.put()

            memcache.flush_all()

            return {"status": True}
        return {"status": False}
示例#18
0
 def get(self):
     matches_json = memcache.get("matches")
     if not matches_json:
         matches = Match.getall()
         matches_json = []
         for match in matches:
             plays = Play.getbyMatch(match.key.id())
             leaves = [play for play in plays if play.leave]
             matches_json.append({
                 "id": match.key.id(),
                 "location": match.location,
                 "startTime": match.startTime,
                 "finishTime": match.finishTime,
                 "signinEarliest": match.signinEarliest,
                 "signinLatest": match.signinLatest,
                 "createdTime": match.createdTime,
                 "noleaves": len(leaves),
                 "nosignups": len(match.registerdPeople),
                 "status": match.status
             })
         memcache.set("matches", matches_json)
     else:
         logging.debug("get matches from memcache")
     return {'matches': matches_json}