def get_stat(show_id, status): if type(status) is not list: status = [status] x = len(Enrollments.filter(course__year=getyear(),course__tradition=K[show_id]['10'],status__in=status)) xv = len(Enrollments.filter(course__year=getyear(),course__tradition=K[show_id]['15'],status__in=status)) xx = len(Enrollments.filter(course__year=getyear(),course__tradition=K[show_id]['20'],status__in=status)) return { '10':x, '15':xv, '20':xx, 'total': (x * 10) + (xv * 15) + (xx * 20) }
def stand(self, me): if me.owner_type == 'Family': return False elif me.owner_type == 'Student': return bool( Enrollments.filter(student_id=me.owner.id, course__teacher=self))
def signin(request): day = request.GET.get('day') if not day: context = { 'today': datetime.datetime.today(), } return render(request, 'reports/signin_home.html', context) else: start = cleandate(request.GET.get('start')) qset = Enrollments.filter( course__tradition__m=True, course__tradition__day=day, course__year=getyear(start), ).order_by( 'student__family__last', 'student__family__name_num', 'student__birthday', 'course__tradition__start', ).distinct() weeks = request.GET.get('weeks') starts = list(set(Each(qset).course.tradition.start)) starts.sort() context = { 'qset': starts, } return render(request, 'reports/signin.html', context)
def search(request, **kwargs): query = request.GET.get('query') if ' in ' in query: match = re.match(r'(?P<student>.*?) in (?P<course>.*)', query).groupdict() students = search_query(match['student'], all_tables=False, student=True) courses = search_query(match['course'], all_tables=False, course=True) results = Enrollments.filter(student__in=students, course__in=courses) else: results = search_query(query) context = { 'results': results, 'query': query, } return render(request, 'rest/search_results.html', context)
def create(self, **kwargs): kwargs.setdefault('year', getyear()) year0000 = (int(kwargs['year']) % 100) * 10000 qset = self.filter(id__gte=year0000,id__lte=year0000+9999) kwargs.setdefault('id',max([year0000]+list(Each(qset).id)) + 1) # kwargs.setdefault('amount', kwargs['family'].total_tuition_in(kwargs['year'])) this = super(InvoiceManager, self).create(**kwargs) qset = Enrollments.filter( student__family=kwargs['family'], course__year=kwargs['year'], status__in=['aud_pass','aud_lock','need_pay','maydefer']) for q in qset: q.invoice = this q.status = 'invoiced' q.save() amount = this.update_amount() this.update_amount() return this
def auditions_in(self, year): return Enrollments.filter(student=self, status__startswith="aud", course__year=year)
def auditions(self): return Enrollments.filter(student=self, status__startswith="aud")
def all_enrollments(self): return Enrollments.filter(student=self).order_by('course__year')
def all_enrollments_in(self, year): return Enrollments.filter(student__family=self, course__year=year)
def reset(user=None): if user: Enrollments.filter(student__family=user.owner,course__year=getyear()).delete() else: Enrollments.filter(course__year=getyear()).delete()
def rescind(request, **kwargs): for enrollment in Enrollments.filter(status__in=['deferred','maydefer']): enrollment.status = 'need_pay' enrollment.save() return redirect('/admin/deferred/')
def search_word(word, all_tables=True, **kwargs): results = set([]) if all_tables or kwargs.get('family'): results |= set( Families.filter( Q( Q(hid=word) | Q(last__icontains=word) | Q(phone__icontains=word) | Q(phone_type=word) | Q(email__icontains=word)))) if all_tables or kwargs.get('parent'): results |= set( Parents.filter( Q( Q(hid=word) | Q(first__icontains=word) | Q(alt_last__icontains=word) | Q(alt_phone__icontains=word) | Q(phone_type=word) | Q(alt_email__icontains=word)))) if all_tables or kwargs.get('student'): results |= set( Students.filter( Q( Q(hid=word) | Q(first__icontains=word) | Q(alt_first__icontains=word) | Q(family__last__icontains=word) | Q(alt_last__icontains=word) | Q(alt_phone__icontains=word) | Q(alt_email__icontains=word) | Q(needs__icontains=word)))) if all_tables or kwargs.get('coursetrad'): results |= set( CourseTrads.filter( Q( Q(id=word) | Q(oid=word) | Q(title__icontains=word) | Q(alias_id=word) | Q(eligex__icontains=word) | Q(default=word) | Q(action=word)))) if all_tables or kwargs.get('course'): results |= set( Courses.filter( Q( Q(id=word) | Q(tradition__id=word) | Q(tradition__oid=word) | Q(title__icontains=word) | Q(tradition__title__icontains=word) | Q(tradition__alias_id=word) | Q(tradition__eligex__icontains=word) | Q(tradition__default=word) | Q(tradition__action__icontains=word)))) if all_tables or kwargs.get('address'): results |= set( Addresses.filter( Q( Q(line1__icontains=word) | Q(line2__icontains=word) | Q(city__icontains=word) | Q(state__icontains=word) | Q(zipcode__icontains=word)))) if all_tables or kwargs.get('venue'): results |= set(Venues.filter(name__icontains=word)) if all_tables or kwargs.get('enrollment'): results |= set(Enrollments.filter(role__icontains=word)) if all_tables or kwargs.get('user'): results |= set(Users.filter(username__icontains=word)) if all_tables or kwargs.get('teacher'): results |= set( Teachers.filter( Q( Q(first__icontains=word) | Q(last__icontains=word) | Q(phone__icontains=word) | Q(email__icontains=word)))) if all_tables or kwargs.get('invoice'): results |= set( Invoices.filter( Q( Q(family__last__icontains=word) | Q(enrollment__course__title__icontains=word) | Q(paypal__txn_id__icontains=word)))) return results