admin.py 1.2 KB
Newer Older
Laurent Peuch's avatar
Laurent Peuch committed
1
2
3
4
5
# encoding: utf-8

from django.contrib import admin
from django.conf.locale.en import formats as en_formats
from reversion.admin import VersionAdmin
6
from admin_views.admin import AdminViews
Laurent Peuch's avatar
Laurent Peuch committed
7
8
9
10
11
from .models import Movement

en_formats.DATE_FORMAT = "Y-m-d"


12
class MovementAdmin(VersionAdmin, AdminViews):
Laurent Peuch's avatar
Laurent Peuch committed
13
14
    fieldsets = (
        (None, {
15
            "fields": (("date", "amount"), ("title", "kind"), ("comment",), ("bank_id",))
Laurent Peuch's avatar
Laurent Peuch committed
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
        }),
    )

    list_display = ("date", "title_column", "credit_column", "debit_column")

    def debit_column(self, obj):
        if obj.kind == "debit":
            return obj.amount
        return ""

    debit_column.short_description = "Débit"

    def credit_column(self, obj):
        if obj.kind == "credit":
            return obj.amount
        return ""

    credit_column.short_description = "Crédit"

    def title_column(self, obj):
        if obj.comment:
            return "%s [has comment]" % obj.title
        return obj.title

    title_column.short_description = "Title"

42
43
44
45
46
    admin_views = (
       ('Neutrinet Public Accounting Page', '/accounts'),
       ('Upload Record Bank CSV ', '/accounts/upload_record_bank_csv'),
    )

Laurent Peuch's avatar
Laurent Peuch committed
47
admin.site.register(Movement, MovementAdmin)