Exemplo n.º 1
0
def semester_config(request, semester_name=None):
    if semester_name:
        semester = get_object_or_404(Semester, name=semester_name)
    else:
        semester = Semester.next_starting()

    unit_choices = [(u.id, u.name) for u in request.units]
    if request.method == 'POST':
        form = SemesterConfigForm(request.POST)
        form.fields['unit'].choices = unit_choices
        if form.is_valid():
            config = SemesterConfig.get_config(
                units=[form.cleaned_data['unit']], semester=semester)
            config.set_start_date(form.cleaned_data['start_date'])
            config.set_end_date(form.cleaned_data['end_date'])
            config.save()
            messages.success(
                request,
                'Updated semester configuration for %s.' % (semester.name))
            return HttpResponseRedirect(reverse('ra.views.search'))
    else:
        config = SemesterConfig.get_config(units=request.units,
                                           semester=semester)
        form = SemesterConfigForm(initial={
            'start_date': config.start_date(),
            'end_date': config.end_date()
        })
        form.fields['unit'].choices = unit_choices

    return render(request, 'ra/semester_config.html', {
        'semester': semester,
        'form': form
    })
Exemplo n.º 2
0
def new_student(request, userid):
    person = get_object_or_404(Person, find_userid_or_emplid(userid))
    semester = Semester.next_starting()
    semesterconfig = SemesterConfig.get_config(request.units, semester)
    student = get_object_or_404(Person, find_userid_or_emplid(userid))
    initial = {
        'person': student.emplid,
        'start_date': semesterconfig.start_date(),
        'end_date': semesterconfig.end_date(),
        'hours': 80
    }
    scholarship_choices, hiring_faculty_choices, unit_choices, project_choices, account_choices = _appointment_defaults(
        request.units, emplid=student.emplid)
    gss = GradStudent.objects.filter(person=student)
    if gss:
        gradstudent = gss[0]
        initial['sin'] = gradstudent.person.sin()

    raform = RAForm(initial=initial)
    raform.fields['person'] = forms.CharField(widget=forms.HiddenInput())
    raform.fields['scholarship'].choices = scholarship_choices
    raform.fields['hiring_faculty'].choices = hiring_faculty_choices
    raform.fields['unit'].choices = unit_choices
    raform.fields['project'].choices = project_choices
    raform.fields['account'].choices = account_choices
    return render(request, 'ra/new.html', {'raform': raform, 'person': person})
Exemplo n.º 3
0
 def run(self):
     sems = Semester.objects.filter(name__gte='1001', name__lte=Semester.next_starting().name)
     u = Unit.objects.get(label='ENSC')
     courses = CourseOffering.objects.prefetch_related('meeting_time').filter(semester__in=sems, owner=u,
                                                                              graded=True).exclude(
         flags=CourseOffering.flags.combined).exclude(subject='DDP').order_by('semester', 'subject', 'number')
     course_history = Table()
     course_history.append_column('Semester')
     course_history.append_column('Course')
     course_history.append_column('Instructor')
     course_history.append_column('Enrolment')
     course_history.append_column('Campus')
     course_history.append_column('Joint With')
     course_history.append_column('Lecture Times')
     course_history.append_column('Instructor(s) Rank(s)')
     for course in courses:
         semester = course.semester.label()
         label = course.name()
         instr = course.instructors_printing_str()
         enrl = '%i/%i' % (course.enrl_tot, course.enrl_cap)
         if course.campus in CAMPUSES_SHORT:
             campus = CAMPUSES_SHORT[course.campus]
         else:
             campus = 'Unknown'
         if course.config.get('joint_with'):
             joint = str(', '.join(course.config.get('joint_with')))
         else:
             joint = ''
         meeting_times = ''
         mt = [t for t in course.meeting_time.all() if t.meeting_type == 'LEC']
         if mt:
             meeting_times = ', '.join(str("%s %s-%s" % (WEEKDAYS[t.weekday], t.start_time, t.end_time)) for t in mt)
         ranks = "; ".join(CareerEvent.ranks_as_of_semester(p.id, course.semester) for p in course.instructors())
         course_history.append_row([semester, label, instr, enrl, campus, joint, meeting_times, ranks])
     self.artifacts.append(course_history)
Exemplo n.º 4
0
def new(request):
    scholarship_choices, hiring_faculty_choices, unit_choices, project_choices, account_choices = _appointment_defaults(request.units)
    if request.method == 'POST':
        data = request.POST.copy()
        if data['pay_frequency'] == 'L':
            # force legal values into the non-submitted (and don't-care) fields for lump sum pay
            data['biweekly_pay'] = 1
            data['hourly_pay'] = 1
            data['hours'] = 1
            data['pay_periods'] = 1

        raform = RAForm(data)
        raform.fields['hiring_faculty'].choices = hiring_faculty_choices
        raform.fields['unit'].choices = unit_choices
        raform.fields['project'].choices = project_choices
        raform.fields['account'].choices = account_choices

        if raform.is_valid():
            userid = raform.cleaned_data['person'].userid_or_emplid()
            appointment = raform.save(commit=False)
            appointment.set_use_hourly(raform.cleaned_data['use_hourly'])
            appointment.save()
            messages.success(request, 'Created RA Appointment for ' + appointment.person.name())
            return HttpResponseRedirect(reverse(student_appointments, kwargs=({'userid': userid})))
    else:
        semester = Semester.next_starting()
        semesterconfig = SemesterConfig.get_config(request.units, semester)
        raform = RAForm(initial={'start_date': semesterconfig.start_date(), 'end_date': semesterconfig.end_date(), 'hours': 80 })
        raform.fields['scholarship'].choices = scholarship_choices
        raform.fields['hiring_faculty'].choices = hiring_faculty_choices
        raform.fields['unit'].choices = unit_choices
        raform.fields['project'].choices = project_choices
        raform.fields['account'].choices = account_choices
    return render(request, 'ra/new.html', { 'raform': raform })
Exemplo n.º 5
0
def XXX_import_applic(request):
    unit_choices = [(u.id, u.name) for u in request.units]
    semester_choices = [(s.id, s.label()) for s in Semester.objects.filter()]
    if request.method == 'POST':
        form = UploadApplicantsForm(data=request.POST, files=request.FILES)
        form.fields['unit'].choices = unit_choices
        form.fields['semester'].choices = semester_choices
        if form.is_valid():
            data = form.cleaned_data['csvfile'].read()
            unit_id = form.cleaned_data['unit']
            semester_id = form.cleaned_data['semester']
            user = Person.objects.get(userid=request.user.username)
            if settings.USE_CELERY:
                from grad.tasks import process_pcs_task
                process_pcs_task.delay(data, unit_id, semester_id, user)
                messages.success(request, "Importing applicant data. You will receive an email with the results in a few minutes.")
            else:
                from grad.forms import process_pcs_export
                res = process_pcs_export(data, unit_id, semester_id, user)
                messages.success(request, "Imported applicant data.")
                return HttpResponse('<pre>'+res+'</pre>')       

            return HttpResponseRedirect(reverse(index))
    else:
        next_sem = Semester.next_starting()
        form = UploadApplicantsForm(initial={'semester': next_sem.id})
        form.fields['unit'].choices = unit_choices
        form.fields['semester'].choices = semester_choices

    context = {
               'form': form,
               }
    return render(request, 'grad/import_applic.html', context)
Exemplo n.º 6
0
    def testApplication(self):
        p = Person.objects.get(emplid=210012345)
        # Create three visas, one that should be expired, one that will soon, and one that is valid.
        v1 = Visa(person=p,
                  status=VISA_STATUSES[0][0],
                  start_date=date(2000, 01, 01),
                  end_date=date(2000, 01, 01))
        v2 = Visa(person=p,
                  status=VISA_STATUSES[0][0],
                  start_date=date(2000, 01, 01),
                  end_date=date(2099, 01, 01))
        next_semester = Semester.next_starting()
        almost_expired_date = next_semester.end - timedelta(days=5)
        v3 = Visa(person=p,
                  status=VISA_STATUSES[0][0],
                  start_date=date(2000, 01, 01),
                  end_date=almost_expired_date)

        self.assertEqual(v1.is_valid(), False)
        self.assertEqual(v1.is_expired(), True)
        self.assertEqual(v1.is_almost_expired(), False)
        self.assertEqual(v2.is_valid(), True)
        self.assertEqual(v2.is_expired(), False)
        self.assertEqual(v2.is_almost_expired(), False)
        self.assertEqual(v3.is_valid(), True)
        self.assertEqual(v3.is_expired(), False)
        self.assertEqual(v3.is_almost_expired(), True)
Exemplo n.º 7
0
def reappoint(request, ra_slug):
    appointment = get_object_or_404(RAAppointment,
                                    slug=ra_slug,
                                    deleted=False,
                                    unit__in=request.units)
    semester = Semester.next_starting()
    semesterconfig = SemesterConfig.get_config(request.units, semester)
    raform = RAForm(instance=appointment,
                    initial={
                        'person': appointment.person.emplid,
                        'reappointment': True,
                        'start_date': semesterconfig.start_date(),
                        'end_date': semesterconfig.end_date(),
                        'hours': 80,
                        'use_hourly': appointment.use_hourly()
                    })
    scholarship_choices, hiring_faculty_choices, unit_choices, project_choices, account_choices, program_choices = \
        _appointment_defaults(request.units, emplid=appointment.person.emplid)
    raform.fields['hiring_faculty'].choices = hiring_faculty_choices
    raform.fields['scholarship'].choices = scholarship_choices
    raform.fields['unit'].choices = unit_choices
    raform.fields['project'].choices = project_choices
    raform.fields['account'].choices = account_choices
    raform.fields['program'].choices = program_choices
    return render(request, 'ra/new.html', {
        'raform': raform,
        'appointment': appointment
    })
Exemplo n.º 8
0
def new(request):
    scholarship_choices, hiring_faculty_choices, unit_choices, project_choices, account_choices =_appointment_defaults(request.units)
    if request.method == 'POST':
        data = request.POST.copy()
        if data['pay_frequency'] == 'L':
            # force legal values into the non-submitted (and don't-care) fields for lump sum pay
            data['biweekly_pay'] = 1
            data['hourly_pay'] = 1
            data['hours'] = 1
            data['pay_periods'] = 1

        raform = RAForm(data)
        raform.fields['hiring_faculty'].choices = hiring_faculty_choices
        raform.fields['unit'].choices = unit_choices
        raform.fields['project'].choices = project_choices
        raform.fields['account'].choices = account_choices

        if raform.is_valid():
            userid = raform.cleaned_data['person'].userid_or_emplid()
            appointment = raform.save(commit=False)
            appointment.set_use_hourly(raform.cleaned_data['use_hourly'])
            appointment.save()
            messages.success(request, 'Created RA Appointment for ' + appointment.person.name())
            return HttpResponseRedirect(reverse(student_appointments, kwargs=({'userid': userid})))
    else:
        semester = Semester.next_starting()
        semesterconfig = SemesterConfig.get_config(request.units, semester)
        raform = RAForm(initial={'start_date': semesterconfig.start_date(), 'end_date': semesterconfig.end_date(), 'hours': 80 })
        raform.fields['scholarship'].choices = scholarship_choices
        raform.fields['hiring_faculty'].choices = hiring_faculty_choices
        raform.fields['unit'].choices = unit_choices
        raform.fields['project'].choices = project_choices
        raform.fields['account'].choices = account_choices
    return render(request, 'ra/new.html', { 'raform': raform })
Exemplo n.º 9
0
def XXX_import_applic(request):
    unit_choices = [(u.id, u.name) for u in request.units]
    semester_choices = [(s.id, s.label()) for s in Semester.objects.filter()]
    if request.method == 'POST':
        form = UploadApplicantsForm(data=request.POST, files=request.FILES)
        form.fields['unit'].choices = unit_choices
        form.fields['semester'].choices = semester_choices
        if form.is_valid():
            data = form.cleaned_data['csvfile'].read()
            unit_id = form.cleaned_data['unit']
            semester_id = form.cleaned_data['semester']
            user = Person.objects.get(userid=request.user.username)
            if settings.USE_CELERY:
                from grad.tasks import process_pcs_task
                process_pcs_task.delay(data, unit_id, semester_id, user)
                messages.success(request, "Importing applicant data. You will receive an email with the results in a few minutes.")
            else:
                from grad.forms import process_pcs_export
                res = process_pcs_export(data, unit_id, semester_id, user)
                messages.success(request, "Imported applicant data.")
                return HttpResponse('<pre>'+res+'</pre>')       

            return HttpResponseRedirect(reverse('grad:index'))
    else:
        next_sem = Semester.next_starting()
        form = UploadApplicantsForm(initial={'semester': next_sem.id})
        form.fields['unit'].choices = unit_choices
        form.fields['semester'].choices = semester_choices

    context = {
               'form': form,
               }
    return render(request, 'grad/import_applic.html', context)
Exemplo n.º 10
0
def all_promises(request, semester_name=None):
    if semester_name is None:
        semester = Semester.next_starting()
    else:
        semester = get_object_or_404(Semester, name=semester_name)
    promises = Promise.objects.filter(end_semester=semester, 
                                      student__program__unit__in=request.units)
    context = {'promises': promises, 'semester': semester}
    return render(request, 'grad/all_promises.html', context)
Exemplo n.º 11
0
def all_promises(request, semester_name=None):
    if semester_name is None:
        semester = Semester.next_starting()
    else:
        semester = get_object_or_404(Semester, name=semester_name)
    promises = Promise.objects.filter(end_semester=semester,
                                      student__program__unit__in=request.units)
    context = {'promises': promises, 'semester': semester}
    return render(request, 'grad/all_promises.html', context)
Exemplo n.º 12
0
def funding_report(request, semester_name=None):
    if semester_name is None:
        semester = Semester.next_starting()
    else:
        semester = get_object_or_404(Semester, name=semester_name)
    
    programs = GradProgram.objects.filter(unit__in=request.units, hidden=False).order_by('label')
    programs = _build_funding_totals(semester, programs, request.units)
    
    these_units = ', '.join(u.name for u in request.units)
    context = {'semester': semester, 'programs': programs, 'these_units': these_units}
    
    return render(request, 'grad/funding_report.html', context)
Exemplo n.º 13
0
 def run(self):
     sems = Semester.objects.filter(name__gte='1001',
                                    name__lte=Semester.next_starting().name)
     u = Unit.objects.filter(label__in=['CMPT', 'ENSC', 'MSE'])
     courses = CourseOffering.objects.prefetch_related(
         'meeting_time').filter(
             semester__in=sems, owner__in=u, graded=True).exclude(
                 flags=CourseOffering.flags.combined).exclude(
                     subject='DDP').exclude(component='CAN').order_by(
                         'semester', 'subject', 'number')
     course_history = Table()
     course_history.append_column('Semester')
     course_history.append_column('Course')
     course_history.append_column('Units')
     course_history.append_column('Instructor')
     course_history.append_column('Enrolment')
     course_history.append_column('Campus')
     course_history.append_column('Joint With')
     course_history.append_column('Lecture Times')
     course_history.append_column('Instructor(s) Rank(s)')
     for course in courses:
         semester = course.semester.label()
         label = course.name()
         units = course.units
         instr = course.instructors_printing_str()
         enrl = '%i/%i' % (course.enrl_tot, course.enrl_cap)
         if course.campus in CAMPUSES_SHORT:
             campus = CAMPUSES_SHORT[course.campus]
         else:
             campus = 'Unknown'
         if course.config.get('joint_with'):
             joint = str(', '.join(course.config.get('joint_with')))
         else:
             joint = ''
         meeting_times = ''
         mt = [
             t for t in course.meeting_time.all() if t.meeting_type == 'LEC'
         ]
         if mt:
             meeting_times = ', '.join(
                 str("%s %s-%s" %
                     (WEEKDAYS[t.weekday], t.start_time, t.end_time))
                 for t in mt)
         ranks = "; ".join(
             CareerEvent.ranks_as_of_semester(p.id, course.semester)
             for p in course.instructors())
         course_history.append_row([
             semester, label, units, instr, enrl, campus, joint,
             meeting_times, ranks
         ])
     self.artifacts.append(course_history)
Exemplo n.º 14
0
def reappoint(request, ra_slug):
    appointment = get_object_or_404(RAAppointment, slug=ra_slug, deleted=False, unit__in=request.units)
    semester = Semester.next_starting()
    semesterconfig = SemesterConfig.get_config(request.units, semester)
    raform = RAForm(instance=appointment, initial={'person': appointment.person.emplid, 'reappointment': True,
                    'start_date': semesterconfig.start_date(), 'end_date': semesterconfig.end_date(), 'hours': 80,
                    'use_hourly': appointment.use_hourly() })
    scholarship_choices, hiring_faculty_choices, unit_choices, project_choices, account_choices, program_choices = \
        _appointment_defaults(request.units, emplid=appointment.person.emplid)
    raform.fields['hiring_faculty'].choices = hiring_faculty_choices
    raform.fields['scholarship'].choices = scholarship_choices
    raform.fields['unit'].choices = unit_choices
    raform.fields['project'].choices = project_choices
    raform.fields['account'].choices = account_choices
    raform.fields['program'].choices = program_choices
    return render(request, 'ra/new.html', { 'raform': raform, 'appointment': appointment })
Exemplo n.º 15
0
def reappoint(request, ra_slug):
    appointment = get_object_or_404(RAAppointment, slug=ra_slug, deleted=False, unit__in=request.units)
    semester = Semester.next_starting()
    semesterconfig = SemesterConfig.get_config(request.units, semester)
    raform = RAForm(instance=appointment, initial={'person': appointment.person.emplid, 'reappointment': True,
                    'start_date': semesterconfig.start_date(), 'end_date': semesterconfig.end_date(), 'hours': 80,
                    'use_hourly': appointment.use_hourly() })
    raform.fields['hiring_faculty'].choices = possible_supervisors(request.units)
    scholarship_choices = [("", "---------")]
    for s in Scholarship.objects.filter(student__person__emplid = appointment.person.emplid):
            scholarship_choices.append((s.pk, s.scholarship_type.unit.label + ": " + s.scholarship_type.name + " (" + s.start_semester.name + " to " + s.end_semester.name + ")"))
    raform.fields['scholarship'].choices = scholarship_choices
    raform.fields['unit'].choices = [(u.id, u.name) for u in request.units]
    raform.fields['project'].choices = [(p.id, unicode(p.project_number)) for p in Project.objects.filter(unit__in=request.units)]
    raform.fields['account'].choices = [(a.id, u'%s (%s)' % (a.account_number, a.title)) for a in Account.objects.filter(unit__in=request.units)]
    return render(request, 'ra/new.html', { 'raform': raform, 'appointment': appointment })
Exemplo n.º 16
0
def reappoint(request, ra_slug):
    appointment = get_object_or_404(RAAppointment, slug=ra_slug, deleted=False)
    semester = Semester.next_starting()
    semesterconfig = SemesterConfig.get_config(request.units, semester)
    raform = RAForm(instance=appointment, initial={'person': appointment.person.emplid, 'reappointment': True,
                    'start_date': semesterconfig.start_date(), 'end_date': semesterconfig.end_date(), 'hours': 80,
                    'use_hourly': appointment.use_hourly() })
    raform.fields['hiring_faculty'].choices = possible_supervisors(request.units)
    scholarship_choices = [("", "---------")]
    for s in Scholarship.objects.filter(student__person__emplid = appointment.person.emplid):
            scholarship_choices.append((s.pk, s.scholarship_type.unit.label + ": " + s.scholarship_type.name + " (" + s.start_semester.name + " to " + s.end_semester.name + ")"))
    raform.fields['scholarship'].choices = scholarship_choices
    raform.fields['unit'].choices = [(u.id, u.name) for u in request.units]
    raform.fields['project'].choices = [(p.id, unicode(p.project_number)) for p in Project.objects.filter(unit__in=request.units)]
    raform.fields['account'].choices = [(a.id, u'%s (%s)' % (a.account_number, a.title)) for a in Account.objects.filter(unit__in=request.units)]
    return render(request, 'ra/new.html', { 'raform': raform, 'appointment': appointment })
Exemplo n.º 17
0
    def testApplication(self):
        p = Person.objects.get(emplid=210012345)
        # Create three visas, one that should be expired, one that will soon, and one that is valid.
        v1 = Visa(person=p, status=VISA_STATUSES[0][0], start_date=date(2000,01,01), end_date=date(2000,01,01))
        v2 = Visa(person=p, status=VISA_STATUSES[0][0], start_date=date(2000,01,01), end_date=date(2099,01,01))
        next_semester = Semester.next_starting()
        almost_expired_date = next_semester.end - timedelta(days=5)
        v3 = Visa(person=p, status=VISA_STATUSES[0][0], start_date=date(2000,01,01), end_date=almost_expired_date)

        self.assertEqual(v1.is_valid(), False)
        self.assertEqual(v1.is_expired(), True)
        self.assertEqual(v1.is_almost_expired(), False)
        self.assertEqual(v2.is_valid(), True)
        self.assertEqual(v2.is_expired(), False)
        self.assertEqual(v2.is_almost_expired(), False)
        self.assertEqual(v3.is_valid(), True)
        self.assertEqual(v3.is_expired(), False)
        self.assertEqual(v3.is_almost_expired(), True)
Exemplo n.º 18
0
def new_student(request, userid):
    person = get_object_or_404(Person, find_userid_or_emplid(userid))
    semester = Semester.next_starting()
    semesterconfig = SemesterConfig.get_config(request.units, semester)
    student = get_object_or_404(Person, find_userid_or_emplid(userid))
    initial = {'person': student.emplid, 'start_date': semesterconfig.start_date(), 'end_date': semesterconfig.end_date(), 'hours': 80 }
    scholarship_choices, hiring_faculty_choices, unit_choices, project_choices, account_choices =_appointment_defaults(request.units, emplid=student.emplid)
    gss = GradStudent.objects.filter(person=student)
    if gss:
        gradstudent = gss[0]
        initial['sin'] = gradstudent.person.sin()
    
    raform = RAForm(initial=initial)
    raform.fields['person'] = forms.CharField(widget=forms.HiddenInput())
    raform.fields['scholarship'].choices = scholarship_choices
    raform.fields['hiring_faculty'].choices = hiring_faculty_choices
    raform.fields['unit'].choices = unit_choices
    raform.fields['project'].choices = project_choices
    raform.fields['account'].choices = account_choices
    return render(request, 'ra/new.html', { 'raform': raform, 'person': person })
Exemplo n.º 19
0
def download_promises(request, semester_name=None):
    if semester_name is None:
        semester = Semester.next_starting()
    else:
        semester = get_object_or_404(Semester, name=semester_name)
    response = HttpResponse(content_type='text/csv')
    response['Content-Disposition'] = 'inline; filename="promises-%s-%s.csv"' % (semester.name,
                                                                                 datetime.now().strftime('%Y%m%d'))
    writer = csv.writer(response)
    writer.writerow(['Student', 'Program', 'Start Semester', 'Status', 'Promised', 'Received', 'Difference'])
    promises = Promise.objects.filter(end_semester=semester,
                                      student__program__unit__in=request.units)
    for p in promises:
        student = p.student.person.sortname()
        program = p.student.program.label
        start = p.student.start_semester.label()
        status = p.student.get_current_status_display()
        promised = p.amount
        received = p.received()
        difference = p.difference()
        writer.writerow([student, program, start, status, promised, received, difference])

    return response
Exemplo n.º 20
0
def semester_config(request, semester_name=None):
    if semester_name:
        semester = get_object_or_404(Semester, name=semester_name)
    else:
        semester = Semester.next_starting()

    unit_choices = [(u.id, u.name) for u in request.units]
    if request.method == 'POST':
        form = SemesterConfigForm(request.POST)
        form.fields['unit'].choices = unit_choices
        if form.is_valid():
            config = SemesterConfig.get_config(units=[form.cleaned_data['unit']], semester=semester)
            config.set_start_date(form.cleaned_data['start_date'])
            config.set_end_date(form.cleaned_data['end_date'])
            config.save()
            messages.success(request, 'Updated semester configuration for %s.' % (semester.name))
            return HttpResponseRedirect(reverse('ra.views.search'))
    else:
        config = SemesterConfig.get_config(units=request.units, semester=semester)
        form = SemesterConfigForm(initial={'start_date': config.start_date(), 'end_date': config.end_date()})
        form.fields['unit'].choices = unit_choices

    return render(request, 'ra/semester_config.html', {'semester': semester, 'form': form})
Exemplo n.º 21
0
 def is_almost_expired(self):
     next_semester = Semester.next_starting()
     return (self.is_valid()) and (self.end_date is not None and self.end_date < next_semester.end)
Exemplo n.º 22
0
 def is_almost_expired(self):
     next_semester = Semester.next_starting()
     return (self.is_valid()) and (self.end_date is not None
                                   and self.end_date < next_semester.end)