diff --git a/api/bills/admin.py b/api/bills/admin.py index 2fb7848..86817f6 100644 --- a/api/bills/admin.py +++ b/api/bills/admin.py @@ -2,7 +2,7 @@ from django.contrib import admin import pendulum from .models import Bill -from.tasks import get_overdue_bills +from.tasks import get_overdue_bills, get_upcoming_bills @admin.action(description='Duplicate Bill') def duplicate(modeladmin, request, queryset): @@ -29,4 +29,4 @@ class BillAdmin(admin.ModelAdmin): list_filter = ('name', 'type', 'is_paid', 'is_overdue', 'is_missed') search_fields = ['name', 'type', 'amount' ] - actions = [duplicate, duplicate_old, get_overdue_bills] \ No newline at end of file + actions = [duplicate, duplicate_old, get_overdue_bills, get_upcoming_bills] \ No newline at end of file diff --git a/api/bills/dashboard.py b/api/bills/dashboard.py new file mode 100644 index 0000000..00a819a --- /dev/null +++ b/api/bills/dashboard.py @@ -0,0 +1,43 @@ +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, + }, + { + 'title': _('COME ON'), + 'url': 'irc://irc.freenode.net/django', + 'external': True, + }, + ], + column=0, + order=0 + )) + + self.children.append(modules.ModelList( + _('Models'), + exclude=('auth.*',), + column=0, + order=0 + )) \ No newline at end of file diff --git a/api/bills/tasks.py b/api/bills/tasks.py index 70001d6..5f93fec 100644 --- a/api/bills/tasks.py +++ b/api/bills/tasks.py @@ -1,5 +1,7 @@ ### Celery Tasks! +from django.core.checks import messages +import pendulum from .models import Bill from celery import shared_task @@ -18,4 +20,16 @@ def get_overdue_bills(modeladmin, request, queryset): 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 + return('This is a test') + +@shared_task +def get_upcoming_bills(modeladmin, request, queryset): + today = pendulum.today().add(days=7) + print(today) + try: + bill_request = Bill.objects.filter(is_paid=False) + print(bill_request) + except Bill.DoesNotExist: + message = 'There are no bill coming due soon that are unpaid.' + print(message) + return(message) \ No newline at end of file