Exemple #1
0
def nuke(request):
	# bad = restricted(request,6)
	# if bad:
	# 	return bad

	# Main
	request.session.clear()
	# Payment
	# PayPals.all().delete()
	# Invoices.all().delete()
	# People
	Addresses.all().delete()
	Parents.all().delete()
	Families.all().delete()
	Students.all().delete()
	Users.all().delete()
	# Program
	Venues.all().delete()
	CourseTrads.all().delete()
	Courses.all().delete()
	Enrollments.all().delete()
	# RAdmin
	Policies.all().delete()
	print '\n\n'+' '*34+'THE RADIANCE OF A THOUSAND SUNS'+'\n\n'
	return redirect ('/seed/load')
Exemple #2
0
def overview(request, **kwargs):
    bad = restricted(request, 5)
    if bad:
        return bad
    GET = request.GET.copy()
    year = GET.setdefault('year', getyear())
    if 'repop' in GET:
        all_students = Students.all()
        course = Courses.fetch(id=GET['repop'])
        if course:
            course.repop(all_students=all_students)
            return redirect('/reports/overview/?year=' + year)
    courses = Courses.filter(year=year).order_by('tradition__order')
    nTickets = {
        'SB':
        [len(Courses.fetch(tradition__id='KB', year=year).students), 0, 0],
        'SC':
        [len(Courses.fetch(tradition__id='KC', year=year).students), 0, 0],
        'SG': [
            len(Courses.fetch(tradition__id='KG', year=year).students),
            len(Courses.fetch(tradition__id='KS', year=year).students),
            len(Courses.fetch(tradition__id='KW', year=year).students),
        ],
        'SJ': [
            len(Courses.fetch(tradition__id='KJ', year=year).students),
            len(Courses.fetch(tradition__id='KT', year=year).students),
            len(Courses.fetch(tradition__id='KX', year=year).students),
        ],
        'SH': [
            len(Courses.fetch(tradition__id='KH', year=year).students),
            len(Courses.fetch(tradition__id='KU', year=year).students),
            len(Courses.fetch(tradition__id='KY', year=year).students),
        ],
        'SR': [
            len(Courses.fetch(tradition__id='KR', year=year).students),
            len(Courses.fetch(tradition__id='KV', year=year).students),
            len(Courses.fetch(tradition__id='KZ', year=year).students),
        ],
    }
    tSlots = 0
    tFilled = 0
    tuitionRev = 0
    for course in courses.filter(tradition__e=True, tradition__m=True):
        tSlots += course.tradition.nSlots
        tFilled += len(course.students)
        tuitionRev += course.revenue
    context = {
        'date':
        datetime.datetime.now(),
        'year':
        Year(year),
        'ar':
        '{:02}'.format(int(year) % 100),
        'real':
        courses.filter(tradition__e=True, tradition__m=True),
        'auto':
        courses.filter(tradition__e=True, tradition__m=False),
        'stat':
        Courses.filter(tradition__r=False,
                       year=year).order_by('tradition__order'),
        'rf':
        Courses.fetch(tradition__id='RF', year=year),
        'tSlots':
        tSlots,
        'tFilled':
        tFilled,
        'tuitionRev':
        tuitionRev,
        'total': {
            'SB':
            nTickets['SB'][0] * 10,
            'SC':
            nTickets['SC'][0] * 10,
            'SG':
            nTickets['SG'][0] * 10 + nTickets['SG'][1] * 15 +
            nTickets['SG'][2] * 20,
            'SH':
            nTickets['SH'][0] * 10 + nTickets['SH'][1] * 15 +
            nTickets['SH'][2] * 20,
            'SJ':
            nTickets['SJ'][0] * 10 + nTickets['SJ'][1] * 15 +
            nTickets['SJ'][2] * 20,
            'SR':
            nTickets['SR'][0] * 10 + nTickets['SR'][1] * 15 +
            nTickets['SR'][2] * 20,
            '10':
            sum(Each(nTickets.values()).__getitem__(0)),
            '15':
            sum(Each(nTickets.values()).__getitem__(1)),
            '20':
            sum(Each(nTickets.values()).__getitem__(2)),
            'tt':
            sum(Each(nTickets.values()).__getitem__(0)) * 10 +
            sum(Each(nTickets.values()).__getitem__(1)) * 15 +
            sum(Each(nTickets.values()).__getitem__(2)) * 20,
        },
        'latest_enrollment':
        Enrollments.all().order_by('-updated_at')[0]
    }
    prepaidRev = context['prepaidRev'] = context['total']['tt'] * 10
    context['totalRev'] = prepaidRev + context['tuitionRev'] + context[
        'rf'].revenue
    return render(request, 'reports/overview.html', context)