How to use the faculty.models.EventConfig.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 / event_types / career.py View on Github external
def post_init(self):
            # set the allowed position choices from the config from allowed units
            from faculty.models import EventConfig
            ecs = EventConfig.objects.filter(unit__in=self.units,
                                             event_type=AccreditationFlagEventHandler.EVENT_TYPE)
            choices = itertools.chain(*[ec.config.get('flags', []) for ec in ecs])
            self.fields['flag'].choices = choices
github sfu-fas / coursys / faculty / event_types / career.py View on Github external
def make_value_field(self, viewer, member_units):
        field = super(AccreditationFlagSearchRule, self).make_value_field(viewer, member_units)

        from faculty.models import EventConfig
        ecs = EventConfig.objects.filter(unit__in=member_units,
                                         event_type=AccreditationFlagEventHandler.EVENT_TYPE)
        field.choices += itertools.chain(*[ec.config.get('flags', []) for ec in ecs])

        return field
github sfu-fas / coursys / faculty / event_types / info.py View on Github external
def _committee_lookup():
        from faculty.models import EventConfig
        unit_lookup = CommitteeMemberHandler._unit_lookup()
        ecs = EventConfig.objects.filter(event_type=CommitteeMemberHandler.EVENT_TYPE)
        cttes = [ec.config.get('committees', []) for ec in ecs]
        return dict((c[0], (c[1], unit_lookup[c[2]])) for c in itertools.chain.from_iterable(cttes))
github sfu-fas / coursys / faculty / event_types / awards.py View on Github external
def get_fellowship_choices(cls, units, only_active=False):
        """
        Get the fellowship choices from EventConfig in these units, or superunits of them.
        """
        from faculty.models import EventConfig
        superunits = [u.super_units() for u in units] + [units]
        superunits =  set(u for sublist in superunits for u in sublist) # flatten list of lists
        ecs = EventConfig.objects.filter(unit__in=superunits,
                                         event_type=FellowshipEventHandler.EVENT_TYPE)
        choices = itertools.chain(*[ec.config.get('fellowships', []) for ec in ecs])
        if only_active:
            choices = ((short,int) for short,int,status in choices if status == 'ACTIVE')
        else:
            choices = ((short,int) for short,int,status in choices)
        return choices
github sfu-fas / coursys / faculty / views.py View on Github external
def course_accreditation_csv(request):
    viewer = get_object_or_404(Person, userid=request.user.username)
    units = Unit.sub_units(request.units)

    # Gather all visible accreditation flags for viewer from all units
    ecs = EventConfig.objects.filter(unit__in=units,
                                     event_type=AccreditationFlagEventHandler.EVENT_TYPE)
    flag_choices = Choices(*itertools.chain(*[ec.config.get('flags', []) for ec in ecs]))

    form = CourseAccreditationForm(request.GET, flags=flag_choices)

    if form.is_valid():
        start_code = form.cleaned_data.get('start_semester')
        end_code = form.cleaned_data.get('end_semester')
        operator = form.cleaned_data.get('operator')
        selected_flags = set(form.cleaned_data.get('flag'))

        # Since CourseOfferings require actual Semesters, ignore any semesters in the
        # input range that do not "exist".
        semester_codes = [semester.code
                          for semester in ReportingSemester.range(start_code, end_code)]
        semesters = Semester.objects.filter(name__in=semester_codes)
github sfu-fas / coursys / faculty / event_types / base.py View on Github external
def all_config_fields(cls, units, field):
        """
        Look up EventConfig.config[field] for each unit. Returns an iterable of [unit,] + config_val lists.
        """
        from faculty.models import EventConfig
        configs = EventConfig.objects.filter(unit__in=units, event_type=cls.EVENT_TYPE)
        unit_cfs = (([cfg.unit] + e for e in cfg.config.get(field, [])) for cfg in configs)
        return itertools.chain.from_iterable(unit_cfs)
github sfu-fas / coursys / faculty / event_types / info.py View on Github external
def get_committee_choices(cls, units, only_active=False):
        """
        Get the committee choices from EventConfig in these units, or superunits of them.
        """
        from faculty.models import EventConfig
        unit_lookup = CommitteeMemberHandler._unit_lookup()

        superunits = [u.super_units() for u in units] + [units]
        superunits =  set(u for sublist in superunits for u in sublist) # flatten list of lists
        ecs = EventConfig.objects.filter(unit__in=superunits,
                                         event_type=CommitteeMemberHandler.EVENT_TYPE)
        choices = itertools.chain(*[ec.config.get('committees', []) for ec in ecs])
        choices = (c for c in choices if c[-1] == 'ACTIVE')
        choices = ((short, CommitteeMemberHandler.get_committee_display_for(short)) for short,int,unit,status in choices)
        return choices