You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

20 lines
612 B

# coding=utf-8
import os
import django
import sys
sys.path.append("/var/www/projects/lms/")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lms.settings")
django.setup()
from finance.models import Bill
from access.models import User
from courses.models import Course
result = {}
for user in User.objects.all():
result[user.email] = dict({course.id: False for course in Course.objects.all()})
for bill in Bill.objects.filter(status='F').order_by('date'):
if result[bill.user.email][bill.service.course.id]:
bill.delete()
else:
result[bill.user.email][bill.service.course.id] = True