diff --git a/api/api/dashboard.py b/api/api/dashboard.py deleted file mode 100644 index 9c5d4c7..0000000 --- a/api/api/dashboard.py +++ /dev/null @@ -1,32 +0,0 @@ -from django.utils.translation import ugettext_lazy as _ -from jet.dashboard import modules -from jet.dashboard.dashboard import Dashboard, AppIndexDashboard - - -class CustomIndexDashboard(Dashboard): - columns = 3 - - def init_with_context(self, context): - self.available_children.append(modules.LinkList) - self.children.append(modules.LinkList( - _('Support'), - children=[ - { - 'title': _('Django documentation'), - 'url': 'http://docs.djangoproject.com/', - 'external': True, - }, - { - 'title': _('Django "django-users" mailing list'), - 'url': 'http://groups.google.com/group/django-users', - 'external': True, - }, - { - 'title': _('Django irc channel'), - 'url': 'irc://irc.freenode.net/django', - 'external': True, - }, - ], - column=0, - order=0 - )) \ No newline at end of file diff --git a/api/api/settings.py b/api/api/settings.py index eda5890..f8b1e45 100644 --- a/api/api/settings.py +++ b/api/api/settings.py @@ -171,6 +171,6 @@ JET_THEMES = [ } ] -# JET_INDEX_DASHBOARD = 'jet.dashboard.dashboard.DefaultIndexDashboard' -JET_APP_INDEX_DASHBOARD = 'dashboard.CustomIndexDashboard' -# JET_INDEX_DASHBOARD = 'dashboard.CustomIndexDashboard' \ No newline at end of file +JET_INDEX_DASHBOARD = 'jet.dashboard.dashboard.DefaultIndexDashboard' +JET_APP_INDEX_DASHBOARD = 'bills.dashboard.CustomIndexDashboard' +# JET_INDEX_DASHBOARD = 'bills.dashboard.CustomIndexDashboard' \ No newline at end of file diff --git a/api/bills/admin.py b/api/bills/admin.py index ddc1521..2fb7848 100644 --- a/api/bills/admin.py +++ b/api/bills/admin.py @@ -1,9 +1,32 @@ from django.contrib import admin +import pendulum from .models import Bill +from.tasks import get_overdue_bills + +@admin.action(description='Duplicate Bill') +def duplicate(modeladmin, request, queryset): + for object in queryset: + object.id = None + # object.name = object.name+'-duplicate' ## This was temporary while I figured out how to massage the date + # print(object.due) + new_date = (pendulum.parse(str(object.due), exact=True)).add(months=1) + # print(new_date) + object.due = new_date + object.save() + +@admin.action(description='Duplicate Older Bill') +def duplicate_old(modeladmin, request, queryset): + for object in queryset: + object.id = None + new_date = (pendulum.parse(str(object.due), exact=True)).subtract(months=1) + object.due = new_date + object.save() @admin.register(Bill) class BillAdmin(admin.ModelAdmin): list_display = ['name', 'due', 'amount'] list_filter = ('name', 'type', 'is_paid', 'is_overdue', 'is_missed') - search_fields = ['name', 'type', 'amount'] \ No newline at end of file + search_fields = ['name', 'type', 'amount' + ] + actions = [duplicate, duplicate_old, get_overdue_bills] \ No newline at end of file diff --git a/api/bills/tasks.py b/api/bills/tasks.py index b11b48f..70001d6 100644 --- a/api/bills/tasks.py +++ b/api/bills/tasks.py @@ -1,7 +1,21 @@ ### Celery Tasks! +from .models import Bill + from celery import shared_task @shared_task -def get_overdue_bills(): +def get_overdue_bills(modeladmin, request, queryset): + + try: + bills_list = [] + bill_request = Bill.objects.filter(is_overdue=True) + print(bill_request) + for bill in bill_request: + # print(bill.id) + bills_list.append(bill.id) + except Bill.DoesNotExist: + bills_list = "There are no bills that are overdue!" + print("function complete") + print(bills_list) return('This is a test') \ No newline at end of file