Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add map_preview to API #365

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion openra/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.shortcuts import get_object_or_404, get_list_or_404

from openra.models import Maps
from openra.models import MapCategories
from openra.models import MapCategories, Screenshots
from openra import misc

# pylint: disable=too-many-locals
Expand Down Expand Up @@ -77,6 +77,13 @@ def __map_info_from_objects(request, map_objects, yaml):
download_url = 'http://' + request.META['HTTP_HOST'] + \
'/maps/' + str(map_object.id) + '/oramap'

screenshots = Screenshots.objects.filter(ex_name="maps", ex_id=map_object.id)

map_preview = None
for sc_item in screenshots:
if sc_item.map_preview:
map_preview = sc_item

# TODO: Title and author have ' replaced with '' before insertion into the database. Work out why and fix it
results[map_object.map_hash] = {
'id': map_object.id,
Expand Down Expand Up @@ -113,6 +120,7 @@ def __map_info_from_objects(request, map_objects, yaml):
'rules': map_object.base64_rules,
'players_block': map_object.base64_players,
'reports': map_object.amount_reports,
'map_preview': map_preview
}

return __generate_response(results, yaml)
Expand Down