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()
|
||||
|
||||
|
||||
+7
-1
@@ -1,4 +1,4 @@
|
||||
from django.conf.urls import url
|
||||
from django.conf.urls import url, patterns
|
||||
from main.api.views import ProductViewSet
|
||||
from main.views.stats import stats_list, stats_orders, stats_orders_hourly, stats_products_realtime, stats_products_per_user
|
||||
from main.views.general import register, deposit, log
|
||||
@@ -25,7 +25,13 @@ urlpatterns = [
|
||||
url(r'^inventory/$', inventory, name='inventory'),
|
||||
url(r'^inventory/add/$', inventory_add, name='inventory-add'),
|
||||
url(r'^report$', report, name='report'),
|
||||
|
||||
]
|
||||
# Root level service-worker.js
|
||||
urlpatterns += patterns(
|
||||
'django.contrib.staticfiles.views',
|
||||
url(r'^service-worker\.js$', 'serve', kwargs={'path': 'dist/service-worker.js'})
|
||||
)
|
||||
|
||||
# API
|
||||
router = DefaultRouter()
|
||||
|
||||
Reference in new issue
Block a user