Add Get Overdue Bills
This commit is contained in:
parent
20096010b4
commit
f9af3cfefe
@ -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
|
|
||||||
))
|
|
@ -171,6 +171,6 @@ JET_THEMES = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
# JET_INDEX_DASHBOARD = 'jet.dashboard.dashboard.DefaultIndexDashboard'
|
JET_INDEX_DASHBOARD = 'jet.dashboard.dashboard.DefaultIndexDashboard'
|
||||||
JET_APP_INDEX_DASHBOARD = 'dashboard.CustomIndexDashboard'
|
JET_APP_INDEX_DASHBOARD = 'bills.dashboard.CustomIndexDashboard'
|
||||||
# JET_INDEX_DASHBOARD = 'dashboard.CustomIndexDashboard'
|
# JET_INDEX_DASHBOARD = 'bills.dashboard.CustomIndexDashboard'
|
@ -1,9 +1,32 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
import pendulum
|
||||||
|
|
||||||
from .models import Bill
|
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)
|
@admin.register(Bill)
|
||||||
class BillAdmin(admin.ModelAdmin):
|
class BillAdmin(admin.ModelAdmin):
|
||||||
list_display = ['name', 'due', 'amount']
|
list_display = ['name', 'due', 'amount']
|
||||||
list_filter = ('name', 'type', 'is_paid', 'is_overdue', 'is_missed')
|
list_filter = ('name', 'type', 'is_paid', 'is_overdue', 'is_missed')
|
||||||
search_fields = ['name', 'type', 'amount']
|
search_fields = ['name', 'type', 'amount'
|
||||||
|
]
|
||||||
|
actions = [duplicate, duplicate_old, get_overdue_bills]
|
@ -1,7 +1,21 @@
|
|||||||
### Celery Tasks!
|
### Celery Tasks!
|
||||||
|
|
||||||
|
from .models import Bill
|
||||||
|
|
||||||
from celery import shared_task
|
from celery import shared_task
|
||||||
|
|
||||||
@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')
|
return('This is a test')
|
Loading…
Reference in New Issue
Block a user