mirror of
https://github.com/daniviga/django-ram.git
synced 2025-12-26 15:28:31 +01:00
Code refactoring to simplify template data contexts (#55)
* Fix a search filter when no catalogs are returned * Code refactoring to simplify templates * Remove duplicated code * Remove dead code * More improvements, clean up and add featured items in homepage * Fix a type and better page navigation
This commit is contained in:
@@ -47,12 +47,12 @@ class ScaleAdmin(admin.ModelAdmin):
|
||||
@admin.register(Company)
|
||||
class CompanyAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ("logo_thumbnail",)
|
||||
list_display = ("name", "country_flag")
|
||||
list_display = ("name", "country_flag_name")
|
||||
list_filter = ("name", "country")
|
||||
search_fields = ("name",)
|
||||
|
||||
@admin.display(description="Country")
|
||||
def country_flag(self, obj):
|
||||
def country_flag_name(self, obj):
|
||||
return format_html(
|
||||
'<img src="{}" /> {}', obj.country.flag, obj.country.name
|
||||
)
|
||||
@@ -61,12 +61,12 @@ class CompanyAdmin(admin.ModelAdmin):
|
||||
@admin.register(Manufacturer)
|
||||
class ManufacturerAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ("logo_thumbnail",)
|
||||
list_display = ("name", "category", "country_flag")
|
||||
list_display = ("name", "category", "country_flag_name")
|
||||
list_filter = ("category",)
|
||||
search_fields = ("name",)
|
||||
|
||||
@admin.display(description="Country")
|
||||
def country_flag(self, obj):
|
||||
def country_flag_name(self, obj):
|
||||
return format_html(
|
||||
'<img src="{}" /> {}', obj.country.flag, obj.country.name
|
||||
)
|
||||
@@ -88,6 +88,12 @@ class RollingStockTypeAdmin(SortableAdminMixin, admin.ModelAdmin):
|
||||
|
||||
@admin.register(Shop)
|
||||
class ShopAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "on_line", "active")
|
||||
list_display = ("name", "on_line", "active", "country_flag_name")
|
||||
list_filter = ("on_line", "active")
|
||||
search_fields = ("name",)
|
||||
|
||||
@admin.display(description="Country")
|
||||
def country_flag_name(self, obj):
|
||||
return format_html(
|
||||
'<img src="{}" /> {}', obj.country.flag, obj.country.name
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user