Exemplo n.º 1
0
class EventFilter(AMYFilterSet):
    assigned_to = ForeignKeyAllValuesFilter(Person, widget=Select2())
    host = ForeignKeyAllValuesFilter(Organization, widget=Select2())
    administrator = ForeignKeyAllValuesFilter(Organization, widget=Select2())

    STATUS_CHOICES = [
        ('', 'All'),
        ('active', 'Active'),
        ('past_events', 'Past'),
        ('ongoing_events', 'Ongoing'),
        ('upcoming_events', 'Upcoming'),
        ('unpublished_events', 'Unpublished'),
        ('published_events', 'Published'),
        ('uninvoiced_events', 'Uninvoiced'),
        ('metadata_changed', 'Detected changes in metadata'),
    ]
    state = EventStateFilter(choices=STATUS_CHOICES, label='Status',
                             widget=Select2())

    invoice_status = django_filters.ChoiceFilter(
        choices=Event.INVOICED_CHOICES,
    )

    tags = django_filters.ModelMultipleChoiceFilter(
        queryset=Tag.objects.all(), label='Tags',
        widget=ModelSelect2Multiple(),
    )

    country = AllCountriesFilter(widget=Select2())

    order_by = django_filters.OrderingFilter(
        fields=(
            'slug',
            'start',
            'end',
        ),
    )

    class Meta:
        model = Event
        fields = [
            'assigned_to',
            'tags',
            'host',
            'administrator',
            'invoice_status',
            'completed',
            'country',
        ]
Exemplo n.º 2
0
 class Meta:
     model = EventRequest
     exclude = (
         'created_at',
         'last_updated_at',
         'assigned_to',
         'data_types',
         'data_types_other',
         'attendee_data_analysis_level',
         'fee_waiver_request',
     )
     widgets = {
         'event':
         Select2(),
         'approx_attendees':
         forms.RadioSelect(),
         'attendee_domains':
         CheckboxSelectMultipleWithOthers('attendee_domains_other'),
         'attendee_academic_levels':
         forms.CheckboxSelectMultiple(),
         'attendee_computing_levels':
         forms.CheckboxSelectMultiple(),
         'travel_reimbursement':
         RadioSelectWithOther('travel_reimbursement_other'),
         'admin_fee_payment':
         forms.RadioSelect(),
         'country':
         ListSelect2(),
     }
Exemplo n.º 3
0
class WorkshopRequestFilter(AMYFilterSet, StateFilterSet):
    assigned_to = ForeignKeyAllValuesFilter(Person, widget=Select2())
    country = AllCountriesFilter(widget=Select2())
    requested_workshop_types = django_filters.ModelMultipleChoiceFilter(
        label='Requested workshop types',
        queryset=Curriculum.objects.all(),
        widget=widgets.CheckboxSelectMultiple(),
    )

    order_by = django_filters.OrderingFilter(fields=('created_at', ), )

    class Meta:
        model = WorkshopRequest
        fields = [
            'state',
            'assigned_to',
            'requested_workshop_types',
            'country',
        ]
Exemplo n.º 4
0
 class Meta:
     model = EventSubmission
     exclude = (
         'created_at',
         'last_updated_at',
         'assigned_to',
     )
     widgets = {
         'event': Select2(),
     }
Exemplo n.º 5
0
class EventRequestFilter(AMYFilterSet, StateFilterSet):
    assigned_to = ForeignKeyAllValuesFilter(Person, widget=Select2())
    country = AllCountriesFilter(widget=Select2())
    workshop_type = django_filters.ChoiceFilter(
        choices=(('swc', 'Software-Carpentry'), ('dc', 'Data-Carpentry')),
        label='Workshop type',
        empty_label='All',
    )

    order_by = django_filters.OrderingFilter(fields=('created_at', ), )

    class Meta:
        model = EventRequest
        fields = [
            'state',
            'assigned_to',
            'workshop_type',
            'country',
        ]
Exemplo n.º 6
0
class EventSubmissionFilter(AMYFilterSet, StateFilterSet):
    assigned_to = ForeignKeyAllValuesFilter(Person, widget=Select2())

    order_by = django_filters.OrderingFilter(fields=('created_at', ), )

    class Meta:
        model = EventSubmission
        fields = [
            'state',
            'assigned_to',
        ]
Exemplo n.º 7
0
 class Meta:
     model = DCSelfOrganizedEventRequest
     exclude = ('created_at', 'last_updated_at', 'assigned_to')
     widgets = {
         'event': Select2(),
         'instructor_status': forms.RadioSelect(),
         'is_partner': forms.RadioSelect(),
         'domains': forms.CheckboxSelectMultiple(),
         'topics': forms.CheckboxSelectMultiple(),
         'attendee_academic_levels': forms.CheckboxSelectMultiple(),
         'attendee_data_analysis_level': forms.CheckboxSelectMultiple(),
         'payment': forms.RadioSelect(),
     }
Exemplo n.º 8
0
class DCSelfOrganizedEventRequestFilter(AMYFilterSet, StateFilterSet):
    assigned_to = ForeignKeyAllValuesFilter(Person, widget=Select2())

    order_by = django_filters.OrderingFilter(fields=('created_at', ), )

    class Meta:
        model = DCSelfOrganizedEventRequest
        fields = [
            'state',
            'assigned_to',
        ]
        order_by = [
            '-created_at',
            'created_at',
        ]
Exemplo n.º 9
0
class AirportFilter(AMYFilterSet):
    fullname = django_filters.CharFilter(lookup_expr='icontains')

    continent = ContinentFilter(widget=Select2(), label="Continent")

    order_by = django_filters.OrderingFilter(fields=(
        'iata',
        'fullname',
    ),
                                             field_labels={
                                                 'iata': 'IATA',
                                                 'fullname': 'Full name',
                                             })

    class Meta:
        model = Airport
        fields = [
            'fullname',
        ]
Exemplo n.º 10
0
class OrganizationFilter(AMYFilterSet):
    country = AllCountriesFilter(widget=Select2())

    membership__variant = django_filters.MultipleChoiceFilter(
        label='Memberships (current or past)',
        choices=Membership.MEMBERSHIP_CHOICES,
        widget=Select2Multiple(),
    )

    order_by = django_filters.OrderingFilter(fields=(
        'fullname',
        'domain',
    ), )

    class Meta:
        model = Organization
        fields = [
            'country',
        ]
Exemplo n.º 11
0
 class Meta(SWCEventRequestNoCaptchaForm.Meta):
     exclude = (
         'created_at',
         'last_updated_at',
         'assigned_to',
         'admin_fee_payment',
         'attendee_computing_levels',
     )
     widgets = {
         'event':
         Select2(),
         'approx_attendees':
         forms.RadioSelect(),
         'attendee_domains':
         CheckboxSelectMultipleWithOthers('attendee_domains_other'),
         'data_types':
         RadioSelectWithOther('data_types_other'),
         'attendee_academic_levels':
         forms.CheckboxSelectMultiple(),
         'attendee_data_analysis_level':
         forms.CheckboxSelectMultiple(),
         'travel_reimbursement':
         RadioSelectWithOther('travel_reimbursement_other'),
     }
Exemplo n.º 12
0
class WorkshopStaffFilter(AMYFilterSet):
    country = django_filters.MultipleChoiceFilter(
        choices=list(Countries()),
        widget=Select2Multiple(),
        method="filter_country",
    )
    continent = ContinentFilter(widget=Select2(), label="Continent")
    lessons = django_filters.ModelMultipleChoiceFilter(
        label='Lessons',
        queryset=Lesson.objects.all(),
        widget=ModelSelect2Multiple(attrs=SIDEBAR_DAL_WIDTH),
        conjoined=True,  # `AND`
    )
    badges = django_filters.ModelMultipleChoiceFilter(
        label='Badges',
        queryset=Badge.objects.instructor_badges(),
        widget=ModelSelect2Multiple(attrs=SIDEBAR_DAL_WIDTH),
        conjoined=False,  # `OR`
    )
    is_trainer = django_filters.BooleanFilter(
        widget=widgets.CheckboxInput,
        method='filter_trainer',
    )
    languages = django_filters.ModelMultipleChoiceFilter(
        label='Languages',
        queryset=Language.objects.all(),
        widget=ModelSelect2Multiple(
            url='language-lookup',
            attrs=SIDEBAR_DAL_WIDTH,
        ),
        conjoined=True,  # `AND`
    )
    gender = django_filters.ChoiceFilter(
        label='Gender',
        choices=Person.GENDER_CHOICES,
    )
    was_helper = django_filters.BooleanFilter(
        widget=widgets.CheckboxInput,
        method='filter_helper',
    )
    was_organizer = django_filters.BooleanFilter(
        widget=widgets.CheckboxInput,
        method='filter_organizer',
    )
    is_in_progress_trainee = django_filters.BooleanFilter(
        widget=widgets.CheckboxInput,
        method='filter_in_progress_trainee',
    )

    def filter_country(self, qs, n, v):
        if v:
            return qs.filter(Q(airport__country__in=v) | Q(country__in=v))
        return qs

    def filter_trainer(self, qs, n, v):
        if v:
            return qs.filter(is_trainer__gte=1)
        return qs

    def filter_helper(self, qs, n, v):
        if v:
            return qs.filter(num_helper__gte=1)
        return qs

    def filter_organizer(self, qs, n, v):
        if v:
            return qs.filter(num_organizer__gte=1)
        return qs

    def filter_in_progress_trainee(self, qs, n, v):
        if v:
            return qs.filter(is_trainee__gte=1)
        return qs