Initial attempt at using Service Worker
- Caches facebook profile pictures and static resources - Removes django-compressor and commited bower_components - rest fixes
This commit is contained in:
1 parent
195c49b0fd
commit
2b5c3529d6
468 files changed
+376
-96983
No files matched your search
@@ -10,6 +10,7 @@ class ProductSerializer(ModelSerializer):
|
||||
model = Product
|
||||
|
||||
|
||||
|
||||
class ProductStatSerializer(ModelSerializer):
|
||||
EXTERNAL_USER = 'Ekstern'
|
||||
counts = serializers.SerializerMethodField()
|
||||
@@ -28,11 +29,9 @@ class ProductStatSerializer(ModelSerializer):
|
||||
return per_user
|
||||
|
||||
def get_counts(self, obj):
|
||||
per_user = OrderLine.objects\
|
||||
.filter(product=obj)\
|
||||
.values('order__customer__first_name', 'order__customer__last_name')\
|
||||
.annotate(amount_total=Sum('amount'))\
|
||||
.order_by('-amount_total')
|
||||
name_fields = ['order__customer__first_name', 'order__customer__last_name']
|
||||
per_user = OrderLine.objects.filter(product=obj)
|
||||
per_user = per_user.values(*name_fields).annotate(amount_total=Sum('amount')).order_by('-amount_total')
|
||||
|
||||
return self._format_counts(per_user)
|
||||
|
||||
|
||||
+5
-2
@@ -1,12 +1,15 @@
|
||||
from rest_framework import mixins
|
||||
from rest_framework.decorators import list_route
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
from main.api.serializers import ProductSerializer, ProductStatSerializer
|
||||
from main.models import Product
|
||||
from rest_framework.viewsets import GenericViewSet
|
||||
|
||||
|
||||
class ProductViewSet(ModelViewSet):
|
||||
class ProductViewSet(mixins.ListModelMixin,
|
||||
mixins.RetrieveModelMixin,
|
||||
GenericViewSet):
|
||||
serializer_class = ProductSerializer
|
||||
queryset = Product.objects.all()
|
||||
|
||||
|
||||
Reference in new issue
Block a user