Commit 3994a58a authored by Krophil's avatar Krophil

Add search form in admin

parent 47bace20
Pipeline #1351 passed with stage
in 5 minutes and 45 seconds
......@@ -23,10 +23,20 @@
#
from django.contrib import admin
from haystack.admin import SearchModelAdmin
from com.models import *
class NewsAdmin(SearchModelAdmin):
search_fields = ["title", "summary", "content"]
class WeekmailAdmin(SearchModelAdmin):
search_fields = ["title"]
admin.site.register(Sith)
admin.site.register(News)
admin.site.register(Weekmail)
admin.site.register(News, NewsAdmin)
admin.site.register(Weekmail, WeekmailAdmin)
......@@ -26,13 +26,14 @@ from django.contrib import admin
from ajax_select import make_ajax_form
from core.models import User, Page, RealGroup, SithFile
from django.contrib.auth.models import Group as AuthGroup
from haystack.admin import SearchModelAdmin
admin.site.unregister(AuthGroup)
admin.site.register(RealGroup)
@admin.register(User)
class UserAdmin(admin.ModelAdmin):
class UserAdmin(SearchModelAdmin):
list_display = ["first_name", "last_name", "username", "email", "nick_name"]
form = make_ajax_form(User, {
'godfathers': 'users',
'home': 'files', # ManyToManyField
......@@ -40,6 +41,9 @@ class UserAdmin(admin.ModelAdmin):
'avatar_pict': 'files', # ManyToManyField
'scrub_pict': 'files', # ManyToManyField
})
search_fields = ["first_name", "last_name", "username"]
admin.site.register(User, UserAdmin)
@admin.register(Page)
class PageAdmin(admin.ModelAdmin):
......
......@@ -23,13 +23,22 @@
#
from django.contrib import admin
from haystack.admin import SearchModelAdmin
from counter.models import *
# Register your models here.
admin.site.register(Customer)
class ProductAdmin(SearchModelAdmin):
search_fields = ["name", "code"]
class CustomerAdmin(SearchModelAdmin):
search_fields = ["account_id"]
admin.site.register(Customer, CustomerAdmin)
admin.site.register(Product, ProductAdmin)
admin.site.register(ProductType)
admin.site.register(Product)
admin.site.register(Counter)
admin.site.register(Refilling)
admin.site.register(Selling)
......
......@@ -23,10 +23,26 @@
#
from django.contrib import admin
from haystack.admin import SearchModelAdmin
from forum.models import *
admin.site.register(Forum)
admin.site.register(ForumTopic)
admin.site.register(ForumMessage)
class ForumAdmin(SearchModelAdmin):
search_fields = ["name", "description"]
class ForumTopicAdmin(SearchModelAdmin):
search_fields = ["_title", "description"]
class ForumMessageAdmin(SearchModelAdmin):
search_fields = ["title", "message"]
admin.site.register(Forum, ForumAdmin)
admin.site.register(ForumTopic, ForumTopicAdmin)
admin.site.register(ForumMessage, ForumMessageAdmin)
admin.site.register(ForumUserInfo)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment