implement new django-based models and loadmappkg command
This commit is contained in:
parent
66661209d2
commit
752b7d6d7d
14 changed files with 318 additions and 196 deletions
|
@ -1,19 +1,15 @@
|
|||
import mimetypes
|
||||
|
||||
from django.contrib.admin.views.decorators import staff_member_required
|
||||
from django.http import Http404, HttpResponse
|
||||
from django.shortcuts import render
|
||||
|
||||
from ..mapdata import mapmanager
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from .models import MapSource
|
||||
|
||||
|
||||
@staff_member_required
|
||||
def source(request, filename):
|
||||
source = mapmanager.sources_by_filename.get(filename)
|
||||
if source is None:
|
||||
raise Http404('Source does not exist')
|
||||
|
||||
response = HttpResponse(content_type=mimetypes.guess_type(source.src)[0])
|
||||
with open(source.src, 'rb') as f:
|
||||
response.write(f.read())
|
||||
def source(request, source):
|
||||
source = get_object_or_404(MapSource, name=source)
|
||||
response = HttpResponse(content_type=mimetypes.guess_type(source.image.name)[0])
|
||||
for chunk in source.image.chunks():
|
||||
response.write(chunk)
|
||||
return response
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue