Exemplo n.º 1
0
    def get(self):
        self._current_user = self.require_login()
        if not self._current_user:
            self.authenticate()
            return

        self._current_user.hackers = Hacker.all().filter("user ="******"user": self._current_user}))
Exemplo n.º 2
0
    def get(self):
        hackers = list(Hacker.all())
        if hackers:
            hackers.sort(key=lambda h: (h.score, h.handle))
            rank = 0
            ranked_hackers = [(rank, hackers[-1])]
            for i in range(len(hackers) - 2, 0, -1):
                if hackers[i + 1].score_cache != hackers[i].score_cache:
                    rank += 1
                ranked_hackers.append((rank, hackers[i]))
        else:
            ranked_hackers = []

        self.render_template('members', {'hackers': ranked_hackers})
Exemplo n.º 3
0
 def get(self):
     hackers = list(Hacker.all())
     if hackers:
         hackers.sort(key=lambda h:(h.score,h.handle))
         rank = 0
         ranked_hackers = [(rank, hackers[-1])]
         for i in range(len(hackers)-2, 0, -1):
             if hackers[i + 1].score_cache != hackers[i].score_cache:
                 rank += 1
             ranked_hackers.append((rank, hackers[i]))
     else:
         ranked_hackers = []
         
     self.render_template('members', {'hackers': ranked_hackers})
Exemplo n.º 4
0
    def get(self):
        self._current_user = self.require_login()
        if not self._current_user:
            self.authenticate()
            return

        token = initChannel(self._current_user.id)
        #Resolve hackers for this user
        self._current_user.hackers = Hacker.all().filter("user ="******"/create")

        path = os.path.join(os.path.dirname(__file__), 'loadout.html')
        self.response.out.write(template.render(path, {"user": self._current_user, "token": token}))
Exemplo n.º 5
0
    def get(self):
        self._current_user = self.require_login()
        if not self._current_user:
            self.authenticate()
            return

        match = getCurrentMatchByUser(self._current_user.id)
        if not match:
            self.redirect("/loadout")
            return

        #Resolve hacker ids to actual hacker data
        hacker_list = {}
        for hacker in match.hacker_list:
            hacker_instance = Hacker.get(hacker)
            hacker_list[str(hacker_instance.key())] = {"first_name": hacker_instance.first_name,
                             "last_name": hacker_instance.last_name,
                             "talents": hacker_instance.talents,
                             "imgset": hacker_instance.imageset,
                             "base": {"energy": hacker_instance.base_energy,
                                      "productivity": hacker_instance.base_productivity,
                                      "teamwork": hacker_instance.base_teamwork}}

        #Resolve hackers for this user
        self._current_user.hackers = Hacker.all().filter("user ="******"user": self._current_user,
                                                        "users": users,
                                                        "hackathon": match,
                                                        "hackers": json.dumps(hacker_list),
                                                        "project": project,
                                                        "token": token}))
Exemplo n.º 6
0
    def get(self):
        self._current_user = self.require_login()
        if not self._current_user:
            self.response.out.write(json.dumps({"error": "please log in"}))
            return

        q = Queue.all().get()
        if not q:
            q = Queue()

        #Push onto queue
        if str(self._current_user.id) in q.users:
            self.response.out.write(json.dumps({"success": "already in queue"}))
        elif len(q.users) == 0:
            q.users = [self._current_user.id]
            self.response.out.write(json.dumps({"success": "added to queue"}))
        else: #Found a match. Pop & Serve
            matched = q.users[0]
            q.users = q.users[1:]

            #Randomly choose a project
            projects = Project.all().fetch(1000)
            random.seed()
            project = random.choice(projects)

            #Actually create the match
            match = Match(project_id = str(project.key()),
                          users = [self._current_user.id, matched],
                          outcome = [0, 0])

            hackers = Hacker.all().filter("user IN", match.users).fetch(8)
            match.hacker_list = []
            for hacker in hackers:
                match.hacker_list.append(str(hacker.key()))

            match.put()

            #Notify the users via socket
            broadcast(match, json.dumps({"success": "match found"}))
            self.response.out.write("herp")
        q.put()
Exemplo n.º 7
0
 def get(self):
     self.render_template('admin', {
         'badges': Badge.all(),
         'hackers': Hacker.all()
     })
Exemplo n.º 8
0
 def get(self):
     for h in Hacker.all().fetch(1000):
         h.delete()
     for m in Match.all().fetch(1000):
         m.delete()
     self.response.out.write("Datastore cleared of matches & hackers");
Exemplo n.º 9
0
 def get(self):
     self.render_template('admin', {'badges': Badge.all(),
                                    'hackers': Hacker.all()})