2018-08-29 22:52:32 +00:00
|
|
|
from django.contrib import admin
|
|
|
|
from .models import Expense, Reimbursement
|
|
|
|
|
|
|
|
|
|
|
|
def approve_expenses(modeladmin, request, queryset):
|
|
|
|
for expense in queryset.all():
|
2018-08-29 23:35:37 +00:00
|
|
|
expense.approve(request)
|
2018-08-29 22:52:32 +00:00
|
|
|
approve_expenses.short_description = "Approve Expenses"
|
|
|
|
|
|
|
|
|
|
|
|
def reject_expenses(modeladmin, request, queryset):
|
|
|
|
for expense in queryset.all():
|
2018-08-29 23:35:37 +00:00
|
|
|
expense.reject(request)
|
2018-08-29 22:52:32 +00:00
|
|
|
reject_expenses.short_description = "Reject Expenses"
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Expense)
|
|
|
|
class ExpenseAdmin(admin.ModelAdmin):
|
|
|
|
list_filter = ['camp', 'responsible_team', 'approved', 'user', 'reimbursement']
|
|
|
|
list_display = ['user', 'description', 'amount', 'camp', 'responsible_team', 'approved', 'reimbursement']
|
|
|
|
search_fields = ['description', 'amount', 'user']
|
|
|
|
actions = [approve_expenses, reject_expenses]
|
|
|
|
|
2018-08-30 11:17:34 +00:00
|
|
|
|
|
|
|
@admin.register(Reimbursement)
|
|
|
|
class ReimbursementAdmin(admin.ModelAdmin):
|
|
|
|
def get_amount(self, obj):
|
|
|
|
return obj.amount
|
|
|
|
|
|
|
|
list_filter = ['camp', 'user', 'reimbursement_user', 'paid']
|
|
|
|
list_display = ['camp', 'user', 'reimbursement_user', 'paid', 'notes', 'get_amount']
|
|
|
|
search_fields = ['user__username', 'reimbursement_user__username', 'notes']
|
|
|
|
|