示例#1
0
def puzzle(puzzle_id):
    if (app.config["SITE_MODE"]
            if app.config["SITE_MODE"] else 'live') not in ['live']:
        abort(403)

    if not cube.is_puzzle_unlocked(app, puzzle_id):
        abort(403)

    if request.method == "POST":
        if "submission" in request.form:
            cube.create_submission(app, puzzle_id, request.form["submission"])
            return redirect(url_for('puzzle', puzzle_id=puzzle_id))
        elif "hintrequest" in request.form:
            cube.create_hint_request(app, puzzle_id,
                                     request.form["hintrequest"],
                                     request.form["hinttype"])
            return redirect(url_for('puzzle', puzzle_id=puzzle_id))
        elif "interactionrequest" in request.form:
            cube.create_interaction_request(app, puzzle_id,
                                            request.form["interactionrequest"])
            return redirect(url_for('puzzle', puzzle_id=puzzle_id))
        else:
            abort(400)

    submissions = cube.get_submissions(app, puzzle_id)
    puzzle = cube.get_puzzle(app, puzzle_id)
    visibility = cube.get_puzzle_visibility(app, puzzle_id)
    hints = cube.get_hints(app, puzzle_id)
    interactions = [
        i for i in cube.get_interactions(app, puzzle_id)
        if i['invisible'] != 'YES'
    ]
    team_properties = cube.get_team_properties(app)

    url = "puzzle.html"

    r = make_response(
        render_template(url,
                        puzzle_id=puzzle_id,
                        puzzle=puzzle,
                        submissions=submissions,
                        visibility=visibility,
                        hints=hints,
                        interactions=interactions,
                        team_properties=team_properties))
    r.headers.set('Cache-Control', 'private, max-age=0, no-cache, no-store')
    return r
示例#2
0
def full_solution(puzzle_id):
    try:
        puzzle = cube.get_puzzle(app, puzzle_id)
        canonical_puzzle_id = puzzle.get('puzzleId')
        puzzle_round_id = [
            r_id for r_id, round_puzzle_ids in ROUND_PUZZLE_MAP.iteritems()
            if canonical_puzzle_id in round_puzzle_ids
        ]
        puzzle_round_id = puzzle_round_id[0] if len(
            puzzle_round_id) > 0 else None
        emotions = puzzle.get('puzzleProperties',
                              {}).get('EmotionsProperty',
                                      {}).get('emotions', [])
    except HTTPError as e:
        if e.response.status_code != 404:
            raise

        puzzle = {
            'puzzleId': puzzle_id,
            'puzzleProperties': {
                'DisplayNameProperty': {
                    'displayName': puzzle_id
                },
                'AnswersProperty': {
                    'answers': [{
                        'canonicalAnswer': 'FLOATER ANSWER'
                    }]
                },
            },
        }
        puzzle_round_id = 'floaters'
        emotions = []

    core_display_data = get_full_path_core_display_data()

    return render_template("solutions/%s.html" % puzzle_id,
                           core_display_data=core_display_data,
                           is_hunt_started=True,
                           puzzle_id=puzzle_id,
                           puzzle_round_id=puzzle_round_id,
                           emotions=emotions,
                           puzzle=puzzle,
                           puzzle_visibility={'status': 'SOLVED'},
                           solution=True)
def full_puzzle(puzzle_id):
    try:
        puzzle = cube.get_puzzle(app, puzzle_id)
        canonical_puzzle_id = puzzle.get('puzzleId')
        puzzle_round_id = [
            r_id for r_id, round_puzzle_ids in ROUND_PUZZLE_MAP.iteritems()
            if canonical_puzzle_id in round_puzzle_ids
        ]
        puzzle_round_id = puzzle_round_id[0] if len(
            puzzle_round_id) > 0 else None
    except:
        puzzle = None
        puzzle_round_id = None
    core_display_data = get_full_path_core_display_data()
    return render_template("puzzles/%s.html" % puzzle_id,
                           core_display_data=core_display_data,
                           puzzle_id=puzzle_id,
                           puzzle_round_id=puzzle_round_id,
                           puzzle=puzzle)
示例#4
0
def puzzle(puzzle_id):
    if (app.config["SITE_MODE"] if app.config["SITE_MODE"] else 'live') not in ['live']:
        abort(403)
      
    if not cube.is_puzzle_unlocked(app, puzzle_id):
        abort(403)

    if request.method == "POST":
        if "submission" in request.form:
            cube.create_submission(app, puzzle_id, request.form["submission"])
            return redirect(url_for('puzzle', puzzle_id = puzzle_id))
        elif "hintrequest" in request.form:
            cube.create_hint_request(app, puzzle_id, request.form["hintrequest"])
            return redirect(url_for('puzzle', puzzle_id = puzzle_id))
        elif "interactionrequest" in request.form:
            cube.create_interaction_request(app, puzzle_id, request.form["interactionrequest"])
            return redirect(url_for('puzzle', puzzle_id = puzzle_id))
        else:
            abort(400)

    submissions = cube.get_submissions(app, puzzle_id)
    puzzle = cube.get_puzzle(app, puzzle_id)
    visibility = cube.get_puzzle_visibility(app, puzzle_id)
    hints = cube.get_hints(app, puzzle_id)
    interactions = cube.get_interactions(app, puzzle_id)
    team_properties = cube.get_team_properties(app)

    return render_template(
        "puzzle.html",
        puzzle_id=puzzle_id,
        puzzle=puzzle,
        submissions=submissions,
        visibility=visibility,
        hints=hints,
        interactions=interactions,
        team_properties=team_properties)
示例#5
0
                if e.response is None:
                    raise e
                flash("Failed to update submission: %s" % e.response.json())
                return redirect(url_for("callqueue"))

            if request.form["status"] == "SUBMITTED":
                return redirect(url_for("callqueue"))
        else:
            abort(400)

    time.sleep(0.2)

    submission = cube.get_submission(app, submission_id)
    past_submissions = cube.get_submissions(app, submission['puzzleId'], submission['teamId'])
    past_submissions = [s for s in past_submissions if s['submissionId'] != submission_id]
    puzzle = cube.get_puzzle(app, submission['puzzleId'])
    team = cube.get_team_properties(app, team_id=submission['teamId'])

    return render_template(
        "submission.html",
        submission=submission,
        past_submissions=past_submissions,
        puzzle=puzzle,
        team=team)

@app.route("/hintrequest/<int:hint_request_id>", methods=["GET", "POST"])
@login_required.writingteam
def hintrequest(hint_request_id):
    if request.method == "POST":
        if "status" in request.form:
            response = ""
示例#6
0
def full_puzzle(puzzle_id):
    puzzle = {
        'puzzleId': puzzle_id,
        'puzzleProperties': {
            'DisplayNameProperty': {
                'displayName': puzzle_id
            }
        },
    }
    puzzle_round_id = 'floaters'
    emotions = []
    feeders = set()
    feeder_properties = {}

    try:
        puzzle = cube.get_puzzle(app, puzzle_id)

        canonical_puzzle_id = puzzle.get('puzzleId')
        puzzle_round_id = [
            r_id for r_id, round_puzzle_ids in ROUND_PUZZLE_MAP.iteritems()
            if canonical_puzzle_id in round_puzzle_ids
        ]
        puzzle_round_id = puzzle_round_id[0] if len(
            puzzle_round_id) > 0 else None
        emotions = puzzle.get('puzzleProperties',
                              {}).get('EmotionsProperty',
                                      {}).get('emotions', [])

        feeders = puzzle.get('puzzleProperties',
                             {}).get('FeedersProperty', {}).get('feeders', [])
        if feeders:
            feeder_properties_async = cube.get_all_puzzle_properties_for_list_async(
                app, feeders)
            feeder_properties = {
                v['puzzleId']: v
                for v in feeder_properties_async.result().json().get(
                    'puzzles', [])
            }
            feeders.sort(key=lambda puzzleId: feeder_properties[puzzleId].get(
                'puzzleProperties', {}).get('SymbolProperty', {}).get(
                    'symbol', ''))

    except HTTPError as e:
        if e.response.status_code != 404:
            raise

    core_display_data = get_full_path_core_display_data()

    pages_without_solutions_async = cube.get_all_puzzle_properties_for_list_async(
        app, ALL_PUZZLES)
    pages_without_solutions = [
        v.get('puzzleProperties', {}).get('DisplayIdProperty',
                                          {}).get('displayId', '')
        for v in pages_without_solutions_async.result().json().get(
            "puzzles", [])
    ]

    return render_template("puzzles/%s.html" % puzzle_id,
                           core_display_data=core_display_data,
                           is_hunt_started=True,
                           puzzle_id=puzzle_id,
                           puzzle_round_id=puzzle_round_id,
                           emotions=emotions,
                           puzzle=puzzle,
                           puzzle_visibility={'status': 'UNLOCKED'},
                           feeders_solved=feeders,
                           feeder_count=len(feeders),
                           feeder_properties=feeder_properties,
                           pages_without_solutions=pages_without_solutions)