fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
configure migdal
[wolnelektury.git]
/
src
/
api
/
handlers.py
diff --git
a/src/api/handlers.py
b/src/api/handlers.py
index
8d32873
..
d050f0f
100644
(file)
--- a/
src/api/handlers.py
+++ b/
src/api/handlers.py
@@
-30,7
+30,7
@@
from wolnelektury.utils import re_escape
from . import emitters # Register our emitters
API_BASE = WL_BASE = MEDIA_BASE = lazy(
from . import emitters # Register our emitters
API_BASE = WL_BASE = MEDIA_BASE = lazy(
- lambda: u'http://' + Site.objects.get_current().domain, unicode)()
+ lambda: u'http
s
://' + Site.objects.get_current().domain, unicode)()
category_singular = {
category_singular = {
@@
-745,13
+745,14
@@
class UserLikeHandler(BaseHandler):
return rc.NOT_FOUND
return {'likes': likes(request.user, book)}
return rc.NOT_FOUND
return {'likes': likes(request.user, book)}
- def create(self, request, slug
, action='like'
):
+ def create(self, request, slug):
if not request.user.is_authenticated():
return rc.FORBIDDEN
try:
book = Book.objects.get(slug=slug)
except Book.DoesNotExist:
return rc.NOT_FOUND
if not request.user.is_authenticated():
return rc.FORBIDDEN
try:
book = Book.objects.get(slug=slug)
except Book.DoesNotExist:
return rc.NOT_FOUND
+ action = request.GET.get('action', 'like')
if action == 'like':
book.like(request.user)
elif action == 'unlike':
if action == 'like':
book.like(request.user)
elif action == 'unlike':
@@
-761,7
+762,7
@@
class UserLikeHandler(BaseHandler):
class BlogEntryHandler(BaseHandler):
model = Entry
class BlogEntryHandler(BaseHandler):
model = Entry
- fields = ('title', 'lead', 'body', 'place', 'time', 'image_url', 'gallery_urls', 'type', 'key')
+ fields = ('title', 'lead', 'body', 'place', 'time', 'image_url', '
image_thumb', '
gallery_urls', 'type', 'key')
def read(self, request):
after = request.GET.get('after')
def read(self, request):
after = request.GET.get('after')
@@
-775,11
+776,16
@@
class BlogEntryHandler(BaseHandler):
@classmethod
def image_url(cls, entry):
@classmethod
def image_url(cls, entry):
- return entry.image.url if entry.image else None
+ return (WL_BASE + entry.image.url) if entry.image else None
+
+ @classmethod
+ def image_thumb(cls, entry):
+ return MEDIA_BASE + default.backend.get_thumbnail(
+ entry.image, "193x193").url if entry.image else ''
@classmethod
def gallery_urls(cls, entry):
@classmethod
def gallery_urls(cls, entry):
- return [photo.url() for photo in entry.photo_set.all()]
+ return [
WL_BASE +
photo.url() for photo in entry.photo_set.all()]
@classmethod
def key(cls, entry):
@classmethod
def key(cls, entry):