Merge branch 'krophil' into 'master'

Add search form in admin

See merge request ae/Sith!124
This commit is contained in:
Skia 2017-10-12 09:29:02 +02:00
commit 69c7036089
4 changed files with 50 additions and 11 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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)

View File

@ -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)