<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals
from rest_framework import generics, mixins
from rest_framework.renderers import BrowsableAPIRenderer
from shop.rest.serializers import OrderListSerializer, OrderDetailSerializer
from shop.rest.money import JSONRenderer
from shop.rest.renderers import CMSPageRenderer
from shop.models.order import OrderModel


class GenericOrderView(generics.GenericAPIView):
    """
    Base View class to render the fulfilled orders for the current user.
    """
    renderer_classes = (CMSPageRenderer, JSONRenderer, BrowsableAPIRenderer)
    thank_you = False  # if true render a "Thank You" view, rather than a normal order object

    def get_queryset(self):
        return OrderModel.objects.filter(user=self.request.user).order_by('-updated_at',)

    def get_renderer_context(self):
        renderer_context = super(GenericOrderView, self).get_renderer_context()
        if renderer_context['request'].accepted_renderer.format == 'html':
            renderer_context.update(many=isinstance(self, mixins.ListModelMixin), thank_you=self.thank_you)
        return renderer_context

    def get_template_names(self):
        return [self.request.current_page.get_template()]


class OrderListView(mixins.ListModelMixin, GenericOrderView):
    serializer_class = OrderListSerializer

    def get(self, request, *args, **kwargs):
        return self.list(request, *args, **kwargs)

<commit_msg>Could not retrieve Order for anonymous users<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals
from rest_framework import generics, mixins
from rest_framework.renderers import BrowsableAPIRenderer
from shop.rest.serializers import OrderListSerializer, OrderDetailSerializer
from shop.rest.money import JSONRenderer
from shop.rest.renderers import CMSPageRenderer
from shop.models.auth import get_customer
from shop.models.order import OrderModel


class GenericOrderView(generics.GenericAPIView):
    """
    Base View class to render the fulfilled orders for the current user.
    """
    renderer_classes = (CMSPageRenderer, JSONRenderer, BrowsableAPIRenderer)
    thank_you = False  # if true render a "Thank You" view, rather than a normal order object

    def get_queryset(self):
        user = get_customer(self.request)
        return OrderModel.objects.filter(user=user).order_by('-updated_at',)

    def get_renderer_context(self):
        renderer_context = super(GenericOrderView, self).get_renderer_context()
        if renderer_context['request'].accepted_renderer.format == 'html':
            renderer_context.update(many=isinstance(self, mixins.ListModelMixin), thank_you=self.thank_you)
        return renderer_context

    def get_template_names(self):
        return [self.request.current_page.get_template()]


class OrderListView(mixins.ListModelMixin, GenericOrderView):
    serializer_class = OrderListSerializer

    def get(self, request, *args, **kwargs):
        return self.list(request, *args, **kwargs)


{'fraction_non_alphanumeric': 0.08471211118464593, 'fraction_numerical': 0.0006618133686300463, 'mean_word_length': 4.6930320150659135, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5174583', 'n_tokens_mistral': 856, 'n_tokens_neox': 832, 'n_words': 214}