<commit_before>from django.contrib import admin
from django.utils.translation import ugettext_lazy as _

from plata.discount.models import AppliedDiscount
from plata.shop import models


class OrderItemInline(admin.TabularInline):
    model = models.OrderItem
    raw_id_fields = ('product',)

class AppliedDiscountInline(admin.TabularInline):
    model = AppliedDiscount

class OrderStatusInline(admin.TabularInline):
    model = models.OrderStatus
    extra = 1


class OrderAdmin(admin.ModelAdmin):
    date_hierarchy = 'created'
    fieldsets = (
        (None, {'fields': ('created', 'confirmed', 'user', 'email', 'status')}),
        (_('Billing address'), {'fields': ('billing_company', 'billing_first_name',
            'billing_last_name', 'billing_address', 'billing_zip_code',
            'billing_city', 'billing_country')}),
        (_('Shipping address'), {'fields': ('shipping_same_as_billing',
            'shipping_company', 'shipping_first_name',
            'shipping_last_name', 'shipping_address', 'shipping_zip_code',
            'shipping_city', 'shipping_country')}),
        (_('Order items'), {'fields': ('items_subtotal', 'items_discount', 'items_tax')}),
        (_('Shipping'), {'fields': ('shipping_cost', 'shipping_discount', 'shipping_tax')}),
        (_('Total'), {'fields': ('currency', 'total', 'paid')}),
        (_('Additional fields'), {'fields': ('notes',)}),
        )
    inlines = [OrderItemInline, AppliedDiscountInline, OrderStatusInline]
    list_display = ('order_id', 'created', 'user', 'status', 'total',
        'balance_remaining', 'is_paid', 'admin_invoice_pdf', 'admin_packing_slip_pdf')
    list_filter = ('status',)
    ordering = ['-created']
    raw_id_fields = ('user',)
    search_fields = tuple('billing_%s' % s for s in models.Order.ADDRESS_FIELDS)\
        +tuple('shipping_%s' % s for s in models.Order.ADDRESS_FIELDS)\
        +('total', 'notes')
<commit_msg>Allow ordering by the order_id<commit_after>from django.contrib import admin
from django.utils.translation import ugettext_lazy as _

from plata.discount.models import AppliedDiscount
from plata.shop import models


class OrderItemInline(admin.TabularInline):
    model = models.OrderItem
    raw_id_fields = ('product',)

class AppliedDiscountInline(admin.TabularInline):
    model = AppliedDiscount

class OrderStatusInline(admin.TabularInline):
    model = models.OrderStatus
    extra = 1


class OrderAdmin(admin.ModelAdmin):
    date_hierarchy = 'created'
    fieldsets = (
        (None, {'fields': ('created', 'confirmed', 'user', 'email', 'status')}),
        (_('Billing address'), {'fields': ('billing_company', 'billing_first_name',
            'billing_last_name', 'billing_address', 'billing_zip_code',
            'billing_city', 'billing_country')}),
        (_('Shipping address'), {'fields': ('shipping_same_as_billing',
            'shipping_company', 'shipping_first_name',
            'shipping_last_name', 'shipping_address', 'shipping_zip_code',
            'shipping_city', 'shipping_country')}),
        (_('Order items'), {'fields': ('items_subtotal', 'items_discount', 'items_tax')}),
        (_('Shipping'), {'fields': ('shipping_cost', 'shipping_discount', 'shipping_tax')}),
        (_('Total'), {'fields': ('currency', 'total', 'paid')}),
        (_('Additional fields'), {'fields': ('notes',)}),
        )
    inlines = [OrderItemInline, AppliedDiscountInline, OrderStatusInline]
    list_display = ('admin_order_id', 'created', 'user', 'status', 'total',
        'balance_remaining', 'is_paid', 'admin_invoice_pdf', 'admin_packing_slip_pdf')
    list_filter = ('status',)
    ordering = ['-created']
    raw_id_fields = ('user',)
    search_fields = tuple('billing_%s' % s for s in models.Order.ADDRESS_FIELDS)\
        +tuple('shipping_%s' % s for s in models.Order.ADDRESS_FIELDS)\
        +('total', 'notes')

    def admin_order_id(self, instance):
        return instance.order_id
    admin_order_id.short_description = _('order ID')
    admin_order_id.admin_order_field = '_order_id'

{'fraction_non_alphanumeric': 0.15599505562422744, 'fraction_numerical': 0.0004944375772558715, 'mean_word_length': 4.247730220492866, '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': '1414726', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1273, 'n_words': 256}