mirror of
https://github.com/ae-utbm/sith.git
synced 2024-10-31 19:38:04 +00:00
Add search form in admin
This commit is contained in:
parent
47bace2057
commit
3994a58a2f
16
com/admin.py
16
com/admin.py
@ -23,10 +23,20 @@
|
||||
#
|
||||
|
||||
from django.contrib import admin
|
||||
from haystack.admin import SearchModelAdmin
|
||||
|
||||
from com.models import *
|
||||
|
||||
admin.site.register(Sith)
|
||||
admin.site.register(News)
|
||||
admin.site.register(Weekmail)
|
||||
|
||||
class NewsAdmin(SearchModelAdmin):
|
||||
search_fields = ["title", "summary", "content"]
|
||||
|
||||
|
||||
class WeekmailAdmin(SearchModelAdmin):
|
||||
search_fields = ["title"]
|
||||
|
||||
|
||||
admin.site.register(Sith)
|
||||
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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user