update sources API
This commit is contained in:
parent
8662d5a062
commit
df19daf501
2 changed files with 8 additions and 3 deletions
|
@ -224,6 +224,4 @@ class SourceViewSet(MapdataViewSet):
|
|||
|
||||
def _image(self, request, pk=None):
|
||||
source = self.get_object()
|
||||
response = HttpResponse(content_type=mimetypes.guess_type(source.name)[0])
|
||||
response.write(source.image)
|
||||
return response
|
||||
return HttpResponse(open(source.filepath, 'rb'), content_type=mimetypes.guess_type(source.name)[0])
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
@ -15,6 +18,10 @@ class Source(BoundsMixin, models.Model):
|
|||
verbose_name_plural = _('Sources')
|
||||
default_related_name = 'sources'
|
||||
|
||||
@property
|
||||
def filepath(self):
|
||||
return os.path.join(settings.SOURCES_ROOT, self.name)
|
||||
|
||||
@property
|
||||
def title(self):
|
||||
return self.name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue