Skip to content

tables

main.tables ¤

Tables module for the main app.

Classes¤

LearningResourceTable ¤

Bases: Table

Table class for the LearningResources model.

Classes¤
Meta ¤

Meta options for the LearningResourcesTable.

Methods:¤
render_language(value) ¤

Render the language field as a badge.

Source code in main/tables.py
53
54
55
56
57
def render_language(self, value: str) -> SafeString:
    """Render the language field as a badge."""
    return mark_safe(
        " ".join(format_html(badge_html, val.strip()) for val in value.split(","))
    )
render_name(value, record) ¤

Include the URL in the name.

Source code in main/tables.py
49
50
51
def render_name(self, value: str, record: LearningResource) -> SafeString:
    """Include the URL in the name."""
    return format_html(external_link_html, record.url, "fs-lg", value)
render_provider(value, record) ¤

Include the URL in the provider name.

Source code in main/tables.py
59
60
61
62
63
64
def render_provider(self, value: str, record: LearningResource) -> SafeString:
    """Include the URL in the provider name."""
    if record.provider is None or not record.provider.url:
        return mark_safe(value)

    return format_html(external_link_html, record.provider.url, "", value)
render_skill_set(value) ¤

Include the relevant skills as button links.

Source code in main/tables.py
66
67
68
def render_skill_set(self, value: "ManyRelatedManager[Skill]") -> SafeString:
    """Include the relevant skills as button links."""
    return _render_skills(value.all())

ToolLanguageMethodologyTable ¤

Bases: Table

Table class for the ToolLanguageMethodology model.

Classes¤
Meta ¤

Meta options for the ToolLanguageMethodologyTable.

Methods:¤
render_kind(value) ¤

Render the kind field as a badge.

Source code in main/tables.py
87
88
89
def render_kind(self, value: str) -> SafeString:
    """Render the kind field as a badge."""
    return format_html(badge_html, value)
render_name(value, record) ¤

Include the URL in the name.

Source code in main/tables.py
83
84
85
def render_name(self, value: str, record: ToolLanguageMethodology) -> SafeString:
    """Include the URL in the name."""
    return format_html(external_link_html, record.url, "fs-lg", value)
render_skill_set(value) ¤

Include the relevant skills as button links.

Source code in main/tables.py
91
92
93
def render_skill_set(self, value: "ManyRelatedManager[Skill]") -> SafeString:
    """Include the relevant skills as button links."""
    return _render_skills(value.all())