Adding pagination disabled for history

remotes/origin/enhancement/email-actions
Alejandro Alonso 2014-08-28 13:10:55 +02:00
parent a9ecac7c1c
commit 3b48c1fa95
4 changed files with 23 additions and 9 deletions

View File

@ -20,7 +20,9 @@
from .viewsets import ModelListViewSet
from .viewsets import ModelCrudViewSet
from .viewsets import GenericViewSet
from .viewsets import ReadOnlyListViewSet
__all__ = ["ModelCrudViewSet",
"ModelListViewSet",
"GenericViewSet"]
"GenericViewSet",
"ReadOnlyListViewSet"]

View File

@ -124,6 +124,13 @@ class GenericViewSet(ViewSetMixin, generics.GenericAPIView):
"""
pass
class ReadOnlyListViewSet(pagination.HeadersPaginationMixin,
pagination.ConditionalPaginationMixin,
GenericViewSet):
"""
A viewset that provides default `list()` action.
"""
pass
class ReadOnlyModelViewSet(mixins.RetrieveModelMixin,
mixins.ListModelMixin,

View File

@ -18,17 +18,15 @@ from django.contrib.contenttypes.models import ContentType
from django.shortcuts import get_object_or_404
from rest_framework.response import Response
from rest_framework.permissions import IsAuthenticated
from taiga.base.api import GenericViewSet
from taiga.base.filters import IsProjectMemberFilterBackend
from taiga.base.api import ReadOnlyListViewSet
from . import permissions
from . import serializers
from . import services
class HistoryViewSet(GenericViewSet):
class HistoryViewSet(ReadOnlyListViewSet):
serializer_class = serializers.HistoryEntrySerializer
content_type = None

View File

@ -23,6 +23,7 @@ from django.db.models import Q
from django.conf import settings
from easy_thumbnails.files import get_thumbnailer
from easy_thumbnails.exceptions import InvalidImageFormatError
from taiga.base import exceptions as exc
from taiga.base.utils.urls import get_absolute_url
@ -54,8 +55,11 @@ def get_and_validate_user(*, username:str, password:str) -> bool:
def get_photo_url(photo):
"""Get a photo absolute url and the photo automatically cropped."""
url = get_thumbnailer(photo)['avatar'].url
return get_absolute_url(url)
try:
url = get_thumbnailer(photo)['avatar'].url
return get_absolute_url(url)
except InvalidImageFormatError as e:
return None
def get_photo_or_gravatar_url(user):
@ -67,8 +71,11 @@ def get_photo_or_gravatar_url(user):
def get_big_photo_url(photo):
"""Get a big photo absolute url and the photo automatically cropped."""
url = get_thumbnailer(photo)['big-avatar'].url
return get_absolute_url(url)
try:
url = get_thumbnailer(photo)['big-avatar'].url
return get_absolute_url(url)
except InvalidImageFormatError as e:
return None
def get_big_photo_or_gravatar_url(user):