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