Commit af50513f authored by Elger Jonker's avatar Elger Jonker

[wip] map added, score after accepting organization not correct


Former-commit-id: b8059ecc
parent 1d14389b
......@@ -385,47 +385,55 @@ class OrganizationSubmissionAdmin(ImportExportModelAdmin, admin.ModelAdmin):
# don't add the same thing over and over, allows to re-select the ones already added without a problem
# once rejected, can't be accepted via buttons: needs to be a manual action
# todo: make it possible to reject afterwards, and delete all subdomains etc.
if osm.has_been_accepted or osm.has_been_rejected:
log.debug('Organization has already been accepted or rejected.')
continue
try:
# this might revive some old organizations, so domain knowledge is required.
# In this case the organization already exists with the same name, type and alive.
# this means we don't need to add a new one, or with new coordinates.
Organization.objects.all().filter(
name=osm.organization_name,
country=osm.organization_country,
is_dead=False,
type=OrganizationType.objects.get(name=osm.organization_type_name)).first()
except Organization.DoesNotExist:
# Create a new one
# address and evidence are saved elsewhere. Since we have a reference we can auto-update after
# geocoding works. In the hopes some quality data has been added, which can be checked more easy then
# adding this data in the system again(?)
new_org = Organization(
name=osm.organization_name,
country=osm.organization_country,
is_dead=False,
type=OrganizationType.objects.get(name=osm.organization_type_name),
created_on=timezone.now(),
)
new_org.save()
# of course it has a new coordinate
new_coordinate = Coordinate(
organization=new_org,
geojsontype="Point",
area=osm.organization_address_geocoded,
edit_area=osm.organization_address_geocoded,
created_on=timezone.now(),
creation_metadata="Accepted organization submission"
)
new_coordinate.save()
# and save tracking information
osm.organization_in_system = new_org
osm.has_been_accepted = True
osm.save()
# this might revive some old organizations, so domain knowledge is required.
# In this case the organization already exists with the same name, type and alive.
# this means we don't need to add a new one, or with new coordinates.
already_exists = Organization.objects.all().filter(
name=osm.organization_name,
country=osm.organization_country,
is_dead=False,
type=OrganizationType.objects.get(name=osm.organization_type_name)).first()
if already_exists:
log.debug('Organization with the same name already exists, in this country and type and is alive.')
continue
# Create a new one
# address and evidence are saved elsewhere. Since we have a reference we can auto-update after
# geocoding works. In the hopes some quality data has been added, which can be checked more easy then
# adding this data in the system again(?)
new_org = Organization(
name=osm.organization_name,
country=osm.organization_country,
is_dead=False,
type=OrganizationType.objects.get(name=osm.organization_type_name),
created_on=timezone.now(),
)
new_org.save()
log.debug('Saved new organization.')
# of course it has a new coordinate
new_coordinate = Coordinate(
organization=new_org,
geojsontype="Point",
area=osm.organization_address_geocoded,
edit_area=osm.organization_address_geocoded,
created_on=timezone.now(),
creation_metadata="Accepted organization submission"
)
new_coordinate.save()
log.debug('Saved matching coordinate.')
# and save tracking information
osm.organization_in_system = new_org
osm.has_been_accepted = True
osm.save()
log.debug('Saved tracking information for the game.')
self.message_user(request, "Organizations have been accepted and added to the system.")
accept.short_description = "✅ Accept"
......
......@@ -81,9 +81,9 @@
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item"><a class="nav-link" href="/game/scores/">Scores</a></li>
<li class="nav-item"><a class="nav-link" href="/game/map/">Map</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">
......
......@@ -6,6 +6,7 @@
<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' %}">
<link rel="stylesheet" type="text/css" href="{% static '/css/overrides.css' %}">
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
<script type="text/javascript" src="{% static '/js/vendor/jquery-3.2.1.js' %}"></script>
......@@ -29,7 +30,7 @@
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 => {
fetch('/game/data/contest/').then(response => response.json()).then(data => {
failmap.plotdata(data);
}).catch((fail) => {console.log('An error occurred: ' + fail)});
});
......@@ -37,6 +38,10 @@
{% endblock %}
{% block content %}
Contest: {{ contest.name }}
{% endblock %}
{% block fullwidth %}
<section>
......
......@@ -15,5 +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)
path('data/contest/', views.contest_map_data)
]
This diff is collapsed.
......@@ -96,7 +96,7 @@ body {
/* bootstrap fixed menu terribleness... always overlaps content. */
body {
padding-top: 62px;
padding-top: 56px;
}
/* prevent dynamic content loading in the div before this element to scroll
......
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