Skip to content

Commit

Permalink
Add button to country to fetch geoshape from wikidata.
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoWill committed Jan 25, 2019
1 parent 46d3fdc commit ed1c655
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{% if country.iso_3166_1_code %}
<input type="submit" name="update-boundaries" value="Update boundaries">
{% endif %}
<input type="submit" name="get-geoshape" value="Get boundary from wikidata">
</form>
</div>
{% endblock %}
Expand Down
8 changes: 8 additions & 0 deletions commons_api/wikidata/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ def post(self, request, *args, **kwargs):
messages.info(request, "Boundaries for {} will "
"be refreshed".format(self.object))

if 'get-geoshape' in request.POST:
from commons_api.proto_commons.tasks import import_geoshape
from django.contrib.contenttypes.models import ContentType
ct = ContentType.objects.get_for_model(self.model)
import_geoshape.delay(ct.app_label, ct.model, self.object.id)
messages.info(request, "Getting boundary from wikidata "
"for {}".format(self.object))

return redirect(self.object.get_absolute_url())


Expand Down

0 comments on commit ed1c655

Please sign in to comment.