Esempio n. 1
0
def attendance_student(id, all_years=False, order_by="Date", include_private_notes=False, type="odt"):
    """ Attendance report on particular student """
    from ecwsp.sis.report import get_default_data, pod_save
    student = Student.objects.get(id=id)
    if all_years:
        attendances = StudentAttendance.objects.filter(student=student)
    else:
        active_year = SchoolYear.objects.get(active_year=True)
        active_year_dates = (active_year.start_date, active_year.end_date)
        attendances = StudentAttendance.objects.filter(student=student, date__range=active_year_dates)
    if order_by == "Status": attendances = attendances.order_by('status') 
    
    data = get_default_data()
    
    data['attendances'] = []
    
    for attn in attendances:
        if include_private_notes:
            notes = unicode(attn.notes) + "  " + unicode(attn.private_notes)
        else:
            notes = unicode(attn.notes)
        attendance = Struct()
        attendance.date = attn.date
        attendance.status = attn.status
        attendance.notes = notes
        data['attendances'].append(attendance)
              
   # data['attendances'] = attendances
    data['student'] = student
    data['student_year'] = student.year
    
    template = Template.objects.get_or_create(name="Student Attendance Report")[0]
    filename = unicode(student) + "_Attendance"
    return pod_save(filename, "." + str(type), data, template.file.path)
Esempio n. 2
0
def attendance_student(id, all_years=False, order_by="Date", include_private_notes=False, type="odt"):
    """ Attendance report on particular student """
    from ecwsp.sis.report import get_default_data, pod_save
    student = Student.objects.get(id=id)
    if all_years:
        attendances = StudentAttendance.objects.filter(student=student)
    else:
        active_year = SchoolYear.objects.get(active_year=True)
        active_year_dates = (active_year.start_date, active_year.end_date)
        attendances = StudentAttendance.objects.filter(student=student, date__range=active_year_dates)
    if order_by == "Status": attendances = attendances.order_by('status') 
    
    data = get_default_data()
    
    data['attendances'] = []
    
    for attn in attendances:
        if include_private_notes:
            notes = unicode(attn.notes) + "  " + unicode(attn.private_notes)
        else:
            notes = unicode(attn.notes)
        attendance = Struct()
        attendance.date = attn.date
        attendance.status = attn.status
        attendance.notes = notes
        data['attendances'].append(attendance)
              
   # data['attendances'] = attendances
    data['student'] = student
    data['student_year'] = student.year
    
    template = Template.objects.get_or_create(name="Student Attendance Report")[0]
    filename = unicode(student) + "_Attendance"
    return pod_save(filename, "." + str(type), data, template.file.path)
Esempio n. 3
0
def daily_attendance_report(adate, private_notes=False, type="odt", request=None):
    from ecwsp.sis.models import GradeLevel
    from ecwsp.sis.report import get_school_day_number, pod_save, get_default_data
    template = Template.objects.get_or_create(name="Daily Attendance")[0]
    template = template.get_template_path(request)
    if not template:
        return HttpResponseRedirect(request.META.get('HTTP_REFERER','/'))
    
    data = get_default_data()
    data['selected_date'] = unicode(adate)
    data['school_day'] = get_school_day_number(adate)
    
    attendance = StudentAttendance.objects.filter(date=adate)
    students = Student.objects.filter(student_attn__in=attendance)
    
    active_year = SchoolYear.objects.get(active_year=True)
    active_year_dates = (active_year.start_date, active_year.end_date)
    
    for year in GradeLevel.objects.all():
        attns = attendance.filter(student__year__id=year.id)
        for attn in attns:
            if attn.status.absent:
                attn.total = StudentAttendance.objects.filter(student=attn.student, status__absent=True, status__half=False, date__range=active_year_dates).count()
                halfs = StudentAttendance.objects.filter(student=attn.student, status__absent=True, status__half=True,date__range=active_year_dates).count() / 2 
                attn.total += (float(halfs)/2)
            elif attn.status.tardy:
                attn.total = StudentAttendance.objects.filter(student=attn.student, status__tardy=True, date__range=active_year_dates).count()
            else:
                attn.total = StudentAttendance.objects.filter(student=attn.student, status=attn.status, date__range=active_year_dates).count()
        data['absences_' + str(year.id)] = attns
        
        attn_list = ""
        for status in AttendanceStatus.objects.exclude(name="Present"):
            attn = StudentAttendance.objects.filter(status=status, date=adate, student__year__id=year.id)
            if attn.count() > 0:
                attn_list += unicode(status.name) + " " + unicode(attn.count()) + ",  " 
        if len(attn_list) > 3: attn_list = attn_list[:-3]
        data['stat_' + str(year.id)] = attn_list
        
    
    data['comments'] = ""
    for attn in StudentAttendance.objects.filter(date=adate):
        if (attn.notes) or (attn.private_notes and private_notes):
            data['comments'] += unicode(attn.student) + ": "
            if attn.notes: data['comments'] += unicode(attn.notes) + "  "
            if attn.private_notes and private_notes: 
                data['comments'] += unicode(attn.private_notes) 
            data['comments'] += ",  "
    if len(data['comments']) > 3: data['comments'] = data['comments'][:-3]
    
    filename = "daily_attendance"
    return pod_save(filename, "." + str(type), data, template)
Esempio n. 4
0
def daily_attendance_report(adate, private_notes=False, type="odt", request=None):
    from ecwsp.sis.models import GradeLevel
    from ecwsp.sis.report import get_school_day_number, pod_save, get_default_data
    template = Template.objects.get_or_create(name="Daily Attendance")[0]
    template = template.get_template_path(request)
    if not template:
        return HttpResponseRedirect(request.META.get('HTTP_REFERER','/'))
    
    data = get_default_data()
    data['selected_date'] = unicode(adate)
    data['school_day'] = get_school_day_number(adate)
    
    attendance = StudentAttendance.objects.filter(date=adate)
    students = Student.objects.filter(student_attn__in=attendance)
    
    active_year = SchoolYear.objects.get(active_year=True)
    active_year_dates = (active_year.start_date, active_year.end_date)
    
    for year in GradeLevel.objects.all():
        attns = attendance.filter(student__year__id=year.id)
        for attn in attns:
            if attn.status.absent:
                attn.total = StudentAttendance.objects.filter(student=attn.student, status__absent=True, status__half=False, date__range=active_year_dates).count()
                halfs = StudentAttendance.objects.filter(student=attn.student, status__absent=True, status__half=True,date__range=active_year_dates).count() / 2 
                attn.total += (float(halfs)/2)
            elif attn.status.tardy:
                attn.total = StudentAttendance.objects.filter(student=attn.student, status__tardy=True, date__range=active_year_dates).count()
            else:
                attn.total = StudentAttendance.objects.filter(student=attn.student, status=attn.status, date__range=active_year_dates).count()
        data['absences_' + str(year.id)] = attns
        
        attn_list = ""
        for status in AttendanceStatus.objects.exclude(name="Present"):
            attn = StudentAttendance.objects.filter(status=status, date=adate, student__year__id=year.id)
            if attn.count() > 0:
                attn_list += unicode(status.name) + " " + unicode(attn.count()) + ",  " 
        if len(attn_list) > 3: attn_list = attn_list[:-3]
        data['stat_' + str(year.id)] = attn_list
        
    
    data['comments'] = ""
    for attn in StudentAttendance.objects.filter(date=adate):
        if (attn.notes) or (attn.private_notes and private_notes):
            data['comments'] += unicode(attn.student) + ": "
            if attn.notes: data['comments'] += unicode(attn.notes) + "  "
            if attn.private_notes and private_notes: 
                data['comments'] += unicode(attn.private_notes) 
            data['comments'] += ",  "
    if len(data['comments']) > 3: data['comments'] = data['comments'][:-3]
    
    filename = "daily_attendance"
    return pod_save(filename, "." + str(type), data, template)
Esempio n. 5
0
 def generate_contract_file(self):
     data = get_default_data()
     data['contract'] = self
     filename = unicode(self.company) + "_contract"
     if settings.PREFERED_FORMAT == "m":
         format = "doc"
     else:
         format = "odt"
     if self.company and self.company.alternative_contract_template:
         template = self.company.alternative_contract_template.file
     else:
         template = Template.get_or_make_blank(name="Work Study Contract").file.path
     if template :
         file = pod_save(filename, "." + str(format), data, template, get_tmp_file=True)
         self.contract_file.save(unicode(self.company) + "." + unicode(format), File(open(file)))
Esempio n. 6
0
 def generate_contract_file(self):
     data = get_default_data()
     data['contract'] = self
     filename = unicode(self.company) + "_contract"
     if settings.PREFERED_FORMAT == "m":
         format = "doc"
     else:
         format = "odt"
     if self.company and self.company.alternative_contract_template:
         template = self.company.alternative_contract_template.file
     else:
         template = Template.get_or_make_blank(
             name="Work Study Contract").file.path
     if template:
         file = pod_save(filename,
                         "." + str(format),
                         data,
                         template,
                         get_tmp_file=True)
         self.contract_file.save(
             unicode(self.company) + "." + unicode(format),
             File(open(file)))