def _update(self):
        self.dirty = False

        challenge_points = { 
            challenge : monitor.metadata(challenge)['points']
            for challenge in monitor.challenges
        }

        entries = []

        for user in auth.users:
            if not auth.is_playing(user):
                continue

            user_points = 0
            user_captures = 0
            user_last_capture_timestamp = float('-inf')
            for challenge, timestamp in scoreboard.get_captures_by_user(user):
                user_captures += 1
                user_points += challenge_points[challenge]
                if user_last_capture_timestamp < float(timestamp):
                    user_last_capture_timestamp = float(timestamp)

            entries.append((user, user_points, user_captures, user_last_capture_timestamp))
        
        self.scoreboard_list = sorted(entries, key=lambda e: (e[1], -e[3]), reverse=True)
Example #2
0
    def _update(self):
        self.dirty = False

        challenge_points = {
            challenge: monitor.metadata(challenge)['points']
            for challenge in monitor.challenges
        }

        entries = []

        for user in auth.users:
            if not auth.is_playing(user):
                continue

            user_points = 0
            user_captures = 0
            user_last_capture_timestamp = float('-inf')
            for challenge, timestamp in scoreboard.get_captures_by_user(user):
                user_captures += 1
                user_points += challenge_points[challenge]
                if user_last_capture_timestamp < float(timestamp):
                    user_last_capture_timestamp = float(timestamp)

            entries.append((user, user_points, user_captures,
                            user_last_capture_timestamp))

        self.scoreboard_list = sorted(entries,
                                      key=lambda e: (e[1], -e[3]),
                                      reverse=True)
Example #3
0
    def get(self, challenge):
        status = monitor.status(challenge)
        metadata = monitor.metadata(challenge)
        if status == None or metadata == None:
            raise tornado.web.HTTPError(404)

        if not self.is_admin and not status['visible']:
            raise tornado.web.HTTPError(404)

        status_widget = make_status_widget(self, status, metadata,
                                           self.is_admin)

        self.render(
            'templates/challenge.html',
            user=self.user,
            selected='challenges',
            challenge_files=metadata.get('public_files', []),
            challenge_name=metadata.get('name', challenge),
            challenge_author=metadata.get('author', 'Anonymous'),
            challenge_points=metadata.get('points', 0),
            challenge_solves=len(
                scoreboard.get_captures_by_challenge(challenge)),
            challenge_description=metadata.get('description', ''),
            show_capture=auth.is_playing(self.user or ''),
            status=status_widget,
        )
    def get(self, challenge):
        status = monitor.status(challenge)
        metadata = monitor.metadata(challenge)
        if status == None or metadata == None:
            raise tornado.web.HTTPError(404)

        if not self.is_admin and not status['visible']:
            raise tornado.web.HTTPError(404)

        status_widget = make_status_widget(self, status, metadata, self.is_admin)

        self.render('templates/challenge.html',
            user=self.user,
            selected='challenges',
            challenge_files=metadata.get('public_files', []),
            challenge_name=metadata.get('name', challenge),
            challenge_author=metadata.get('author', 'Anonymous'),
            challenge_points=metadata.get('points', 0),
            challenge_solves=len(scoreboard.get_captures_by_challenge(challenge)),
            challenge_description=metadata.get('description', ''),
            show_capture=auth.is_playing(self.user or ''),
            status=status_widget,
        )
 def is_playing(self):
     username = self.get_secure_cookie('user')
     if not username:
         return False
     else:
         return auth.is_playing(username)
Example #6
0
 def is_playing(self):
     username = self.get_secure_cookie('user')
     if not username:
         return False
     else:
         return auth.is_playing(username)