mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +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 django.contrib import admin
|
||||||
|
from haystack.admin import SearchModelAdmin
|
||||||
|
|
||||||
from com.models import *
|
from com.models import *
|
||||||
|
|
||||||
admin.site.register(Sith)
|
|
||||||
admin.site.register(News)
|
class NewsAdmin(SearchModelAdmin):
|
||||||
admin.site.register(Weekmail)
|
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 ajax_select import make_ajax_form
|
||||||
from core.models import User, Page, RealGroup, SithFile
|
from core.models import User, Page, RealGroup, SithFile
|
||||||
from django.contrib.auth.models import Group as AuthGroup
|
from django.contrib.auth.models import Group as AuthGroup
|
||||||
|
from haystack.admin import SearchModelAdmin
|
||||||
|
|
||||||
|
|
||||||
admin.site.unregister(AuthGroup)
|
admin.site.unregister(AuthGroup)
|
||||||
admin.site.register(RealGroup)
|
admin.site.register(RealGroup)
|
||||||
|
|
||||||
@admin.register(User)
|
class UserAdmin(SearchModelAdmin):
|
||||||
class UserAdmin(admin.ModelAdmin):
|
list_display = ["first_name", "last_name", "username", "email", "nick_name"]
|
||||||
form = make_ajax_form(User, {
|
form = make_ajax_form(User, {
|
||||||
'godfathers': 'users',
|
'godfathers': 'users',
|
||||||
'home': 'files', # ManyToManyField
|
'home': 'files', # ManyToManyField
|
||||||
@ -40,6 +41,9 @@ class UserAdmin(admin.ModelAdmin):
|
|||||||
'avatar_pict': 'files', # ManyToManyField
|
'avatar_pict': 'files', # ManyToManyField
|
||||||
'scrub_pict': 'files', # ManyToManyField
|
'scrub_pict': 'files', # ManyToManyField
|
||||||
})
|
})
|
||||||
|
search_fields = ["first_name", "last_name", "username"]
|
||||||
|
|
||||||
|
admin.site.register(User, UserAdmin)
|
||||||
|
|
||||||
@admin.register(Page)
|
@admin.register(Page)
|
||||||
class PageAdmin(admin.ModelAdmin):
|
class PageAdmin(admin.ModelAdmin):
|
||||||
|
@ -23,13 +23,22 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from haystack.admin import SearchModelAdmin
|
||||||
|
|
||||||
from counter.models import *
|
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(ProductType)
|
||||||
admin.site.register(Product)
|
|
||||||
admin.site.register(Counter)
|
admin.site.register(Counter)
|
||||||
admin.site.register(Refilling)
|
admin.site.register(Refilling)
|
||||||
admin.site.register(Selling)
|
admin.site.register(Selling)
|
||||||
|
@ -23,10 +23,26 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
from haystack.admin import SearchModelAdmin
|
||||||
|
|
||||||
|
|
||||||
from forum.models import *
|
from forum.models import *
|
||||||
|
|
||||||
admin.site.register(Forum)
|
|
||||||
admin.site.register(ForumTopic)
|
class ForumAdmin(SearchModelAdmin):
|
||||||
admin.site.register(ForumMessage)
|
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)
|
admin.site.register(ForumUserInfo)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user