Exemple #1
0
 def __init__(self, *args, **kwargs):
     super(AvailableCapacityForm, self).__init__(*args, **kwargs)
     if 'start_semester' not in self.data:
         self.data['start_semester'] = ReportingSemester.current().prev(
         ).prev().code
     if 'end_semester' not in self.data:
         self.data['end_semester'] = ReportingSemester.current().code
Exemple #2
0
 def __init__(self, *args, **kwargs):
     super(AvailableCapacityForm, self).__init__(*args, **kwargs)
     self.data = dict(self.data)
     if 'start_semester' not in self.data:
         self.data['start_semester'] = ReportingSemester.current().prev().prev().code
     if 'end_semester' not in self.data:
         self.data['end_semester'] = ReportingSemester.current().code
Exemple #3
0
 def semester_length(self):
     if self.event.end_date:
         rng = ReportingSemester.range(self.event.start_date,
                                       self.event.end_date)
     else:
         rng = ReportingSemester.range(self.event.start_date,
                                       datetime.date.today())
     return len(list(rng))
Exemple #4
0
 def prepare_value(self, value):
     if isinstance(value, (unicode, str)):
         return value
     elif value is None:
         return ''
     else:
         return ReportingSemester(value).code
Exemple #5
0
        def post_init(self):
            # finding the teaching load and set the decrease to that value
            if (self.person):
                from faculty.util import ReportingSemester
                from faculty.processing import FacultySummary
                semester = ReportingSemester(self.initial['start_date'])
                teaching_load = abs(FacultySummary(self.person).teaching_credits(semester)[1])
            else:
                teaching_load = 0

            self.fields['teaching_decrease'].initial = teaching_load
Exemple #6
0
 def get_semester(self, code):
     try:
         assert len(code) == 4
         assert code.isdigit()
         #s = Semester.objects.get(name=code)
         s = ReportingSemester(code)
         return s
     except AssertionError:
         #except (AssertionError, Semester.DoesNotExist):
         # Semester does not exist, or its in the wrong format
         return
Exemple #7
0
    def overlaps_semester(self, semester):
        """
        Returns CareerEvents occurring during the semester.
        """
        if isinstance(semester, Semester):
            semester = ReportingSemester(semester)

        start = semester.start_date
        end = semester.end_date

        end_okay = Q(end_date__isnull=True) | Q(end_date__gte=start)
        return self.exclude(status='D').filter(start_date__lte=end).filter(end_okay)
Exemple #8
0
    def effective_semester(self, semester):
        """
        Returns CareerEvents starting and ending within this semester.
        """
        if isinstance(semester, Semester):
            semester = ReportingSemester(semester)

        start = semester.start_date
        end = semester.end_date
        
        end_okay = Q(end_date__isnull=True) | Q(end_date__lte=end) & Q(end_date__gte=start)
        return self.exclude(status='D').filter(start_date__gte=start).filter(end_okay)
Exemple #9
0
    def to_python(self, value):
        if value in forms.fields.validators.EMPTY_VALUES:
            return None

        if not (len(value) == 4 and value.isdigit()):
            raise ValidationError(_('Invalid semester code'))

        try:
            semester = ReportingSemester(value)
        except ValueError:
            raise ValidationError(_('Invalid semester code'))

        return self.start and semester.start_date or semester.end_date
Exemple #10
0
 def semester_length(self):
     if self.event.end_date:
         rng = ReportingSemester.range(self.event.start_date, self.event.end_date)
     else:
         rng = ReportingSemester.range(self.event.start_date, datetime.date.today())
     return len(list(rng))