Skip to content

Tables

hypha.apply.funds.tables

User module-attribute

User = get_user_model()

SubmissionsTable

Bases: Table

Base table for listing submissions, do not include admin data to this table

title class-attribute instance-attribute

title = LinkColumn('funds:submissions:detail', text=render_title, args=[A('pk')], orderable=True, attrs={'td': {'class': 'js-title'}, 'a': {'data-tippy-content': lambda record: render_title(record), 'data-tippy-placement': 'top', 'class': "truncate inline-block w-[calc(100%-2rem)] after:content-[''] after:block"}})

submit_time class-attribute instance-attribute

submit_time = DateColumn(verbose_name=gettext_lazy('Submitted'))

phase class-attribute instance-attribute

phase = Column(verbose_name=gettext_lazy('Status'), order_by=('status'), attrs={'td': {'data-actions': render_actions, 'class': 'js-actions'}})

stage class-attribute instance-attribute

stage = Column(verbose_name=gettext_lazy('Type'), order_by=('status'))

fund class-attribute instance-attribute

fund = Column(verbose_name=gettext_lazy('Fund'), accessor='page')

comments class-attribute instance-attribute

comments = Column(accessor='comment_count', verbose_name=gettext_lazy('Comments'))

last_update class-attribute instance-attribute

last_update = DateColumn(accessor='last_update', verbose_name=gettext_lazy('Last updated'))

Meta

model class-attribute instance-attribute
order_by class-attribute instance-attribute
order_by = ('-last_update')
fields class-attribute instance-attribute
fields = ('title', 'phase', 'stage', 'fund', 'round', 'submit_time', 'last_update')
sequence class-attribute instance-attribute
sequence = fields + ('comments')
template_name class-attribute instance-attribute
template_name = 'funds/tables/table.html'
row_attrs class-attribute instance-attribute
row_attrs = {'class': make_row_class, 'data-record-id': lambda record: id, 'data-archived': lambda record: is_archive}
attrs class-attribute instance-attribute
attrs = {'class': 'all-submissions-table'}
empty_text class-attribute instance-attribute
empty_text = gettext_lazy('No submissions available')

render_user

render_user(value)
Source code in hypha/apply/funds/tables.py
def render_user(self, value):
    return value.get_full_name()

render_phase

render_phase(value)
Source code in hypha/apply/funds/tables.py
def render_phase(self, value):
    return format_html("<span>{}</span>", value)

order_last_update

order_last_update(qs, desc)
Source code in hypha/apply/funds/tables.py
def order_last_update(self, qs, desc):
    update_order = getattr(F("last_update"), "desc" if desc else "asc")(
        nulls_last=True
    )

    qs = qs.order_by(update_order, "submit_time")
    return qs, True

get_column_class_names

get_column_class_names(classes_set, bound_column)
Source code in hypha/apply/funds/tables.py
def get_column_class_names(self, classes_set, bound_column):
    classes_set = super(SubmissionsTable, self).get_column_class_names(
        classes_set, bound_column
    )
    classes_set.add(bound_column.name)
    return classes_set

ReviewerSubmissionsTable

Bases: SubmissionsTable

title class-attribute instance-attribute

title = LinkColumn('funds:submissions:detail', text=render_title, args=[A('pk')], orderable=True, attrs={'td': {'class': 'js-title'}, 'a': {'data-tippy-content': lambda record: render_title(record), 'data-tippy-placement': 'top', 'class': "truncate inline-block w-[calc(100%-2rem)] after:content-[''] after:block"}})

submit_time class-attribute instance-attribute

submit_time = DateColumn(verbose_name=gettext_lazy('Submitted'))

phase class-attribute instance-attribute

phase = Column(verbose_name=gettext_lazy('Status'), order_by=('status'), attrs={'td': {'data-actions': render_actions, 'class': 'js-actions'}})

stage class-attribute instance-attribute

stage = Column(verbose_name=gettext_lazy('Type'), order_by=('status'))

fund class-attribute instance-attribute

fund = Column(verbose_name=gettext_lazy('Fund'), accessor='page')

comments class-attribute instance-attribute

comments = Column(accessor='comment_count', verbose_name=gettext_lazy('Comments'))

last_update class-attribute instance-attribute

last_update = DateColumn(accessor='last_update', verbose_name=gettext_lazy('Last updated'))

Meta

Bases: Meta

model class-attribute instance-attribute
order_by class-attribute instance-attribute
order_by = ('-last_update')
fields class-attribute instance-attribute
fields = ('title', 'phase', 'stage', 'fund', 'round', 'submit_time', 'last_update')
sequence class-attribute instance-attribute
sequence = fields + ('comments')
template_name class-attribute instance-attribute
template_name = 'funds/tables/table.html'
row_attrs class-attribute instance-attribute
row_attrs = {'class': make_row_class, 'data-record-id': lambda record: id, 'data-archived': lambda record: is_archive}
attrs class-attribute instance-attribute
attrs = {'class': 'all-submissions-table'}
empty_text class-attribute instance-attribute
empty_text = gettext_lazy('No submissions available')
orderable class-attribute instance-attribute
orderable = False

render_user

render_user(value)
Source code in hypha/apply/funds/tables.py
def render_user(self, value):
    return value.get_full_name()

render_phase

render_phase(value)
Source code in hypha/apply/funds/tables.py
def render_phase(self, value):
    return format_html("<span>{}</span>", value)

order_last_update

order_last_update(qs, desc)
Source code in hypha/apply/funds/tables.py
def order_last_update(self, qs, desc):
    update_order = getattr(F("last_update"), "desc" if desc else "asc")(
        nulls_last=True
    )

    qs = qs.order_by(update_order, "submit_time")
    return qs, True

get_column_class_names

get_column_class_names(classes_set, bound_column)
Source code in hypha/apply/funds/tables.py
def get_column_class_names(self, classes_set, bound_column):
    classes_set = super(SubmissionsTable, self).get_column_class_names(
        classes_set, bound_column
    )
    classes_set.add(bound_column.name)
    return classes_set

LabeledCheckboxColumn

Bases: CheckBoxColumn

header property

header

wrap_with_label

wrap_with_label(checkbox, for_value)
Source code in hypha/apply/funds/tables.py
def wrap_with_label(self, checkbox, for_value):
    return format_html(
        '<label for="{}">{}</label>',
        for_value,
        checkbox,
    )

render

render(value, record, bound_column)
Source code in hypha/apply/funds/tables.py
def render(self, value, record, bound_column):
    checkbox = super().render(value=value, record=record, bound_column=bound_column)
    return self.wrap_with_label(checkbox, value)

BaseAdminSubmissionsTable

Bases: SubmissionsTable

title class-attribute instance-attribute

title = LinkColumn('funds:submissions:detail', text=render_title, args=[A('pk')], orderable=True, attrs={'td': {'class': 'js-title'}, 'a': {'data-tippy-content': lambda record: render_title(record), 'data-tippy-placement': 'top', 'class': "truncate inline-block w-[calc(100%-2rem)] after:content-[''] after:block"}})

submit_time class-attribute instance-attribute

submit_time = DateColumn(verbose_name=gettext_lazy('Submitted'))

phase class-attribute instance-attribute

phase = Column(verbose_name=gettext_lazy('Status'), order_by=('status'), attrs={'td': {'data-actions': render_actions, 'class': 'js-actions'}})

stage class-attribute instance-attribute

stage = Column(verbose_name=gettext_lazy('Type'), order_by=('status'))

fund class-attribute instance-attribute

fund = Column(verbose_name=gettext_lazy('Fund'), accessor='page')

comments class-attribute instance-attribute

comments = Column(accessor='comment_count', verbose_name=gettext_lazy('Comments'))

last_update class-attribute instance-attribute

last_update = DateColumn(accessor='last_update', verbose_name=gettext_lazy('Last updated'))

lead class-attribute instance-attribute

lead = Column(order_by=('lead__full_name'))

reviews_stats class-attribute instance-attribute

reviews_stats = TemplateColumn(template_name='funds/tables/column_reviews.html', verbose_name=mark_safe('Reviews<div>Comp. <span class="counts-separator">/</span> Assgn.</div>'), orderable=False)

screening_status class-attribute instance-attribute

screening_status = Column(verbose_name=gettext_lazy('Screening'), accessor='screening_statuses')

organization_name class-attribute instance-attribute

organization_name = Column()

Meta

Bases: Meta

model class-attribute instance-attribute
order_by class-attribute instance-attribute
order_by = ('-last_update')
template_name class-attribute instance-attribute
template_name = 'funds/tables/table.html'
row_attrs class-attribute instance-attribute
row_attrs = {'class': make_row_class, 'data-record-id': lambda record: id, 'data-archived': lambda record: is_archive}
attrs class-attribute instance-attribute
attrs = {'class': 'all-submissions-table'}
empty_text class-attribute instance-attribute
empty_text = gettext_lazy('No submissions available')
fields class-attribute instance-attribute
fields = ('title', 'phase', 'stage', 'fund', 'round', 'lead', 'submit_time', 'last_update', 'screening_status', 'reviews_stats', 'organization_name')
sequence class-attribute instance-attribute
sequence = fields + ('comments')

render_user

render_user(value)
Source code in hypha/apply/funds/tables.py
def render_user(self, value):
    return value.get_full_name()

render_phase

render_phase(value)
Source code in hypha/apply/funds/tables.py
def render_phase(self, value):
    return format_html("<span>{}</span>", value)

order_last_update

order_last_update(qs, desc)
Source code in hypha/apply/funds/tables.py
def order_last_update(self, qs, desc):
    update_order = getattr(F("last_update"), "desc" if desc else "asc")(
        nulls_last=True
    )

    qs = qs.order_by(update_order, "submit_time")
    return qs, True

get_column_class_names

get_column_class_names(classes_set, bound_column)
Source code in hypha/apply/funds/tables.py
def get_column_class_names(self, classes_set, bound_column):
    classes_set = super(SubmissionsTable, self).get_column_class_names(
        classes_set, bound_column
    )
    classes_set.add(bound_column.name)
    return classes_set

render_lead

render_lead(value)
Source code in hypha/apply/funds/tables.py
def render_lead(self, value):
    return format_html("<span>{}</span>", value)

render_screening_status

render_screening_status(value)
Source code in hypha/apply/funds/tables.py
def render_screening_status(self, value):
    try:
        status = value.get()
        classname = "status-yes" if status.yes else "status-no text-red-500"
        return format_html(
            f"<span class='font-medium text-xs {classname}'>{'👍' if status.yes else '👎'} {status.title}</span>"
        )
    except ScreeningStatus.DoesNotExist:
        return format_html(
            "<span class='text-xs text-fg-muted'>{}</span>", "Awaiting"
        )

AdminSubmissionsTable

Bases: BaseAdminSubmissionsTable

Adds admin only columns to the submissions table

title class-attribute instance-attribute

title = LinkColumn('funds:submissions:detail', text=render_title, args=[A('pk')], orderable=True, attrs={'td': {'class': 'js-title'}, 'a': {'data-tippy-content': lambda record: render_title(record), 'data-tippy-placement': 'top', 'class': "truncate inline-block w-[calc(100%-2rem)] after:content-[''] after:block"}})

submit_time class-attribute instance-attribute

submit_time = DateColumn(verbose_name=gettext_lazy('Submitted'))

phase class-attribute instance-attribute

phase = Column(verbose_name=gettext_lazy('Status'), order_by=('status'), attrs={'td': {'data-actions': render_actions, 'class': 'js-actions'}})

stage class-attribute instance-attribute

stage = Column(verbose_name=gettext_lazy('Type'), order_by=('status'))

fund class-attribute instance-attribute

fund = Column(verbose_name=gettext_lazy('Fund'), accessor='page')

comments class-attribute instance-attribute

comments = Column(accessor='comment_count', verbose_name=gettext_lazy('Comments'))

last_update class-attribute instance-attribute

last_update = DateColumn(accessor='last_update', verbose_name=gettext_lazy('Last updated'))

lead class-attribute instance-attribute

lead = Column(order_by=('lead__full_name'))

reviews_stats class-attribute instance-attribute

reviews_stats = TemplateColumn(template_name='funds/tables/column_reviews.html', verbose_name=mark_safe('Reviews<div>Comp. <span class="counts-separator">/</span> Assgn.</div>'), orderable=False)

screening_status class-attribute instance-attribute

screening_status = Column(verbose_name=gettext_lazy('Screening'), accessor='screening_statuses')

organization_name class-attribute instance-attribute

organization_name = Column()

selected class-attribute instance-attribute

selected = LabeledCheckboxColumn(accessor=A('pk'), attrs={'input': {'class': 'js-batch-select'}, 'th__input': {'class': 'js-batch-select-all'}})

Meta

Bases: Meta

model class-attribute instance-attribute
order_by class-attribute instance-attribute
order_by = ('-last_update')
template_name class-attribute instance-attribute
template_name = 'funds/tables/table.html'
row_attrs class-attribute instance-attribute
row_attrs = {'class': make_row_class, 'data-record-id': lambda record: id, 'data-archived': lambda record: is_archive}
attrs class-attribute instance-attribute
attrs = {'class': 'all-submissions-table'}
empty_text class-attribute instance-attribute
empty_text = gettext_lazy('No submissions available')
fields class-attribute instance-attribute
fields = ('selected', *fields)
sequence class-attribute instance-attribute
sequence = fields

render_user

render_user(value)
Source code in hypha/apply/funds/tables.py
def render_user(self, value):
    return value.get_full_name()

render_phase

render_phase(value)
Source code in hypha/apply/funds/tables.py
def render_phase(self, value):
    return format_html("<span>{}</span>", value)

order_last_update

order_last_update(qs, desc)
Source code in hypha/apply/funds/tables.py
def order_last_update(self, qs, desc):
    update_order = getattr(F("last_update"), "desc" if desc else "asc")(
        nulls_last=True
    )

    qs = qs.order_by(update_order, "submit_time")
    return qs, True

get_column_class_names

get_column_class_names(classes_set, bound_column)
Source code in hypha/apply/funds/tables.py
def get_column_class_names(self, classes_set, bound_column):
    classes_set = super(SubmissionsTable, self).get_column_class_names(
        classes_set, bound_column
    )
    classes_set.add(bound_column.name)
    return classes_set

render_lead

render_lead(value)
Source code in hypha/apply/funds/tables.py
def render_lead(self, value):
    return format_html("<span>{}</span>", value)

render_screening_status

render_screening_status(value)
Source code in hypha/apply/funds/tables.py
def render_screening_status(self, value):
    try:
        status = value.get()
        classname = "status-yes" if status.yes else "status-no text-red-500"
        return format_html(
            f"<span class='font-medium text-xs {classname}'>{'👍' if status.yes else '👎'} {status.title}</span>"
        )
    except ScreeningStatus.DoesNotExist:
        return format_html(
            "<span class='text-xs text-fg-muted'>{}</span>", "Awaiting"
        )

SummarySubmissionsTable

Bases: BaseAdminSubmissionsTable

title class-attribute instance-attribute

title = LinkColumn('funds:submissions:detail', text=render_title, args=[A('pk')], orderable=True, attrs={'td': {'class': 'js-title'}, 'a': {'data-tippy-content': lambda record: render_title(record), 'data-tippy-placement': 'top', 'class': "truncate inline-block w-[calc(100%-2rem)] after:content-[''] after:block"}})

submit_time class-attribute instance-attribute

submit_time = DateColumn(verbose_name=gettext_lazy('Submitted'))

phase class-attribute instance-attribute

phase = Column(verbose_name=gettext_lazy('Status'), order_by=('status'), attrs={'td': {'data-actions': render_actions, 'class': 'js-actions'}})

stage class-attribute instance-attribute

stage = Column(verbose_name=gettext_lazy('Type'), order_by=('status'))

fund class-attribute instance-attribute

fund = Column(verbose_name=gettext_lazy('Fund'), accessor='page')

comments class-attribute instance-attribute

comments = Column(accessor='comment_count', verbose_name=gettext_lazy('Comments'))

last_update class-attribute instance-attribute

last_update = DateColumn(accessor='last_update', verbose_name=gettext_lazy('Last updated'))

lead class-attribute instance-attribute

lead = Column(order_by=('lead__full_name'))

reviews_stats class-attribute instance-attribute

reviews_stats = TemplateColumn(template_name='funds/tables/column_reviews.html', verbose_name=mark_safe('Reviews<div>Comp. <span class="counts-separator">/</span> Assgn.</div>'), orderable=False)

screening_status class-attribute instance-attribute

screening_status = Column(verbose_name=gettext_lazy('Screening'), accessor='screening_statuses')

organization_name class-attribute instance-attribute

organization_name = Column()

Meta

Bases: Meta

model class-attribute instance-attribute
order_by class-attribute instance-attribute
order_by = ('-last_update')
fields class-attribute instance-attribute
fields = ('title', 'phase', 'stage', 'fund', 'round', 'lead', 'submit_time', 'last_update', 'screening_status', 'reviews_stats', 'organization_name')
sequence class-attribute instance-attribute
sequence = fields + ('comments')
template_name class-attribute instance-attribute
template_name = 'funds/tables/table.html'
row_attrs class-attribute instance-attribute
row_attrs = {'class': make_row_class, 'data-record-id': lambda record: id, 'data-archived': lambda record: is_archive}
attrs class-attribute instance-attribute
attrs = {'class': 'all-submissions-table'}
empty_text class-attribute instance-attribute
empty_text = gettext_lazy('No submissions available')
orderable class-attribute instance-attribute
orderable = False

render_user

render_user(value)
Source code in hypha/apply/funds/tables.py
def render_user(self, value):
    return value.get_full_name()

render_phase

render_phase(value)
Source code in hypha/apply/funds/tables.py
def render_phase(self, value):
    return format_html("<span>{}</span>", value)

order_last_update

order_last_update(qs, desc)
Source code in hypha/apply/funds/tables.py
def order_last_update(self, qs, desc):
    update_order = getattr(F("last_update"), "desc" if desc else "asc")(
        nulls_last=True
    )

    qs = qs.order_by(update_order, "submit_time")
    return qs, True

get_column_class_names

get_column_class_names(classes_set, bound_column)
Source code in hypha/apply/funds/tables.py
def get_column_class_names(self, classes_set, bound_column):
    classes_set = super(SubmissionsTable, self).get_column_class_names(
        classes_set, bound_column
    )
    classes_set.add(bound_column.name)
    return classes_set

render_lead

render_lead(value)
Source code in hypha/apply/funds/tables.py
def render_lead(self, value):
    return format_html("<span>{}</span>", value)

render_screening_status

render_screening_status(value)
Source code in hypha/apply/funds/tables.py
def render_screening_status(self, value):
    try:
        status = value.get()
        classname = "status-yes" if status.yes else "status-no text-red-500"
        return format_html(
            f"<span class='font-medium text-xs {classname}'>{'👍' if status.yes else '👎'} {status.title}</span>"
        )
    except ScreeningStatus.DoesNotExist:
        return format_html(
            "<span class='text-xs text-fg-muted'>{}</span>", "Awaiting"
        )

SummarySubmissionsTableWithRole

Bases: BaseAdminSubmissionsTable

Adds Role Assigned to the 'Waiting for My Review' table

title class-attribute instance-attribute

title = LinkColumn('funds:submissions:detail', text=render_title, args=[A('pk')], orderable=True, attrs={'td': {'class': 'js-title'}, 'a': {'data-tippy-content': lambda record: render_title(record), 'data-tippy-placement': 'top', 'class': "truncate inline-block w-[calc(100%-2rem)] after:content-[''] after:block"}})

submit_time class-attribute instance-attribute

submit_time = DateColumn(verbose_name=gettext_lazy('Submitted'))

phase class-attribute instance-attribute

phase = Column(verbose_name=gettext_lazy('Status'), order_by=('status'), attrs={'td': {'data-actions': render_actions, 'class': 'js-actions'}})

stage class-attribute instance-attribute

stage = Column(verbose_name=gettext_lazy('Type'), order_by=('status'))

fund class-attribute instance-attribute

fund = Column(verbose_name=gettext_lazy('Fund'), accessor='page')

comments class-attribute instance-attribute

comments = Column(accessor='comment_count', verbose_name=gettext_lazy('Comments'))

last_update class-attribute instance-attribute

last_update = DateColumn(accessor='last_update', verbose_name=gettext_lazy('Last updated'))

lead class-attribute instance-attribute

lead = Column(order_by=('lead__full_name'))

reviews_stats class-attribute instance-attribute

reviews_stats = TemplateColumn(template_name='funds/tables/column_reviews.html', verbose_name=mark_safe('Reviews<div>Comp. <span class="counts-separator">/</span> Assgn.</div>'), orderable=False)

screening_status class-attribute instance-attribute

screening_status = Column(verbose_name=gettext_lazy('Screening'), accessor='screening_statuses')

organization_name class-attribute instance-attribute

organization_name = Column()

role_icon class-attribute instance-attribute

role_icon = Column(verbose_name=gettext_lazy('Role'))

Meta

Bases: Meta

model class-attribute instance-attribute
order_by class-attribute instance-attribute
order_by = ('-last_update')
fields class-attribute instance-attribute
fields = ('title', 'phase', 'stage', 'fund', 'round', 'lead', 'submit_time', 'last_update', 'screening_status', 'reviews_stats', 'organization_name')
template_name class-attribute instance-attribute
template_name = 'funds/tables/table.html'
row_attrs class-attribute instance-attribute
row_attrs = {'class': make_row_class, 'data-record-id': lambda record: id, 'data-archived': lambda record: is_archive}
attrs class-attribute instance-attribute
attrs = {'class': 'all-submissions-table'}
empty_text class-attribute instance-attribute
empty_text = gettext_lazy('No submissions available')
sequence class-attribute instance-attribute
sequence = fields + ('role_icon', 'comments')
orderable class-attribute instance-attribute
orderable = False

render_user

render_user(value)
Source code in hypha/apply/funds/tables.py
def render_user(self, value):
    return value.get_full_name()

render_phase

render_phase(value)
Source code in hypha/apply/funds/tables.py
def render_phase(self, value):
    return format_html("<span>{}</span>", value)

order_last_update

order_last_update(qs, desc)
Source code in hypha/apply/funds/tables.py
def order_last_update(self, qs, desc):
    update_order = getattr(F("last_update"), "desc" if desc else "asc")(
        nulls_last=True
    )

    qs = qs.order_by(update_order, "submit_time")
    return qs, True

get_column_class_names

get_column_class_names(classes_set, bound_column)
Source code in hypha/apply/funds/tables.py
def get_column_class_names(self, classes_set, bound_column):
    classes_set = super(SubmissionsTable, self).get_column_class_names(
        classes_set, bound_column
    )
    classes_set.add(bound_column.name)
    return classes_set

render_lead

render_lead(value)
Source code in hypha/apply/funds/tables.py
def render_lead(self, value):
    return format_html("<span>{}</span>", value)

render_screening_status

render_screening_status(value)
Source code in hypha/apply/funds/tables.py
def render_screening_status(self, value):
    try:
        status = value.get()
        classname = "status-yes" if status.yes else "status-no text-red-500"
        return format_html(
            f"<span class='font-medium text-xs {classname}'>{'👍' if status.yes else '👎'} {status.title}</span>"
        )
    except ScreeningStatus.DoesNotExist:
        return format_html(
            "<span class='text-xs text-fg-muted'>{}</span>", "Awaiting"
        )

render_role_icon

render_role_icon(value)
Source code in hypha/apply/funds/tables.py
def render_role_icon(self, value):
    if value:
        image = CustomImage.objects.filter(id=value).first()
        if image:
            filter_spec = "fill-20x20"
            return generate_image_tag(image, filter_spec)

    return ""

Select2CheckboxWidgetMixin

Select2CheckboxWidgetMixin(*args, **kwargs)

Bases: Filter

Source code in hypha/apply/funds/tables.py
def __init__(self, *args, **kwargs):
    label = kwargs.get("label")
    kwargs.setdefault(
        "widget", Select2MultiCheckboxesWidget(attrs={"data-placeholder": label})
    )
    super().__init__(*args, **kwargs)

Select2MultipleChoiceFilter

Select2MultipleChoiceFilter(*args, **kwargs)

Bases: Select2CheckboxWidgetMixin, MultipleChoiceFilter

Source code in hypha/apply/funds/tables.py
def __init__(self, *args, **kwargs):
    label = kwargs.get("label")
    kwargs.setdefault(
        "widget", Select2MultiCheckboxesWidget(attrs={"data-placeholder": label})
    )
    super().__init__(*args, **kwargs)

Select2ModelMultipleChoiceFilter

Select2ModelMultipleChoiceFilter(*args, **kwargs)

Bases: Select2MultipleChoiceFilter, ModelMultipleChoiceFilter

Source code in hypha/apply/funds/tables.py
def __init__(self, *args, **kwargs):
    label = kwargs.get("label")
    kwargs.setdefault(
        "widget", Select2MultiCheckboxesWidget(attrs={"data-placeholder": label})
    )
    super().__init__(*args, **kwargs)

StatusMultipleChoiceFilter

StatusMultipleChoiceFilter(limit_to, *args, **kwargs)

Bases: Select2MultipleChoiceFilter

Source code in hypha/apply/funds/tables.py
def __init__(self, limit_to, *args, **kwargs):
    choices = [
        (slugify(name), name)
        for name, statuses in STATUSES.items()
        if not limit_to or self.has_any(statuses, limit_to)
    ]
    self.status_map = {
        slugify(name): list(status) for name, status in STATUSES.items()
    }
    super().__init__(
        *args,
        field_name="status",
        choices=choices,
        label=_("Statuses"),
        **kwargs,
    )

status_map instance-attribute

status_map = {slugify(name): list(status)for (name, status) in items()}

has_any

has_any(first, second)
Source code in hypha/apply/funds/tables.py
def has_any(self, first, second):
    return any(item in second for item in first)

get_filter_predicate

get_filter_predicate(v)
Source code in hypha/apply/funds/tables.py
def get_filter_predicate(self, v):
    return {f"{ self.field_name }__in": self.status_map.get(v, [])}

SubmissionFilter

SubmissionFilter(*args, exclude=None, limit_statuses=None, **kwargs)

Bases: FilterSet

Source code in hypha/apply/funds/tables.py
def __init__(self, *args, exclude=None, limit_statuses=None, **kwargs):
    if exclude is None:
        exclude = []

    qs = kwargs.get("queryset")

    archived = kwargs.pop("archived") if "archived" in kwargs.keys() else None
    if archived is not None:
        archived = int(archived) if archived else None

    super().__init__(*args, **kwargs)

    reviewers_qs = get_reviewers_from_dataset(
        dataset=qs.exclude(reviewers__isnull=True)
    )
    if archived is not None and archived == 0:
        reviewers_qs = get_reviewers_from_dataset(
            dataset=qs.filter(is_archive=archived).exclude(reviewers__isnull=True)
        )
        qs = qs.filter(is_archive=archived)

    self.filters["fund"].queryset = get_used_funds_from_dataset(dataset=qs)
    self.filters["round"].queryset = get_used_rounds_from_dataset(dataset=qs)
    self.filters["lead"].queryset = get_round_leads_from_dataset(dataset=qs)
    self.filters[
        "screening_statuses"
    ].queryset = get_screening_statuses_from_dataset(dataset=qs)
    self.filters["reviewers"].queryset = reviewers_qs
    self.filters["meta_terms"].queryset = get_meta_terms_from_dataset(dataset=qs)

    self.filters["status"] = StatusMultipleChoiceFilter(limit_to=limit_statuses)
    self.filters["category_options"].extra["choices"] = [
        (option.id, option.value)
        for option in Option.objects.filter(category__filter_on_dashboard=True)
    ]
    self.filters = {
        field: filter
        for field, filter in self.filters.items()
        if field not in exclude
    }

fund class-attribute instance-attribute

fund = Select2ModelMultipleChoiceFilter(field_name='page', queryset=get_used_funds, label=gettext_lazy('Funds'))

round class-attribute instance-attribute

round = Select2ModelMultipleChoiceFilter(queryset=get_used_rounds, label=gettext_lazy('Rounds'))

lead class-attribute instance-attribute

lead = Select2ModelMultipleChoiceFilter(queryset=get_round_leads, label=gettext_lazy('Leads'))

screening_statuses class-attribute instance-attribute

screening_statuses = Select2ModelMultipleChoiceFilter(queryset=get_screening_statuses, label=gettext_lazy('Screening'), null_label=gettext_lazy('No Status'))

reviewers class-attribute instance-attribute

reviewers = Select2ModelMultipleChoiceFilter(queryset=get_all_reviewers, label=gettext_lazy('Reviewers'))

category_options class-attribute instance-attribute

category_options = Select2MultipleChoiceFilter(choices=[], label=gettext_lazy('Category'), method='filter_category_options')

meta_terms class-attribute instance-attribute

meta_terms = Select2ModelMultipleChoiceFilter(queryset=get_meta_terms, label=gettext_lazy('Terms'))

filters instance-attribute

filters = {field: _zDBWlfor (field, filter) in items() if field not in exclude}

Meta

model class-attribute instance-attribute
fields class-attribute instance-attribute
fields = ('status', 'fund', 'round')

filter_category_options

filter_category_options(queryset, name, value)

Filter submissions based on the category options selected.

In order to do that we need to first get all the category fields used in the submission.

And then use those category fields to filter submissions with their form_data.

Source code in hypha/apply/funds/tables.py
def filter_category_options(self, queryset, name, value):
    """
    Filter submissions based on the category options selected.

    In order to do that we need to first get all the category fields used in the submission.

    And then use those category fields to filter submissions with their form_data.
    """
    query = Q()
    submission_data = queryset.values("form_fields", "form_data").distinct()
    for submission in submission_data:
        for field in submission["form_fields"]:
            if isinstance(field.block, CategoryQuestionBlock):
                try:
                    category_options = category_ids = submission["form_data"][
                        field.id
                    ]
                except KeyError:
                    include_in_filter = False
                else:
                    if isinstance(category_options, str):
                        category_options = [category_options]
                    include_in_filter = set(category_options) & set(value)
                # Check if filter options has any value in category options
                # If yes then those submissions should be filtered in the list
                if include_in_filter:
                    kwargs = {
                        "{0}__{1}".format("form_data", field.id): category_ids
                    }
                    query |= Q(**kwargs)
    return queryset.filter(query)

SubmissionFilterAndSearch

SubmissionFilterAndSearch(*args, exclude=None, limit_statuses=None, **kwargs)

Bases: SubmissionFilter

Source code in hypha/apply/funds/tables.py
def __init__(self, *args, exclude=None, limit_statuses=None, **kwargs):
    if exclude is None:
        exclude = []

    qs = kwargs.get("queryset")

    archived = kwargs.pop("archived") if "archived" in kwargs.keys() else None
    if archived is not None:
        archived = int(archived) if archived else None

    super().__init__(*args, **kwargs)

    reviewers_qs = get_reviewers_from_dataset(
        dataset=qs.exclude(reviewers__isnull=True)
    )
    if archived is not None and archived == 0:
        reviewers_qs = get_reviewers_from_dataset(
            dataset=qs.filter(is_archive=archived).exclude(reviewers__isnull=True)
        )
        qs = qs.filter(is_archive=archived)

    self.filters["fund"].queryset = get_used_funds_from_dataset(dataset=qs)
    self.filters["round"].queryset = get_used_rounds_from_dataset(dataset=qs)
    self.filters["lead"].queryset = get_round_leads_from_dataset(dataset=qs)
    self.filters[
        "screening_statuses"
    ].queryset = get_screening_statuses_from_dataset(dataset=qs)
    self.filters["reviewers"].queryset = reviewers_qs
    self.filters["meta_terms"].queryset = get_meta_terms_from_dataset(dataset=qs)

    self.filters["status"] = StatusMultipleChoiceFilter(limit_to=limit_statuses)
    self.filters["category_options"].extra["choices"] = [
        (option.id, option.value)
        for option in Option.objects.filter(category__filter_on_dashboard=True)
    ]
    self.filters = {
        field: filter
        for field, filter in self.filters.items()
        if field not in exclude
    }

fund class-attribute instance-attribute

fund = Select2ModelMultipleChoiceFilter(field_name='page', queryset=get_used_funds, label=gettext_lazy('Funds'))

round class-attribute instance-attribute

round = Select2ModelMultipleChoiceFilter(queryset=get_used_rounds, label=gettext_lazy('Rounds'))

lead class-attribute instance-attribute

lead = Select2ModelMultipleChoiceFilter(queryset=get_round_leads, label=gettext_lazy('Leads'))

screening_statuses class-attribute instance-attribute

screening_statuses = Select2ModelMultipleChoiceFilter(queryset=get_screening_statuses, label=gettext_lazy('Screening'), null_label=gettext_lazy('No Status'))

reviewers class-attribute instance-attribute

reviewers = Select2ModelMultipleChoiceFilter(queryset=get_all_reviewers, label=gettext_lazy('Reviewers'))

category_options class-attribute instance-attribute

category_options = Select2MultipleChoiceFilter(choices=[], label=gettext_lazy('Category'), method='filter_category_options')

meta_terms class-attribute instance-attribute

meta_terms = Select2ModelMultipleChoiceFilter(queryset=get_meta_terms, label=gettext_lazy('Terms'))

filters instance-attribute

filters = {field: _TFBrNfor (field, filter) in items() if field not in exclude}

query class-attribute instance-attribute

query = CharFilter(method='search_data_and_id', widget=HiddenInput)

archived class-attribute instance-attribute

archived = BooleanFilter(field_name='is_archive', widget=HiddenInput, method='filter_archived')

Meta

model class-attribute instance-attribute
fields class-attribute instance-attribute
fields = ('status', 'fund', 'round')

filter_category_options

filter_category_options(queryset, name, value)

Filter submissions based on the category options selected.

In order to do that we need to first get all the category fields used in the submission.

And then use those category fields to filter submissions with their form_data.

Source code in hypha/apply/funds/tables.py
def filter_category_options(self, queryset, name, value):
    """
    Filter submissions based on the category options selected.

    In order to do that we need to first get all the category fields used in the submission.

    And then use those category fields to filter submissions with their form_data.
    """
    query = Q()
    submission_data = queryset.values("form_fields", "form_data").distinct()
    for submission in submission_data:
        for field in submission["form_fields"]:
            if isinstance(field.block, CategoryQuestionBlock):
                try:
                    category_options = category_ids = submission["form_data"][
                        field.id
                    ]
                except KeyError:
                    include_in_filter = False
                else:
                    if isinstance(category_options, str):
                        category_options = [category_options]
                    include_in_filter = set(category_options) & set(value)
                # Check if filter options has any value in category options
                # If yes then those submissions should be filtered in the list
                if include_in_filter:
                    kwargs = {
                        "{0}__{1}".format("form_data", field.id): category_ids
                    }
                    query |= Q(**kwargs)
    return queryset.filter(query)

search_data_and_id

search_data_and_id(queryset, name, value)
Source code in hypha/apply/funds/tables.py
def search_data_and_id(self, queryset, name, value):
    possible_id = re.search("^#(\\d+)$", value.strip())
    if possible_id:
        return queryset.filter(id=possible_id.groups()[0])
    return queryset.filter(search_data__icontains=value)

filter_archived

filter_archived(queryset, name, value)
Source code in hypha/apply/funds/tables.py
def filter_archived(self, queryset, name, value):
    if not value:
        # if value is 0 or None
        queryset = queryset.exclude(is_archive=True)
    return queryset

SubmissionDashboardFilter

SubmissionDashboardFilter(*args, exclude=None, limit_statuses=None, **kwargs)

Bases: FilterSet

Source code in hypha/apply/funds/tables.py
def __init__(self, *args, exclude=None, limit_statuses=None, **kwargs):
    if exclude is None:
        exclude = []
    super().__init__(*args, **kwargs)

    self.filters = {
        field: filter
        for field, filter in self.filters.items()
        if field not in exclude
    }

round class-attribute instance-attribute

round = Select2ModelMultipleChoiceFilter(queryset=get_used_rounds, label=gettext_lazy('Rounds'))

fund class-attribute instance-attribute

fund = Select2ModelMultipleChoiceFilter(field_name='page', queryset=get_used_funds, label=gettext_lazy('Funds'))

filters instance-attribute

filters = {field: _PpJ0Mfor (field, filter) in items() if field not in exclude}

Meta

model class-attribute instance-attribute
fields class-attribute instance-attribute
fields = ('fund', 'round')

SubmissionReviewerFilterAndSearch

SubmissionReviewerFilterAndSearch(*args, exclude=None, limit_statuses=None, **kwargs)

Bases: SubmissionDashboardFilter

Source code in hypha/apply/funds/tables.py
def __init__(self, *args, exclude=None, limit_statuses=None, **kwargs):
    if exclude is None:
        exclude = []
    super().__init__(*args, **kwargs)

    self.filters = {
        field: filter
        for field, filter in self.filters.items()
        if field not in exclude
    }

round class-attribute instance-attribute

round = Select2ModelMultipleChoiceFilter(queryset=get_used_rounds, label=gettext_lazy('Rounds'))

fund class-attribute instance-attribute

fund = Select2ModelMultipleChoiceFilter(field_name='page', queryset=get_used_funds, label=gettext_lazy('Funds'))

filters instance-attribute

filters = {field: _yMCkvfor (field, filter) in items() if field not in exclude}

query class-attribute instance-attribute

query = CharFilter(field_name='search_data', lookup_expr='icontains', widget=HiddenInput)

Meta

model class-attribute instance-attribute
fields class-attribute instance-attribute
fields = ('fund', 'round')

RoundsTable

Bases: Table

title class-attribute instance-attribute

title = Column(linkify=lambda record: get_absolute_url(), orderable=True)

fund class-attribute instance-attribute

fund = Column(accessor=A('specific__fund'))

lead class-attribute instance-attribute

lead = Column()

start_date class-attribute instance-attribute

start_date = Column()

end_date class-attribute instance-attribute

end_date = Column()

progress class-attribute instance-attribute

progress = Column(verbose_name=gettext_lazy('Determined'))

Meta

fields class-attribute instance-attribute
fields = ('title', 'fund', 'lead', 'start_date', 'end_date', 'progress')
attrs class-attribute instance-attribute
attrs = {'class': 'responsive-table'}

render_lead

render_lead(value)
Source code in hypha/apply/funds/tables.py
def render_lead(self, value):
    return format_html("<span>{}</span>", value)

render_progress

render_progress(record)
Source code in hypha/apply/funds/tables.py
def render_progress(self, record):
    return f"{record.progress}%"

order_start_date

order_start_date(qs, desc)
Source code in hypha/apply/funds/tables.py
def order_start_date(self, qs, desc):
    return qs.order_by(self._field_order("start_date", desc)), True

order_end_date

order_end_date(qs, desc)
Source code in hypha/apply/funds/tables.py
def order_end_date(self, qs, desc):
    return qs.order_by(self._field_order("end_date", desc)), True

order_fund

order_fund(qs, desc)
Source code in hypha/apply/funds/tables.py
def order_fund(self, qs, desc):
    return qs.order_by(self._field_order("fund", desc)), True

order_progress

order_progress(qs, desc)
Source code in hypha/apply/funds/tables.py
def order_progress(self, qs, desc):
    return qs.order_by(self._field_order("progress", desc)), True

get_column_class_names

get_column_class_names(classes_set, bound_column)
Source code in hypha/apply/funds/tables.py
def get_column_class_names(self, classes_set, bound_column):
    classes_set = super(RoundsTable, self).get_column_class_names(
        classes_set, bound_column
    )
    classes_set.add(bound_column.name)
    return classes_set

ActiveRoundFilter

ActiveRoundFilter(*args, **kwargs)

Bases: Select2MultipleChoiceFilter

Source code in hypha/apply/funds/tables.py
def __init__(self, *args, **kwargs):
    super().__init__(
        self,
        *args,
        choices=[("active", "Active"), ("inactive", "Inactive")],
        **kwargs,
    )

filter

filter(qs, value)
Source code in hypha/apply/funds/tables.py
def filter(self, qs, value):
    if value is None or len(value) != 1:
        return qs

    value = value[0]
    if value == "active":
        return qs.active()
    else:
        return qs.inactive()

OpenRoundFilter

OpenRoundFilter(*args, **kwargs)

Bases: Select2MultipleChoiceFilter

Source code in hypha/apply/funds/tables.py
def __init__(self, *args, **kwargs):
    super().__init__(
        self,
        *args,
        choices=[("open", "Open"), ("closed", "Closed"), ("new", "Not Started")],
        **kwargs,
    )

filter

filter(qs, value)
Source code in hypha/apply/funds/tables.py
def filter(self, qs, value):
    if value is None or len(value) != 1:
        return qs

    value = value[0]
    if value == "closed":
        return qs.closed()
    if value == "new":
        return qs.new()

    return qs.open()

RoundsFilter

Bases: FilterSet

fund class-attribute instance-attribute

fund = Select2ModelMultipleChoiceFilter(queryset=get_used_funds, label=gettext_lazy('Funds'))

lead class-attribute instance-attribute

lead = Select2ModelMultipleChoiceFilter(queryset=get_round_leads, label=gettext_lazy('Leads'))

active class-attribute instance-attribute

active = ActiveRoundFilter(label=gettext_lazy('Active'))

round_state class-attribute instance-attribute

round_state = OpenRoundFilter(label=gettext_lazy('Open'))

ReviewerLeaderboardFilterForm

Bases: ModelForm

Form to "clean" a list of User objects to their PKs.

The Reviewer Leaderboard table is a list of User objects, however we also want the ability to filter down to N Users (reviewers). Django filter is converting the selected PKs to User objects, however we can't filter a User QuerySet with User objects. So this form converts back to a list of User PKs using the clean_reviewer method.

Meta

fields class-attribute instance-attribute
fields = ['id']
model class-attribute instance-attribute
model = User

clean_reviewer

clean_reviewer()
Source code in hypha/apply/funds/tables.py
def clean_reviewer(self):
    return [u.id for u in self.cleaned_data["reviewer"]]

ReviewerLeaderboardFilter

Bases: FilterSet

query class-attribute instance-attribute

query = CharFilter(field_name='full_name', lookup_expr='icontains', widget=HiddenInput)

reviewer class-attribute instance-attribute

reviewer = Select2ModelMultipleChoiceFilter(field_name='pk', label=gettext_lazy('Reviewers'), queryset=get_all_reviewers)

funds class-attribute instance-attribute

funds = Select2ModelMultipleChoiceFilter(field_name='submission__page', label=gettext_lazy('Funds'), queryset=get_used_funds)

rounds class-attribute instance-attribute

rounds = Select2ModelMultipleChoiceFilter(field_name='submission__round', label=gettext_lazy('Rounds'), queryset=get_used_rounds)

Meta

fields class-attribute instance-attribute
fields = ['reviewer', 'funds', 'rounds']
form class-attribute instance-attribute
model class-attribute instance-attribute
model = User

ReviewerLeaderboardTable

Bases: Table

full_name class-attribute instance-attribute

full_name = LinkColumn('funds:submissions:reviewer_leaderboard_detail', args=[A('pk')], orderable=True, verbose_name=gettext_lazy('Reviewer'), attrs={'td': {'class': 'title'}})

Meta

model class-attribute instance-attribute
model = User
fields class-attribute instance-attribute
fields = ['full_name', 'ninety_days', 'this_year', 'last_year', 'total']
order_by class-attribute instance-attribute
order_by = ('-ninety_days')
attrs class-attribute instance-attribute
attrs = {'class': 'all-reviews-table'}
empty_text class-attribute instance-attribute
empty_text = gettext_lazy('No reviews available')

ReviewerLeaderboardDetailTable

Bases: Table

title class-attribute instance-attribute

title = LinkColumn('funds:submissions:reviews:review', text=render_title, args=[A('submission_id'), A('pk')], orderable=True, verbose_name=gettext_lazy('Submission'), attrs={'td': {'class': 'js-title'}, 'a': {'data-tippy-content': lambda record: render_title(record), 'data-tippy-placement': 'top', 'class': 'truncate inline-block w-[calc(100%-2rem)] after:content-[] after:block'}})

Meta

model class-attribute instance-attribute
model = Review
fields class-attribute instance-attribute
fields = ['title', 'recommendation', 'created_at']
order_by class-attribute instance-attribute
order_by = ('-created_at')
attrs class-attribute instance-attribute
attrs = {'class': 'all-reviews-table'}
empty_text class-attribute instance-attribute
empty_text = gettext_lazy('No reviews available')

StaffAssignmentsTable

Bases: Table

full_name class-attribute instance-attribute

full_name = Column(linkify=render_reviewer_link, orderable=True, verbose_name=gettext_lazy('Staff'), attrs={'td': {'class': 'title'}})

Meta

model class-attribute instance-attribute
model = User
fields class-attribute instance-attribute
fields = ['full_name']
attrs class-attribute instance-attribute
attrs = {'class': 'all-reviews-table'}
empty_text class-attribute instance-attribute
empty_text = gettext_lazy('No staff available')

review_filter_for_user

review_filter_for_user(user)
Source code in hypha/apply/funds/tables.py
def review_filter_for_user(user):
    review_states = set(get_review_active_statuses(user))
    statuses = [name for name, status in STATUSES.items() if review_states & status]
    return [slugify(status) for status in statuses]

make_row_class

make_row_class(record)
Source code in hypha/apply/funds/tables.py
def make_row_class(record):
    css_class = (
        "submission-meta__row" if record.next else "all-submissions-table__parent"
    )
    css_class += "" if record.active else " is-inactive"
    return css_class

render_actions

render_actions(table, record)
Source code in hypha/apply/funds/tables.py
def render_actions(table, record):
    user = table.context["user"]
    actions = record.get_actions_for_user(user)
    return json.dumps([slugify(action) for _, action in actions])

render_title

render_title(record)
Source code in hypha/apply/funds/tables.py
def render_title(record):
    try:
        title = record.title_text_display
    except AttributeError:
        title = record.submission.title_text_display
    return title
render_reviewer_link(record)
Source code in hypha/apply/funds/tables.py
def render_reviewer_link(record):
    return f"{reverse('funds:submissions:list')}?reviewers={record.id}"

get_used_rounds

get_used_rounds(request)
Source code in hypha/apply/funds/tables.py
def get_used_rounds(request):
    return Round.objects.filter(submissions__isnull=False).distinct()

get_used_rounds_from_dataset

get_used_rounds_from_dataset(dataset)
Source code in hypha/apply/funds/tables.py
def get_used_rounds_from_dataset(dataset):
    return Round.objects.filter(id__in=dataset.values("round")).distinct()

get_used_funds

get_used_funds(request)
Source code in hypha/apply/funds/tables.py
def get_used_funds(request):
    # Use page to pick up on both Labs and Funds
    return Page.objects.filter(applicationsubmission__isnull=False).distinct()

get_used_funds_from_dataset

get_used_funds_from_dataset(dataset)
Source code in hypha/apply/funds/tables.py
def get_used_funds_from_dataset(dataset):
    return Page.objects.filter(id__in=dataset.values("page")).distinct()

get_round_leads

get_round_leads(request)
Source code in hypha/apply/funds/tables.py
def get_round_leads(request):
    return User.objects.filter(submission_lead__isnull=False).distinct()

get_round_leads_from_dataset

get_round_leads_from_dataset(dataset)
Source code in hypha/apply/funds/tables.py
def get_round_leads_from_dataset(dataset):
    return User.objects.filter(id__in=dataset.values("lead")).distinct()

get_reviewers_from_dataset

get_reviewers_from_dataset(dataset)

All assigned reviewers, not including Staff and Admin because we want a list of reviewers only

Source code in hypha/apply/funds/tables.py
def get_reviewers_from_dataset(dataset):
    """All assigned reviewers, not including Staff and Admin because we want a list of reviewers only"""
    return User.objects.filter(id__in=dataset.values("reviewers")).distinct()

get_screening_statuses

get_screening_statuses(request)
Source code in hypha/apply/funds/tables.py
def get_screening_statuses(request):
    return ScreeningStatus.objects.filter(
        id__in=ApplicationSubmission.objects.all()
        .values("screening_statuses__id")
        .distinct("screening_statuses__id")
    )

get_screening_statuses_from_dataset

get_screening_statuses_from_dataset(dataset)
Source code in hypha/apply/funds/tables.py
def get_screening_statuses_from_dataset(dataset):
    return ScreeningStatus.objects.filter(
        id__in=dataset.values("screening_statuses__id")
    ).distinct()

get_meta_terms

get_meta_terms(request)
Source code in hypha/apply/funds/tables.py
def get_meta_terms(request):
    return MetaTerm.objects.filter(
        filter_on_dashboard=True,
        id__in=ApplicationSubmission.objects.all()
        .values("meta_terms__id")
        .distinct("meta_terms__id"),
    )

get_meta_terms_from_dataset

get_meta_terms_from_dataset(dataset)
Source code in hypha/apply/funds/tables.py
def get_meta_terms_from_dataset(dataset):
    return MetaTerm.objects.filter(
        filter_on_dashboard=True, id__in=dataset.values("meta_terms__id")
    ).distinct()