def billing_task(): """ A recurring task which calculates billing. """ import billing from models import BillingLog billing.run_billing()
def run_billing(request): page_message = None run_billing_form = RunBillingForm(initial={'run_billing':True}) if request.method == 'POST': run_billing_form = RunBillingForm(request.POST) if run_billing_form.is_valid(): billing.run_billing() page_message = 'At your request, I have run <a href="%s">the bills</a>.' % (reverse('staff.views.bills', args=[], kwargs={}),) return render_to_response('staff/run_billing.html', { 'run_billing_form':run_billing_form, 'page_message':page_message, "billing_logs":BillingLog.objects.all() }, context_instance=RequestContext(request))
def billing_task(): """ A recurring task which calculates billing. The task runs once an hour, but will only run billing once every 24 hours. """ import billing from models import BillingLog last_day = datetime.now() - timedelta(hours=24) if not BillingLog.objects.filter(started__gt=last_day).exists(): billing.run_billing()
def billing_task(): """A recurring task which calculates billing""" billing.run_billing()