Exemplo n.º 1
0
    def read(challenge):
        """
        This method is in used to access the data of a challenge in a format processable by the front end.

        :param challenge:
        :return: Challenge object, data dictionary to be returned to the user
        """
        challenge = DynamicChallenge.query.filter_by(id=challenge.id).first()
        from fyp import generateDifficulty
        from CTFd.models import Likes
        difficulty = generateDifficulty(challenge.difficulty)
        data = {
            'id': challenge.id,
            'name': challenge.name,
            'value': challenge.value,
            'initial': challenge.initial,
            'decay': challenge.decay,
            'minimum': challenge.minimum,
            'description': challenge.description,
            'category': challenge.category,
            'state': challenge.state,
            'max_attempts': challenge.max_attempts,
            'type': challenge.type,
            'difficulty': difficulty,
            'like_count': Likes.getCount(challenge.id),
            'liked': Likes.checkUserLike(challenge.id).count(),
            'type_data': {
                'id': DynamicValueChallenge.id,
                'name': DynamicValueChallenge.name,
                'templates': DynamicValueChallenge.templates,
                'scripts': DynamicValueChallenge.scripts,
            }
        }
        return data
Exemplo n.º 2
0
    def read(challenge):
        """
        This method is in used to access the data of a challenge in a format processable by the front end.

        :param challenge:
        :return: Challenge object, data dictionary to be returned to the user
        """
        from fyp import generateDifficulty
        difficulty = generateDifficulty(challenge.difficulty)
        data = {
            'id': challenge.id,
            'name': challenge.name,
            'value': challenge.value,
            'description': challenge.description,
            'category': challenge.category,
            'state': challenge.state,
            'max_attempts': challenge.max_attempts,
            'type': challenge.type,
            'difficulty': difficulty,
            'type_data': {
                'id': CTFdStandardChallenge.id,
                'name': CTFdStandardChallenge.name,
                'templates': CTFdStandardChallenge.templates,
                'scripts': CTFdStandardChallenge.scripts,
            }
        }
        return data