How to use the faculty.processing.FacultySummary function in faculty

To help you get started, we’ve selected a few faculty examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sfu-fas / coursys / faculty / views.py View on Github external
def _teaching_events_data(person, semester):
    cb = 0
    e = []
    courses = Member.objects.filter(role='INST', person=person, added_reason='AUTO', offering__semester__name=semester.code) \
        .exclude(offering__component='CAN').exclude(offering__flags=CourseOffering.flags.combined) \
        .select_related('offering', 'offering__semester')
    for course in courses:
        credits, reason = course.teaching_credit_with_reason()
        enrl = '%i/%i' % (course.offering.enrl_tot, course.offering.enrl_cap)
        e += [(semester.code, course, course.offering.title, credits, reason, enrl, '')]
        cb += course.teaching_credit()

    teaching_events = FacultySummary(person).teaching_events(semester)
    for event in teaching_events:
        credits, load_decrease = FacultySummary(person).teaching_event_info(event)
        if load_decrease:
            e += [(semester.code, event.get_event_type_display(), event.get_handler().short_summary(), load_decrease, '', '', event)]
        if credits:
            e += [(semester.code, event.get_event_type_display(), event.get_handler().short_summary(), credits, '', '', event)]
        cb += credits + load_decrease

    return cb, e
github sfu-fas / coursys / faculty / views.py View on Github external
def _teaching_events_data(person, semester):
    cb = 0
    e = []
    courses = Member.objects.filter(role='INST', person=person, added_reason='AUTO', offering__semester__name=semester.code) \
        .exclude(offering__component='CAN').exclude(offering__flags=CourseOffering.flags.combined) \
        .select_related('offering', 'offering__semester')
    for course in courses:
        credits, reason = course.teaching_credit_with_reason()
        enrl = '%i/%i' % (course.offering.enrl_tot, course.offering.enrl_cap)
        e += [(semester.code, course, course.offering.title, credits, reason, enrl, '')]
        cb += course.teaching_credit()

    teaching_events = FacultySummary(person).teaching_events(semester)
    for event in teaching_events:
        credits, load_decrease = FacultySummary(person).teaching_event_info(event)
        if load_decrease:
            e += [(semester.code, event.get_event_type_display(), event.get_handler().short_summary(), load_decrease, '', '', event)]
        if credits:
            e += [(semester.code, event.get_event_type_display(), event.get_handler().short_summary(), credits, '', '', event)]
        cb += credits + load_decrease

    return cb, e
github sfu-fas / coursys / faculty / views.py View on Github external
for role in fac_roles_pay:
        person = role.person
        unit = role.unit
        salary_events = copy.copy(FacultySummary(person).salary_events(date, units=[unit]))
        add_salary_total = add_bonus_total = 0
        salary_fraction_total = 1

        for event in salary_events:
            event.add_salary, event.salary_fraction, event.add_bonus = FacultySummary(person).salary_event_info(event)
            add_salary_total += event.add_salary
            salary_fraction_total = salary_fraction_total*event.salary_fraction
            add_bonus_total += event.add_bonus

        # get most recent step and rank from base_salary
        recent_salary_update = FacultySummary(person).recent_salary(date, units=[unit])
        if recent_salary_update is not None:
            try:
                step = recent_salary_update.config["step"]
            except KeyError:
                step = "-"
            try:
                handler = recent_salary_update.get_handler()
                rank = handler.get_display('rank')
            except KeyError:
                rank = "-"
        else:
            step = "-"
            rank = "-"

        current_salary = FacultySummary(person).salary(date, units=[unit])
github sfu-fas / coursys / faculty / views.py View on Github external
# only want to account for the study leave event once
        if event.event_type == 'STUDYLEAVE':
            handler = event.get_handler()
            if ReportingSemester.start_and_end_dates(semester.code)[0] <= event.start_date:
                slc = handler.get_study_leave_credits()
                running_total -= slc
                if show_in_table:
                    e += [(semester.code, 'Begin Study Leave', '', -slc , running_total)]
            if event.end_date and ReportingSemester.start_and_end_dates(semester.code)[1] >= event.end_date:
                tot = handler.get_credits_carried_forward()
                if tot != None:
                    running_total = tot
                if show_in_table:
                    e += [(semester.code, 'End Study Leave', '', '' , running_total)]
        else:
            credits, load_decrease = FacultySummary(person).teaching_event_info(event)
            running_total += credits
            if show_in_table and credits:
                    e += [(semester.code, event.get_event_type_display(), credits, credits, running_total)]

    return e, running_total
github sfu-fas / coursys / faculty / views.py View on Github external
def _fallout_report_data(request, start_date, end_date):
    sub_unit_ids = Unit.sub_unit_ids(request.units)
    fac_roles = Role.objects.filter(role='FAC', unit__id__in=sub_unit_ids).select_related('person', 'unit')
    table = []
    tot_fallout = 0
    for role in fac_roles:
        unit = role.unit
        p = role.person
        salary = FacultySummary(p).salary(end_date, units=[unit])
        salary_events = CareerEvent.objects.approved().overlaps_daterange(start_date, end_date) \
            .filter(person=p, unit=unit, flags=CareerEvent.flags.affects_salary)
        for event in salary_events:
            if event.event_type == 'LEAVE' or event.event_type == 'STUDYLEAVE':
                days = event.get_duration_within_range(start_date, end_date)
                fraction = FacultySummary(p).salary_event_info(event)[1]
                d = fraction.denominator
                n = fraction.numerator
                fallout = Decimal((salary - salary*n/d)*days/365).quantize(Decimal('.01'), rounding=ROUND_DOWN)
                tot_fallout += fallout

                table += [(unit.label, p, event, event.start_date, event.end_date, days, salary, fraction, fallout)]
    return table
github sfu-fas / coursys / faculty / views.py View on Github external
def _salary_index_data(request, date):
    sub_unit_ids = Unit.sub_unit_ids(request.units)
    fac_roles_pay = Role.objects.filter(role='FAC', unit__id__in=sub_unit_ids).select_related('person', 'unit')
    fac_pay_summary = []

    for role in fac_roles_pay:
        person = role.person
        unit = role.unit
        salary_events = copy.copy(FacultySummary(person).salary_events(date, units=[unit]))
        add_salary_total = add_bonus_total = 0
        salary_fraction_total = 1

        for event in salary_events:
            event.add_salary, event.salary_fraction, event.add_bonus = FacultySummary(person).salary_event_info(event)
            add_salary_total += event.add_salary
            salary_fraction_total = salary_fraction_total*event.salary_fraction
            add_bonus_total += event.add_bonus

        # get most recent step and rank from base_salary
        recent_salary_update = FacultySummary(person).recent_salary(date, units=[unit])
        if recent_salary_update is not None:
            try:
                step = recent_salary_update.config["step"]
            except KeyError:
                step = "-"
            try:
                handler = recent_salary_update.get_handler()
                rank = handler.get_display('rank')
            except KeyError:
                rank = "-"
github sfu-fas / coursys / faculty / views.py View on Github external
def _fallout_report_data(request, start_date, end_date):
    sub_unit_ids = Unit.sub_unit_ids(request.units)
    fac_roles = Role.objects.filter(role='FAC', unit__id__in=sub_unit_ids).select_related('person', 'unit')
    table = []
    tot_fallout = 0
    for role in fac_roles:
        unit = role.unit
        p = role.person
        salary = FacultySummary(p).salary(end_date, units=[unit])
        salary_events = CareerEvent.objects.approved().overlaps_daterange(start_date, end_date) \
            .filter(person=p, unit=unit, flags=CareerEvent.flags.affects_salary)
        for event in salary_events:
            if event.event_type == 'LEAVE' or event.event_type == 'STUDYLEAVE':
                days = event.get_duration_within_range(start_date, end_date)
                fraction = FacultySummary(p).salary_event_info(event)[1]
                d = fraction.denominator
                n = fraction.numerator
                fallout = Decimal((salary - salary*n/d)*days/365).quantize(Decimal('.01'), rounding=ROUND_DOWN)
                tot_fallout += fallout

                table += [(unit.label, p, event, event.start_date, event.end_date, days, salary, fraction, fallout)]
    return table
github sfu-fas / coursys / faculty / views.py View on Github external
recent_salary_update = FacultySummary(person).recent_salary(date, units=[unit])
        if recent_salary_update is not None:
            try:
                step = recent_salary_update.config["step"]
            except KeyError:
                step = "-"
            try:
                handler = recent_salary_update.get_handler()
                rank = handler.get_display('rank')
            except KeyError:
                rank = "-"
        else:
            step = "-"
            rank = "-"

        current_salary = FacultySummary(person).salary(date, units=[unit])

        fac_pay_summary += [(person, unit, current_salary, add_salary_total, salary_fraction_total,
                             add_bonus_total, step, rank)]

    return fac_pay_summary