Verified Commit c46e3bd7 authored by Elger Jonker's avatar Elger Jonker

[wip] adding map to the game

parent b8be9edc
Pipeline #38792843 passed with stage
in 17 minutes and 34 seconds
......@@ -65,6 +65,9 @@
}
</style>
{% block head %}
{% endblock %}
</head>
<body>
......@@ -80,6 +83,7 @@
<li class="nav-item"><a class="nav-link" href="/game/scores/">Scores</a></li>
<li class="nav-item"><a class="nav-link" href="/game/contests/">Contest</a></li>
<li class="nav-item"><a class="nav-link" href="/game/team/">Teams</a></li>
<li class="nav-item"><a class="nav-link" href="/game/map/">Map</a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Submit Organization <span class="caret"></span></a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
......@@ -109,6 +113,9 @@
</div>
</nav>
{% block fullwidth %}
{% endblock %}
<div id="wrap">
<div class="container">
......
{% extends 'game/base.html' %}{% load static %}
{% block head %}
<link rel="stylesheet" type="text/css" href="{% static '/css/vendor/leaflet.css' %}"/>
<link rel="stylesheet" type="text/css" href="{% static '/css/vendor/leaflet.fullscreen.css' %}">
<link rel="stylesheet" type="text/css" href="{% static '/css/vendor/MarkerCluster.css' %}">
<link rel="stylesheet" type="text/css" href="{% static '/css/vendor/MarkerCluster.Failmap.css' %}">
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
<script type="text/javascript" src="{% static '/js/vendor/jquery-3.2.1.js' %}"></script>
<script type="text/javascript" src="{% static '/js/vendor/leaflet-src.js' %}"></script>
<script type="text/javascript" src="{% static '/js/vendor/Leaflet.fullscreen.js' %}"></script>
<script type="text/javascript" src="{% static '/js/vendor/leaflet.markercluster-src.js' %}"></script>
<script type="text/javascript" src="{% static '/js/vendor/raven.min.vue.3.19.1.js' %}"></script>
<script type="text/javascript" src="{% static '/js/failmap.js' %}"></script>
<meta name="country" content="{{ contest.target_country }}">
<meta name="debug" content="{{ debug }}">
<meta name="mapbox_token" content="{{ config.MAPBOX_ACCESS_TOKEN }}">
<script>
$( document ).ready(function() {
let country = document.head.querySelector("[name=country]").getAttribute('content');
let mapbox_token = document.head.querySelector("[name=mapbox_token]").getAttribute('content');
let debug = document.head.querySelector("[name=debug]").getAttribute('content');
failmap.initialize(mapbox_token, country, debug);
// todo: add timer that repeats this query every 10 seconds or so.
fetch('/game/data/contest/{{ contest.id }}/').then(response => response.json()).then(data => {
failmap.plotdata(data);
}).catch((fail) => {console.log('An error occurred: ' + fail)});
});
</script>
{% endblock %}
{% block fullwidth %}
<section>
<div id='map' style="height: calc(100vh - 55px);"></div>
</section>
<!-- Stuff that made failmap.js not really portable -->
<div id="fullscreenreport"></div>
{% endblock %}
......@@ -6,6 +6,7 @@ urlpatterns = [
path('', views.scores),
path('scores/', views.scores),
path('team/', views.teams),
path('map/', views.map),
path('submitted_urls/', views.submitted_urls),
path('rules_help/', views.rules_help),
path('submitted_organizations/', views.submitted_organizations),
......@@ -14,4 +15,5 @@ urlpatterns = [
path('submit_organization/', views.submit_organisation),
path('autocomplete/organization-autocomplete/', views.OrganizationAutocomplete.as_view()),
path('autocomplete/organization-type-autocomplete/', views.OrganizationTypeAutocomplete.as_view()),
path('data/contest/<int:contest_id>/', views.contest_map_data)
]
......@@ -10,9 +10,10 @@ from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Count, Q
from django.db.models.functions import Lower
from django.db.utils import OperationalError
from django.http import JsonResponse
from django.shortcuts import redirect, render
from django.views.decorators.cache import cache_page
from failmap.app.common import JSEncoder
from failmap.game.forms import ContestForm, OrganisationSubmissionForm, TeamForm, UrlSubmissionForm
from failmap.game.models import Contest, OrganizationSubmission, Team, UrlSubmission
from failmap.map.calculate import get_calculation
......@@ -368,11 +369,24 @@ def submitted_urls(request):
'contest': contest})
@cache_page(ten_minutes)
def rules_help(request):
return render(request, 'game/rules_help.html')
@login_required(login_url='/authentication/login/')
def map(request):
contest = get_default_contest(request)
return render(request, 'game/map.html', {'contest': contest, 'team': get_team_info(request)})
@login_required(login_url='/authentication/login/')
def contest_map_data(request, contest_id):
data = {}
return JsonResponse(data, encoder=JSEncoder)
@login_required(login_url='/authentication/login/')
def teams(request):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment