from django.shortcuts import render

# Create your views here.
from rest_framework import viewsets
from rest_framework.permissions import IsAuthenticated
from history.models import HistorySync
from history.serializers import HistorySyncLogSerializer

from back_latienda.permissions import IsStaff


class HistorySyncViewSet(viewsets.ModelViewSet):
      model = HistorySync
      serializer_class = HistorySyncLogSerializer
      permission_classes = [IsAuthenticated,]

      def perform_create(self, serializer):
            serializer.save(creator=self.request.user)

      def get_queryset(self):
        return self.model.objects.filter(company=self.request.user.company).order_by('-created')