2018-08-29 22:52:32 +00:00
|
|
|
from django.contrib import admin
|
2018-11-20 16:12:32 +00:00
|
|
|
from .models import Expense, Reimbursement, Revenue
|
2018-08-29 22:52:32 +00:00
|
|
|
|
|
|
|
|
2018-11-20 16:12:32 +00:00
|
|
|
### expenses
|
|
|
|
|
2018-08-29 22:52:32 +00:00
|
|
|
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):
|
2019-02-10 15:33:05 +00:00
|
|
|
list_filter = ['camp', 'responsible_team', 'approved', 'user']
|
2019-01-20 14:58:10 +00:00
|
|
|
list_display = ['user', 'description', 'invoice_date', 'amount', 'camp', 'responsible_team', 'approved', 'reimbursement']
|
2019-02-10 15:33:05 +00:00
|
|
|
search_fields = ['description', 'amount', 'uuid']
|
2018-08-29 22:52:32 +00:00
|
|
|
actions = [approve_expenses, reject_expenses]
|
|
|
|
|
2018-08-30 11:17:34 +00:00
|
|
|
|
2018-11-20 16:12:32 +00:00
|
|
|
### revenues
|
|
|
|
|
|
|
|
def approve_revenues(modeladmin, request, queryset):
|
|
|
|
for revenue in queryset.all():
|
|
|
|
revenue.approve(request)
|
|
|
|
approve_revenues.short_description = "Approve Revenues"
|
|
|
|
|
|
|
|
|
|
|
|
def reject_revenues(modeladmin, request, queryset):
|
|
|
|
for revenue in queryset.all():
|
|
|
|
revenue.reject(request)
|
|
|
|
reject_revenues.short_description = "Reject Revenues"
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Revenue)
|
|
|
|
class RevenueAdmin(admin.ModelAdmin):
|
|
|
|
list_filter = ['camp', 'responsible_team', 'approved', 'user']
|
2019-01-20 14:58:10 +00:00
|
|
|
list_display = ['user', 'description', 'invoice_date', 'amount', 'camp', 'responsible_team', 'approved']
|
2018-11-20 16:12:32 +00:00
|
|
|
search_fields = ['description', 'amount', 'user']
|
|
|
|
actions = [approve_revenues, reject_revenues]
|
|
|
|
|
|
|
|
|
|
|
|
### reimbursements
|
|
|
|
|
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']
|
|
|
|
|