Exemplo n.º 1
0
from django.db.models.aggregates import Max
from django.http import Http404
from django.utils.translation import ugettext_lazy as _

from bluebottle.bluebottle_drf2.views import RetrieveUpdateDeleteAPIView, ListCreateAPIView
from rest_framework import permissions, exceptions

from bluebottle.utils.serializer_dispatcher import get_serializer_class
from bluebottle.utils.model_dispatcher import get_project_model, get_fundraiser_model

from tenant_extras.drf_permissions import TenantConditionalOpenClose

PROJECT_MODEL = get_project_model()
FUNDRAISER_MODEL = get_fundraiser_model()

FUNDRAISER_SERIALIZER = get_serializer_class('FUNDRAISERS_FUNDRAISER_MODEL', 'default')


class FundraiserListView(ListCreateAPIView):
    model = FUNDRAISER_MODEL
    serializer_class = FUNDRAISER_SERIALIZER
    permission_classes = (TenantConditionalOpenClose, permissions.IsAuthenticatedOrReadOnly,)
    paginate_by = 10
    paginate_by_param = 'page_size'

    # because we overwrite get_queryset, this is ignored
    # TODO: Write cleaner code that takes this argument into account.
    # ordering = ('-created', )

    def get_queryset(self, queryset=None):
        queryset = super(FundraiserListView, self).get_queryset(queryset)
Exemplo n.º 2
0
 def fundraiser_count(self):
     return get_fundraiser_model().objects.filter(owner=self).count()