How to use the faculty.event_types.base.CareerEventHandlerBase 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 / event_types / info.py View on Github external
def get_org_class_display(self):
        return self.EntryForm.ORG_CLASSES.get(self.get_config('org_class'))

    def short_summary(self):
        org_name = self.get_config('org_name')
        return 'Affiliated with {}'.format(org_name)

def _committee_helptext():
    "Lazily generate the helptext so reverse isn't called until it is possible."
    url = reverse('faculty:event_config', kwargs={'event_type': 'committee'})
    h = mark_safe('More committees can be added on the <a href="%s">configuration</a> page' % (escape(url)))
    return h
committee_helptext = lazy(_committee_helptext, SafeText)

class CommitteeMemberHandler(CareerEventHandlerBase):

    EVENT_TYPE = 'COMMITTEE'
    NAME = 'Service'
    config_name = 'Committee'

    TO_HTML_TEMPLATE = '''
        {% extends 'faculty/event_base.html' %}{% load event_display %}{% block dl %}
        <dt>Committee</dt><dd>{{ handler|get_display:'committee' }}</dd>
        {% endblock %}
    '''

    class EntryForm(BaseEntryForm):
        committee = forms.ChoiceField(label='Committee', choices=[], help_text=committee_helptext())

        def post_init(self):
            # set the allowed position choices from the config from allowed units
github sfu-fas / coursys / faculty / event_types / info.py View on Github external
class OtherEventHandler(CareerEventHandlerBase):

    EVENT_TYPE = 'OTHER_NOTE'
    NAME = 'Other Event / Note'

    class EntryForm(BaseEntryForm):

        def post_init(self):
            self.fields['comments'].help_text = 'Enter details about the event or note here.'
            self.fields['comments'].required = True

    def short_summary(self):
        return 'Other Event / Note'


class ResumeEventHandler(CareerEventHandlerBase):

    EVENT_TYPE = 'RESUME'
    NAME = 'Resume / CV'
    IS_INSTANT = True

    class EntryForm(BaseEntryForm):
        file = forms.FileField(required=True)

        def post_init(self):
            self.fields['comments'].help_text = 'Enter details about the event or note here.'
            self.fields['comments'].required = False



    def short_summary(self):
        return 'Resume / CV'
github sfu-fas / coursys / faculty / event_types / base.py View on Github external
def __init__(self, units, *args, **kwargs):
            super(CareerEventHandlerBase.ConfigItemForm, self).__init__(*args, **kwargs)
            unit_choices = [(u.id, u.name) for u in Unit.sub_units(units)]
            self.fields['unit'].choices = unit_choices
github sfu-fas / coursys / faculty / event_types / career.py View on Github external
}

    def get_rank_display(self):
        return RANK_CHOICES.get(self.get_config('rank'), 'unknown rank')
    def get_result_display(self):
        return self.EntryForm.RESULT_CHOICES.get(self.get_config('result'), 'unknown outcome')
    def get_steps_display(self):
        return SALARY_STEPS_CHOICES.get(self.get_config('steps'), 'unknown outcome')
    def get_steps2_display(self):
        return SALARY_STEPS_CHOICES.get(self.get_config('steps2'), 'unknown outcome')

    def short_summary(self):
        return "Promotion application: {0}".format(self.get_result_display(),)


class SalaryReviewEventHandler(CareerEventHandlerBase):
    EVENT_TYPE = 'SALARYREV'
    NAME = "Salary Review"
    IS_INSTANT = False

    TO_HTML_TEMPLATE = '''{% extends "faculty/event_base.html" %}{% load event_display %}{% block dl %}
        <dt>Steps Granted</dt><dd>{{ handler|get_display:"steps" }}</dd>
        {% endblock %}'''

    class EntryForm(BaseEntryForm):

        steps = forms.ChoiceField(label='Steps', choices=SALARY_STEPS_CHOICES,
                                   help_text='Annual step increase given')


    SEARCH_RULES = {
        'steps': search.ComparableSearchRule,
github sfu-fas / coursys / faculty / event_types / awards.py View on Github external
SemesterField
from faculty.event_types.mixins import TeachingCareerEvent, SalaryCareerEvent
from faculty.event_types.search import ChoiceSearchRule, ComparableSearchRule, \
                                       StringSearchRule


class FellowshipPositionSearchRule(ChoiceSearchRule):
    """A hack to make viewer specific choice fields work."""

    def make_value_field(self, viewer, member_units):
        field = super(FellowshipPositionSearchRule, self).make_value_field(viewer, member_units)
        field.choices = FellowshipEventHandler.get_fellowship_choices(member_units, only_active=False)
        return field


class FellowshipEventHandler(CareerEventHandlerBase, SalaryCareerEvent, TeachingCareerEvent):
    """
    Appointment to a fellowship/chair
    """

    EVENT_TYPE = 'FELLOW'
    NAME = 'Fellowship / Chair'
    config_name = 'Fellowship'

    TO_HTML_TEMPLATE = """
        {% extends "faculty/event_base.html" %}{% load event_display %}{% block dl %}
        <dt>Position</dt><dd>{{ handler|get_display:"position" }}</dd>
        <dt>Add salary</dt><dd>${{ handler|get_display:"add_salary"|floatformat:2 }}</dd>
        <dt>Add pay</dt><dd>${{ handler|get_display:"add_pay"|floatformat:2 }}</dd>
        <dt>Teaching credit</dt><dd>{{ handler|get_display:"teaching_credit" }} (per semester)</dd>
        {% endblock %}
    """
github sfu-fas / coursys / faculty / templatetags / event_display.py View on Github external
def get_config(event, field):
    if isinstance(event, CareerEventHandlerBase):
        return event.get_config(field, 'unknown')
    else:
        return event.config.get(field, 'unknown')
github sfu-fas / coursys / faculty / event_types / career.py View on Github external
except TypeError:
            frac = 0

        return '%s Leave @ %.0f%%' % (self.get_reason_display(), frac*100)

    def salary_adjust_annually(self):
        leave_fraction = self.get_config('leave_fraction')
        return SalaryAdjust(0, leave_fraction, 0)

    def teaching_adjust_per_semester(self):
        credits = self.get_config('teaching_credits', 0)
        load_decrease = self.get_config('teaching_load_decrease')
        return TeachingAdjust(credits, load_decrease)


class StudyLeaveEventHandler(CareerEventHandlerBase, SalaryCareerEvent, TeachingCareerEvent):
    """
    Study leave event
    """

    EVENT_TYPE = 'STUDYLEAVE'
    NAME = "Study Leave"

    TO_HTML_TEMPLATE = """
        {% extends "faculty/event_base.html" %}{% load event_display %}{% block dl %}
        <dt>Option</dt><dd>{{ handler|get_display:"option" }} </dd>
        <dt>Pay Fraction</dt><dd>{{ handler|get_display:"pay_fraction" }}</dd>
        <dt>Report Received</dt><dd>{{ handler|get_display:"report_received"|yesno }}</dd>
        <dt>Report Received On</dt><dd>{{ handler|get_display:"report_received_date" }}</dd>
        <dt>Teaching Load Decrease</dt><dd>{{ handler|get_display:"teaching_decrease" }}</dd>
        <dt>Deferred Salary</dt><dd>{{ handler|get_display:"deferred_salary"|yesno }}</dd>
        <dt>Accumulated Credits</dt><dd>{{ handler|get_display:"accumulated_credits" }}</dd>
github sfu-fas / coursys / faculty / event_types / info.py View on Github external
from django.utils.html import conditional_escape as escape
from django.urls import reverse
from django.utils.functional import lazy
from django.utils.functional import SimpleLazyObject

from coredata.models import Unit

from faculty.event_types import fields, search
from faculty.event_types.base import BaseEntryForm
from faculty.event_types.base import CareerEventHandlerBase
from faculty.event_types.choices import Choices
from faculty.event_types.base import SalaryAdjust, TeachingAdjust
from faculty.event_types.mixins import TeachingCareerEvent, SalaryCareerEvent


class ExternalAffiliationHandler(CareerEventHandlerBase):

    EVENT_TYPE = 'EXTERN_AFF'
    NAME = 'External Affiliation'

    TO_HTML_TEMPLATE = '''
        {% extends 'faculty/event_base.html' %}{% load event_display %}{% block dl %}
        <dt>Organization Name</dt><dd>{{ handler|get_display:'org_name' }}</dd>
        <dt>Organization Type</dt><dd>{{ handler|get_display:'org_type'}}</dd>
        <dt>Organization Class</dt><dd>{{ handler|get_display:'org_class'}}</dd>
        <dt>Is Research Institute / Centre?</dt><dd>{{ handler|get_display:'is_research'|yesno }}</dd>
        <dt>Is Adjunct?</dt><dd>{{ handler|get_display:'is_adjunct'|yesno }}</dd>
        {% endblock %}
    '''

    class EntryForm(BaseEntryForm):
github sfu-fas / coursys / faculty / event_types / awards.py View on Github external
self.fields['position'].choices = choices

        def clean(self):
            data = self.cleaned_data
            if 'unit' not in data:
                raise forms.ValidationError("Couldn't check unit for fellowship ownership.")

            choices = FellowshipEventHandler.get_fellowship_choices([data['unit']], only_active=True)

            found = [short for short,int in choices if short == data['position']]
            if not found:
                raise forms.ValidationError("That fellowship is not owned by the selected unit.")

            return data

    class ConfigItemForm(CareerEventHandlerBase.ConfigItemForm):
        flag_short = forms.CharField(label='Fellowship short form', help_text='e.g. LEEF')
        flag = forms.CharField(label='Fellowship full name', help_text='e.g. Leef Chair')

        def clean_flag_short(self):
            """
            Make sure the flag is globally-unique.
            """
            flag_short = self.cleaned_data['flag_short']
            FellowshipEventHandler.ConfigItemForm.check_unique_key('FELLOW', 'fellowships', flag_short, 'fellowship')
            return flag_short

        def save_config(self):
            from faculty.models import EventConfig
            ec, _ = EventConfig.objects.get_or_create(unit=self.unit_object, event_type='FELLOW')
            fellows = ec.config.get('fellowships', [])
            fellows.append([self.cleaned_data['flag_short'], self.cleaned_data['flag'], 'ACTIVE'])
github sfu-fas / coursys / faculty / event_types / career.py View on Github external
ec = EventConfig.objects.get(unit=self.event.unit, event_type=self.EVENT_TYPE)
            fellowships = dict(ec.config.get('flags', {}))
        except EventConfig.DoesNotExist:
            fellowships = {}

        flag = self.event.config.get('flag', '???')
        return fellowships.get(flag, flag)

    @classmethod
    def default_title(cls):
        return 'Accreditation Flag'

    def short_summary(self):
        return "Has {0}".format(self.get_flag_display())

class ContractReviewEventHandler(CareerEventHandlerBase):
    EVENT_TYPE = 'CONTRACTRV'
    NAME = "Contract Renewal"
    IS_INSTANT = False

    TO_HTML_TEMPLATE = '''
        {% extends "faculty/event_base.html" %}
            {% load event_display %}
            {% block dl %}
            <dt>Result</dt>
            <dd>{{ handler|get_display:"result" }}</dd>
        {% endblock %}'''

    class EntryForm(BaseEntryForm):
        result = forms.ChoiceField(label='Result', choices=CONTRACT_REVIEW_CHOICES)

    SEARCH_RULES = {