<commit_before>#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Authors:
# <NAME> <<EMAIL>>, http://caner.candan.fr
# <NAME> <<EMAIL>>, http://www.vegeclic.fr
#

from django.contrib import admin
from django.contrib.contenttypes import generic
from modeltranslation.admin import TranslationAdmin
from . import forms, models
import common.admin as ca
import common.models as cm

class TaxAdmin(ca.MyModelAdmin):
    list_display = ('id', 'name', 'rate',)

admin.site.register(models.Tax, TaxAdmin)

class PriceInline(ca.LimitedAdminInlineMixin, admin.TabularInline):
    form = forms.PriceForm
    model = models.Price
    extra = 1

    def get_filters(self, obj): return (('supplier', {'product_suppliers': obj}),)

class SupplierFeeInline(admin.TabularInline):
    model = models.SupplierFee
    extra = 1

class SupplierAdmin(ca.MyModelAdmin):
    form = forms.SupplierForm
    add_form = forms.SupplierCreationForm
    list_display = ('id', 'name','fee_per_weight',)
    search_fields = ('name',)
    prepopulated_fields = {"slug": ("name",)}
    inlines = [ca.AddressInline, ca.ImageInline, SupplierFeeInline,]

admin.site.register(models.Supplier, SupplierAdmin)

class IngredientAdmin(TranslationAdmin):
    list_display = ('id', 'name',)

admin.site.register(models.Ingredient, IngredientAdmin)

class ProductAdmin(TranslationAdmin):
    # form = forms.ProductForm
    # fields = ('name', 'slug', 'product', 'status', 'suppliers', 'criterias', 'body', 'ingredients', 'weight', 'sku', 'main_image', 'main_price')
    list_display = ('id', 'name', 'weight', 'date_created', 'date_last_modified', 'status',)
    list_filter = ('status',)
    search_fields = ('name', 'slug', 'weight', 'product__slug',)
    filter_horizontal = ('suppliers', 'criterias',)
    actions = ['make_draft', 'make_published', 'make_expired', 'make_withdrawn',]
    inlines = [ca.ImageInline, PriceInline,]

    def make_draft(self, request, queryset): queryset.update(status='d')
    def make_published(self, request, queryset): queryset.update(status='p')
    def make_expired(self, request, queryset): queryset.update(status='e')
    def make_withdrawn(self, request, queryset): queryset.update(status='w')

admin.site.register(models.Product, ProductAdmin)

class InventoryInline(admin.TabularInline):
    model = models.Inventory
    extra = 3

class StoreAdmin(ca.MyModelAdmin):
    list_display = ('id', 'name', 'date_last_modified',)
    inlines = [InventoryInline, ca.AddressInline,]

admin.site.register(models.Store, StoreAdmin)

class EntryInline(admin.TabularInline):
    model = models.Entry<commit_msg>* suppliers/admin.py: added supplier reference and product id to search fields<commit_after>#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Authors:
# <NAME> <<EMAIL>>, http://caner.candan.fr
# <NAME> <<EMAIL>>, http://www.vegeclic.fr
#

from django.contrib import admin
from django.contrib.contenttypes import generic
from modeltranslation.admin import TranslationAdmin
from . import forms, models
import common.admin as ca
import common.models as cm

class TaxAdmin(ca.MyModelAdmin):
    list_display = ('id', 'name', 'rate',)

admin.site.register(models.Tax, TaxAdmin)

class PriceInline(ca.LimitedAdminInlineMixin, admin.TabularInline):
    form = forms.PriceForm
    model = models.Price
    extra = 1

    def get_filters(self, obj): return (('supplier', {'product_suppliers': obj}),)

class SupplierFeeInline(admin.TabularInline):
    model = models.SupplierFee
    extra = 1

class SupplierAdmin(ca.MyModelAdmin):
    form = forms.SupplierForm
    add_form = forms.SupplierCreationForm
    list_display = ('id', 'name','fee_per_weight',)
    search_fields = ('name',)
    prepopulated_fields = {"slug": ("name",)}
    inlines = [ca.AddressInline, ca.ImageInline, SupplierFeeInline,]

admin.site.register(models.Supplier, SupplierAdmin)

class IngredientAdmin(TranslationAdmin):
    list_display = ('id', 'name',)

admin.site.register(models.Ingredient, IngredientAdmin)

class ProductAdmin(TranslationAdmin):
    # form = forms.ProductForm
    # fields = ('name', 'slug', 'product', 'status', 'suppliers', 'criterias', 'body', 'ingredients', 'weight', 'sku', 'main_image', 'main_price')
    list_display = ('id', 'name', 'weight', 'date_created', 'date_last_modified', 'status',)
    list_filter = ('status',)
    search_fields = ('id', 'name', 'slug', 'weight', 'product__slug', 'main_price__reference',)
    filter_horizontal = ('suppliers', 'criterias',)
    actions = ['make_draft', 'make_published', 'make_expired', 'make_withdrawn',]
    inlines = [ca.ImageInline, PriceInline,]

    def make_draft(self, request, queryset): queryset.update(status='d')
    def make_published(self, request, queryset): queryset.update(status='p')
    def make_expired(self, request, queryset): queryset.update(status='e')
    def make_withdrawn(self, request, queryset): queryset.update(status='w')

admin.site.register(models.Product, ProductAdmin)

class InventoryInline(admin.TabularInline):
    model = models.Inventory
    extra = 3

class StoreAdmin(ca.MyModelAdmin):
    list_display = ('id', 'name', 'date_last_modified',)
    inlines = [InventoryInline, ca.AddressInline,]

admin.site.register(models.Store, StoreAdmin)

class EntryInline(admin.TabularInline):
    model = models.Entry
{'fraction_non_alphanumeric': 0.1264687693259122, 'fraction_numerical': 0.0055658627087198514, 'mean_word_length': 5.1085930122757315, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6674738', 'n_tokens_mistral': 1982, 'n_tokens_neox': 1975, 'n_words': 563}