Add latest Bill functions
This commit is contained in:
parent
f9af3cfefe
commit
cef423c3d1
@ -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]
|
||||
actions = [duplicate, duplicate_old, get_overdue_bills, get_upcoming_bills]
|
43
api/bills/dashboard.py
Normal file
43
api/bills/dashboard.py
Normal file
@ -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
|
||||
))
|
@ -1,5 +1,7 @@
|
||||
### Celery Tasks!
|
||||
|
||||
from django.core.checks import messages
|
||||
import pendulum
|
||||
from .models import Bill
|
||||
|
||||
from celery import shared_task
|
||||
@ -19,3 +21,15 @@ def get_overdue_bills(modeladmin, request, queryset):
|
||||
print("function complete")
|
||||
print(bills_list)
|
||||
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)
|
Loading…
Reference in New Issue
Block a user