mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-21 13:43:20 +00:00
use autocomplete_fields in admin
This commit is contained in:
parent
4d2b82235c
commit
eef15e05f4
@ -12,7 +12,6 @@
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
#
|
||||
from ajax_select import make_ajax_form
|
||||
from django.contrib import admin
|
||||
|
||||
from club.models import Club, Membership
|
||||
@ -32,4 +31,4 @@ class MembershipAdmin(admin.ModelAdmin):
|
||||
"user__last_name",
|
||||
"club__name",
|
||||
)
|
||||
form = make_ajax_form(Membership, {"user": "users"})
|
||||
autocomplete_fields = ("user",)
|
||||
|
11
com/admin.py
11
com/admin.py
@ -12,7 +12,6 @@
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
#
|
||||
from ajax_select import make_ajax_form
|
||||
from django.contrib import admin
|
||||
from haystack.admin import SearchModelAdmin
|
||||
|
||||
@ -23,19 +22,13 @@ from com.models import *
|
||||
class NewsAdmin(SearchModelAdmin):
|
||||
list_display = ("title", "type", "club", "author")
|
||||
search_fields = ("title", "summary", "content")
|
||||
form = make_ajax_form(
|
||||
News,
|
||||
{
|
||||
"author": "users",
|
||||
"moderator": "users",
|
||||
},
|
||||
)
|
||||
autocomplete_fields = ("author", "moderator")
|
||||
|
||||
|
||||
@admin.register(Poster)
|
||||
class PosterAdmin(SearchModelAdmin):
|
||||
list_display = ("name", "club", "date_begin", "date_end", "moderator")
|
||||
form = make_ajax_form(Poster, {"moderator": "users"})
|
||||
autocomplete_fields = ("moderator",)
|
||||
|
||||
|
||||
@admin.register(Weekmail)
|
||||
|
@ -13,30 +13,30 @@
|
||||
#
|
||||
#
|
||||
|
||||
from ajax_select import make_ajax_form
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.models import Group as AuthGroup
|
||||
from haystack.admin import SearchModelAdmin
|
||||
|
||||
from core.models import MetaGroup, Page, RealGroup, SithFile, User
|
||||
from core.models import Group, Page, SithFile, User
|
||||
|
||||
admin.site.unregister(AuthGroup)
|
||||
admin.site.register(MetaGroup)
|
||||
admin.site.register(RealGroup)
|
||||
|
||||
|
||||
@admin.register(Group)
|
||||
class GroupAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "description", "is_meta")
|
||||
list_filter = ("is_meta",)
|
||||
search_fields = ("name",)
|
||||
|
||||
|
||||
@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,
|
||||
{
|
||||
"godfathers": "users",
|
||||
"home": "files", # ManyToManyField
|
||||
"profile_pict": "files", # ManyToManyField
|
||||
"avatar_pict": "files", # ManyToManyField
|
||||
"scrub_pict": "files", # ManyToManyField
|
||||
},
|
||||
autocomplete_fields = (
|
||||
"godfathers",
|
||||
"home",
|
||||
"profile_pict",
|
||||
"avatar_pict",
|
||||
"scrub_pict",
|
||||
)
|
||||
search_fields = ["first_name", "last_name", "username"]
|
||||
|
||||
@ -44,25 +44,12 @@ class UserAdmin(SearchModelAdmin):
|
||||
@admin.register(Page)
|
||||
class PageAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "_full_name", "owner_group")
|
||||
form = make_ajax_form(
|
||||
Page,
|
||||
{
|
||||
"lock_user": "users",
|
||||
"owner_group": "groups",
|
||||
"edit_groups": "groups",
|
||||
"view_groups": "groups",
|
||||
},
|
||||
)
|
||||
search_fields = ("name",)
|
||||
autocomplete_fields = ("lock_user", "owner_group", "edit_groups", "view_groups")
|
||||
|
||||
|
||||
@admin.register(SithFile)
|
||||
class SithFileAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "owner", "size", "date", "is_in_sas")
|
||||
form = make_ajax_form(
|
||||
SithFile,
|
||||
{
|
||||
"parent": "files",
|
||||
"owner": "users",
|
||||
"moderator": "users",
|
||||
},
|
||||
) # ManyToManyField
|
||||
autocomplete_fields = ("parent", "owner", "moderator")
|
||||
search_fields = ("name", "parent__name")
|
||||
|
@ -12,7 +12,6 @@
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
#
|
||||
from ajax_select import make_ajax_form
|
||||
from django.contrib import admin
|
||||
from haystack.admin import SearchModelAdmin
|
||||
|
||||
@ -41,7 +40,7 @@ class CustomerAdmin(SearchModelAdmin):
|
||||
"user__first_name",
|
||||
"user__last_name",
|
||||
)
|
||||
form = make_ajax_form(Customer, {"user": "users"})
|
||||
autocomplete_fields = ("user",)
|
||||
|
||||
|
||||
@admin.register(BillingInfo)
|
||||
@ -52,18 +51,13 @@ class BillingInfoAdmin(admin.ModelAdmin):
|
||||
@admin.register(Counter)
|
||||
class CounterAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "club", "type")
|
||||
form = make_ajax_form(
|
||||
Counter,
|
||||
{
|
||||
"products": "products",
|
||||
"sellers": "users",
|
||||
},
|
||||
)
|
||||
autocomplete_fields = ("products", "sellers")
|
||||
|
||||
|
||||
@admin.register(Refilling)
|
||||
class RefillingAdmin(SearchModelAdmin):
|
||||
list_display = ("customer", "amount", "counter", "payment_method", "date")
|
||||
autocomplete_fields = ("customer", "operator")
|
||||
search_fields = (
|
||||
"customer__user__username",
|
||||
"customer__user__first_name",
|
||||
@ -71,13 +65,6 @@ class RefillingAdmin(SearchModelAdmin):
|
||||
"customer__account_id",
|
||||
"counter__name",
|
||||
)
|
||||
form = make_ajax_form(
|
||||
Refilling,
|
||||
{
|
||||
"customer": "customers",
|
||||
"operator": "users",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@admin.register(Selling)
|
||||
@ -90,13 +77,7 @@ class SellingAdmin(SearchModelAdmin):
|
||||
"customer__account_id",
|
||||
"counter__name",
|
||||
)
|
||||
form = make_ajax_form(
|
||||
Selling,
|
||||
{
|
||||
"customer": "customers",
|
||||
"seller": "users",
|
||||
},
|
||||
)
|
||||
autocomplete_fields = ("customer", "seller")
|
||||
|
||||
|
||||
@admin.register(Permanency)
|
||||
@ -108,7 +89,7 @@ class PermanencyAdmin(SearchModelAdmin):
|
||||
"user__last_name",
|
||||
"counter__name",
|
||||
)
|
||||
form = make_ajax_form(Permanency, {"user": "users"})
|
||||
autocomplete_fields = ("user",)
|
||||
|
||||
|
||||
@admin.register(ProductType)
|
||||
@ -125,7 +106,7 @@ class CashRegisterSummaryAdmin(SearchModelAdmin):
|
||||
"user__last_name",
|
||||
"counter__name",
|
||||
)
|
||||
form = make_ajax_form(CashRegisterSummary, {"user": "users"})
|
||||
autocomplete_fields = ("user",)
|
||||
|
||||
|
||||
@admin.register(Eticket)
|
||||
|
@ -12,7 +12,6 @@
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
#
|
||||
from ajax_select import make_ajax_form
|
||||
from django.contrib import admin
|
||||
|
||||
from eboutic.models import *
|
||||
@ -21,7 +20,7 @@ from eboutic.models import *
|
||||
@admin.register(Basket)
|
||||
class BasketAdmin(admin.ModelAdmin):
|
||||
list_display = ("user", "date", "get_total")
|
||||
form = make_ajax_form(Basket, {"user": "users"})
|
||||
autocomplete_fields = ("user",)
|
||||
|
||||
|
||||
@admin.register(BasketItem)
|
||||
@ -34,7 +33,7 @@ class BasketItemAdmin(admin.ModelAdmin):
|
||||
class InvoiceAdmin(admin.ModelAdmin):
|
||||
list_display = ("user", "date", "validated")
|
||||
search_fields = ("user__username", "user__first_name", "user__last_name")
|
||||
form = make_ajax_form(Invoice, {"user": "users"})
|
||||
autocomplete_fields = ("user",)
|
||||
|
||||
|
||||
@admin.register(InvoiceItem)
|
||||
|
@ -1,4 +1,3 @@
|
||||
from ajax_select import make_ajax_form
|
||||
from django.contrib import admin
|
||||
|
||||
from election.models import Candidature, Election, ElectionList, Role
|
||||
@ -13,7 +12,7 @@ class ElectionAdmin(admin.ModelAdmin):
|
||||
"is_vote_finished",
|
||||
"archived",
|
||||
)
|
||||
form = make_ajax_form(Election, {"voters": "users"})
|
||||
autocomplete_fields = ("voters",)
|
||||
|
||||
|
||||
@admin.register(Role)
|
||||
@ -31,7 +30,7 @@ class ElectionListAdmin(admin.ModelAdmin):
|
||||
@admin.register(Candidature)
|
||||
class CandidatureAdmin(admin.ModelAdmin):
|
||||
list_display = ("user", "role", "election_list")
|
||||
form = make_ajax_form(Candidature, {"user": "users"})
|
||||
autocomplete_fields = ("user",)
|
||||
|
||||
|
||||
# Votes must stay fully anonymous, so no ModelAdmin for Vote model
|
||||
|
@ -19,19 +19,16 @@ from haystack.admin import SearchModelAdmin
|
||||
from forum.models import *
|
||||
|
||||
|
||||
@admin.register(Forum)
|
||||
class ForumAdmin(SearchModelAdmin):
|
||||
search_fields = ["name", "description"]
|
||||
|
||||
|
||||
@admin.register(ForumTopic)
|
||||
class ForumTopicAdmin(SearchModelAdmin):
|
||||
search_fields = ["_title", "description"]
|
||||
|
||||
|
||||
@admin.register(ForumMessage)
|
||||
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)
|
||||
|
@ -12,7 +12,6 @@
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
#
|
||||
from ajax_select import make_ajax_form
|
||||
from django.contrib import admin
|
||||
|
||||
from launderette.models import *
|
||||
@ -31,10 +30,10 @@ class MachineAdmin(admin.ModelAdmin):
|
||||
@admin.register(Token)
|
||||
class TokenAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "launderette", "type", "user")
|
||||
form = make_ajax_form(Token, {"user": "users"})
|
||||
autocomplete_fields = ("user",)
|
||||
|
||||
|
||||
@admin.register(Slot)
|
||||
class SlotAdmin(admin.ModelAdmin):
|
||||
list_display = ("machine", "user", "start_date")
|
||||
form = make_ajax_form(Slot, {"user": "users"})
|
||||
autocomplete_fields = ("user",)
|
||||
|
@ -20,7 +20,6 @@
|
||||
# Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
#
|
||||
from ajax_select import make_ajax_form
|
||||
from django.contrib import admin
|
||||
from haystack.admin import SearchModelAdmin
|
||||
|
||||
@ -31,7 +30,7 @@ from pedagogy.models import UV, UVComment, UVCommentReport
|
||||
class UVAdmin(admin.ModelAdmin):
|
||||
list_display = ("code", "title", "credit_type", "credits", "department")
|
||||
search_fields = ("code", "title", "department")
|
||||
form = make_ajax_form(UV, {"author": "users"})
|
||||
autocomplete_fields = ("author",)
|
||||
|
||||
|
||||
@admin.register(UVComment)
|
||||
@ -43,7 +42,7 @@ class UVCommentAdmin(admin.ModelAdmin):
|
||||
"author__last_name",
|
||||
"uv__code",
|
||||
)
|
||||
form = make_ajax_form(UVComment, {"author": "users"})
|
||||
autocomplete_fields = ("author",)
|
||||
|
||||
|
||||
@admin.register(UVCommentReport)
|
||||
@ -55,4 +54,4 @@ class UVCommentReportAdmin(SearchModelAdmin):
|
||||
"reporter__last_name",
|
||||
"comment__uv__code",
|
||||
)
|
||||
form = make_ajax_form(UVCommentReport, {"reporter": "users"})
|
||||
autocomplete_fields = ("reporter",)
|
||||
|
18
sas/admin.py
18
sas/admin.py
@ -15,8 +15,20 @@
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
from sas.models import *
|
||||
from sas.models import Album, PeoplePictureRelation, Picture
|
||||
|
||||
|
||||
@admin.register(Picture)
|
||||
class PictureAdmin(admin.ModelAdmin):
|
||||
list_display = ("name", "parent", "date", "size", "is_moderated")
|
||||
search_fields = ("name",)
|
||||
autocomplete_fields = ("owner", "parent", "edit_groups", "view_groups", "moderator")
|
||||
|
||||
|
||||
@admin.register(PeoplePictureRelation)
|
||||
class PeoplePictureRelationAdmin(admin.ModelAdmin):
|
||||
list_display = ("picture", "user")
|
||||
autocomplete_fields = ("picture", "user")
|
||||
|
||||
|
||||
admin.site.register(Album)
|
||||
# admin.site.register(Picture)
|
||||
admin.site.register(PeoplePictureRelation)
|
||||
|
@ -12,7 +12,6 @@
|
||||
# OR WITHIN THE LOCAL FILE "LICENSE"
|
||||
#
|
||||
#
|
||||
from ajax_select import make_ajax_form
|
||||
from django.contrib import admin
|
||||
|
||||
from subscription.models import Subscription
|
||||
@ -33,4 +32,4 @@ class SubscriptionAdmin(admin.ModelAdmin):
|
||||
"subscription_end",
|
||||
"subscription_type",
|
||||
)
|
||||
form = make_ajax_form(Subscription, {"member": "users"})
|
||||
autocomplete_fields = ("member",)
|
||||
|
Loading…
Reference in New Issue
Block a user