from django.contrib import admin from django.contrib.admin.options import FORMFIELD_FOR_DBFIELD_DEFAULTS from django.contrib.gis import admin as geoadmin from django.http import StreamingHttpResponse class PollingActivityAdmin(admin.ModelAdmin): readonly_fields = ('id', ) fields = ('id', 'name', 'info', 'status', 'image', 'is_people', 'limit_per_day', 'pub_date') list_display = ('name', 'id', 'status') list_display_links = ('name', ) list_filter = ('status', 'is_people') admin_site.register(PollingActivity, PollingActivityAdmin) class PollingItemAdmin(geoadmin.OSMGeoAdmin, admin.ModelAdmin): model = PollingItem readonly_fields = ('id', ) fields = ('id', 'name', 'phone', 'city', 'address', 'votes', 'img_limits', 'is_luckystar', 'pub_date', 'is_successful', 'member', 'polling_activity', 'coordinates', 'two_bar_codes', 'avatar') list_display = ('name', 'id', 'votes', 'is_successful', 'city', 'is_luckystar', 'pub_date') list_display_links = ('id', ) list_filter = ('is_successful', 'polling_activity', 'pub_date', 'is_luckystar') list_editable = ('is_successful', 'is_luckystar') raw_id_fields = ['polling_activity', 'member', 'city']
from django.contrib import admin from utils.admin_site import admin_site from .models import Race class RaceAdmin(admin.ModelAdmin): readonly_fields = ('id',) fields = ('id', 'name', 'sign_up_date', 'deadline_date', 'start_date', 'image', 'status', 'detail') def has_delete_permission(self, request, obj=None): return False admin_site.register(Race, RaceAdmin)
class CompetitionEventParticipationRecordAdmin(admin.ModelAdmin): autocomplete_fields = ("member", ) fields = ("member", "competition_event", "branch_id", "marathon_id", "pay_status", "prepay_id", "out_trade_no", "nonce_str") readonly_fields = ('id', "in_time") list_display = ("id", "marathon_id", "competition_event", "in_time", "pay_status") class ParticipationInfoAdmin(admin.ModelAdmin): autocomplete_fields = ("member", ) fields = ("id", "member", "name", "gender", "certificate_type", "certificate_num", "birthday", "national", "email", "mobile", "blood_type", "emergency_contact", "emergency_contact_mobile") readonly_fields = ( 'id', "member", ) list_display = ("name", "gender", "certificate_type", "certificate_num", "mobile") admin_site.register(MarathonInfo, MarathonInfoAdmin) admin_site.register(Marathon, MarathonAdmin) admin_site.register(CompetitionEvent, CompetitionEventAdmin) admin_site.register(CompetitionEventParticipationRecord, CompetitionEventParticipationRecordAdmin) admin_site.register(ParticipationInfo, ParticipationInfoAdmin)
class BranchAdmin(admin.ModelAdmin): readonly_fields = ('id',) fields = ('id', 'name', 'announcement',) search_fields = ('name',) inlines = [LocationInline, ] def get_queryset(self, request): return super().get_queryset(request).filter(does_exist=True) def has_add_permission(self, request): return False def has_delete_permission(self, request, obj=None): return False class BranchFundRecordAdmin(admin.ModelAdmin): readonly_fields = ('create_time', 'pay_time', ) fields = ('branch', 'member', 'money', 'out_trade_no', 'transaction_id', 'order_status', 'nonce_str', 'prepay_id') search_fields = ('branch__name', 'member__name') list_filter = ('order_status',) list_display = ('branch', 'member', 'money', 'order_status') admin_site.register(Branch, BranchAdmin) admin_site.register(BranchFundRecord, BranchFundRecordAdmin)
'name', 'member_of__name', ) inlines = [ MemberProfileInline, ] def has_add_permission(self, request): return False def has_delete_permission(self, request, obj=None): return False class CityCodeAdmin(admin.ModelAdmin): readonly_fields = ('id', ) list_display = ( 'city_id', 'province', 'city', ) list_display_links = ('city_id', ) list_filter = ('province', ) search_fields = ( 'city', 'city_id', ) admin_site.register(Member, MemberAdmin) admin_site.register(CityCode, CityCodeAdmin)
class GoodsAidRecordAdmin(admin.ModelAdmin): readonly_fields = ('datetime',) list_display = ('goods', 'launch_member', 'aid_member','datetime') fields = ('goods', 'launch_member', 'aid_member' ) list_filter = ('goods',) search_fields = ('launch_member__name', 'aid_member__name') class ExpressPriceAdmin(admin.ModelAdmin): list_display = ('province', 'price',) fields = ('province', 'price',) class CountStepsAdmin(admin.ModelAdmin): readonly_fields = ('id',) list_display = ('member', 'order', 'today_steps', 'total_steps') fields = ('id', 'member', 'order', 'today_steps', 'total_steps', 'last_count') search_fields = ('member__name', 'order__goods_id__name') list_filter = ('order__goods_id',) ordering = ('total_steps',) admin_site.register(Goods, GoodsAdmin) admin_site.register(GoodsImage, GoodsImageAdmin) admin_site.register(Order, OrderAdmin) # admin_site.register(Address, AddressAdmin) admin_site.register(DeliveryRecord, DeliveryRecordAdmin) # admin_site.register(GoodsAidRecord, GoodsAidRecordAdmin) admin_site.register(ExpressPrice, ExpressPriceAdmin) admin_site.register(CountSteps, CountStepsAdmin)
fields = ( 'member', 'activity', 'money', 'out_trade_no', 'transaction_id', 'nonce_str', 'prepay_id', 'status', ) list_filter = ('status', ) list_display_links = ('member', ) class ParticipationRecordAdmin(admin.ModelAdmin): readonly_fields = ( 'id', 'in_time', ) list_display = ( 'member', 'activity', 'does_exist', ) list_display_links = ('member', ) admin_site.register(Activity, ActivityAdmin) admin_site.register(RechargeableActivity, RechargeableActivityAdmin) admin_site.register(ParticipationRecord, ParticipationRecordAdmin)
'member__member_profile__real_name', ) def has_add_permission(self, request): return False def has_delete_permission(self, request, obj=None): return False class MarathonDataAdmin(admin.ModelAdmin): fields = ('real_name', 'id_num', 'name', 'project', 'chip_time', 'clock_gun_time', 'is_pb', 'sex') list_display = ('real_name', 'id_num', 'name', 'project', 'chip_time', 'is_pb', 'sex') list_filter = ('is_pb', 'sex') # class MarathonQueryRecordAdmin(admin.ModelAdmin): # fields = ('member',) # # def has_add_permission(self, request): # return False # # def has_delete_permission(self, request, obj=None): # return False admin_site.register(Marathon, MarathonAdmin) # admin_site.register(MarathonQueryRecord, MarathonQueryRecordAdmin) admin_site.register(MarathonData, MarathonDataAdmin)
'address', ) can_delete = False max_num = 1 min_num = 1 class BranchAdmin(admin.ModelAdmin): readonly_fields = ('id', ) fields = ( 'id', 'name', 'announcement', ) search_fields = ('name', ) inlines = [ LocationInline, ] def get_queryset(self, request): return super().get_queryset(request).filter(does_exist=True) def has_add_permission(self, request): return False def has_delete_permission(self, request, obj=None): return False admin_site.register(Branch, BranchAdmin)