How to use the faculty.models.CareerEvent.objects.filter 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 / tests.py View on Github external
url = reverse('faculty.views.change_event', kwargs={'userid': person.userid, 'event_slug': event.slug})
        resp = c.get(url)
        inputs = [l for l in resp.content.split('\n') if 'name="load"' in l]
        inputs_correct_value = [l for l in inputs if 'value="6"' in l]
        self.assertEquals(len(inputs_correct_value), 1)

        # POST a change and make sure the right value ends up in the DB
        data = {
            'start_date_0': '2000-09-01',
            'end_date_0': '',
            'unit': str(unit.id),
            'load': '5',
            'comments': '',
        }
        c.post(url, data)
        new_ce = CareerEvent.objects.filter(unit=unit, person=person, event_type=etype)[0]
        self.assertEquals(new_ce.config['load'], '5/3')
github sfu-fas / coursys / faculty / models.py View on Github external
def current_base_salary(cls, person):
        """
        Return a string representing the current base salary for this person.  If the person has more than
        one currently effective one, they get added together.
        """
        salaries = CareerEvent.objects.filter(person=person, event_type='SALARY').effective_now()
        if not salaries:
            return 'unknown'
        # One could theoretically have more than one active base salary (for example, if one is a member of more than
        # one school and gets a salary from both).  In that case, add them up.
        total = Decimal(0)
        for s in salaries:
            if 'base_salary' in s.config:
                total += Decimal(s.config.get('base_salary'))
        # format it nicely with commas, see http://stackoverflow.com/a/10742904/185884
        return str('$' + "{:,}".format(total))
github sfu-fas / coursys / faculty / models.py View on Github external
def ranks_as_of_semester(cls, person_id, semester):
        """
        Return a string representing the rank(s) for this person as of the beginning of a given semester.
        """
        salaries = CareerEvent.objects.filter(person__id=person_id, event_type='SALARY').effective_date(semester.start)
        if not salaries:
            return 'unknown'

        ranks = set(s.get_handler().get_rank_display() for s in salaries)
        return ', '.join(ranks)