The devilry_core_tags template library

devilry.apps.core.templatetags.devilry_core_tags.devilry_isoformat_datetime(datetimeobject)

Isoformat the given datetimeobject as YYYY-MM-DD hh:mm.

devilry.apps.core.templatetags.devilry_core_tags.devilry_single_candidate_long_displayname(assignment, candidate, devilryrole)

Returns the candidate wrapped in HTML formatting tags perfect for showing the user inline in a verbose manner.

Handles anonymization based on assignment.anonymizationmode and devilryrole.

Parameters:
devilry.apps.core.templatetags.devilry_core_tags.devilry_single_candidate_short_displayname(assignment, candidate, devilryrole)

Returns the candidate wrapped in HTML formatting tags perfect for showing the user inline in a non-verbose manner.

Handles anonymization based on assignment.anonymizationmode and devilryrole.

Parameters:
devilry.apps.core.templatetags.devilry_core_tags.devilry_single_examiner_long_displayname(assignment, examiner, devilryrole)

Returns the examiner wrapped in HTML formatting tags perfect for showing the user inline in a verbose manner.

Handles anonymization based on assignment.anonymizationmode and devilryrole.

Parameters:
devilry.apps.core.templatetags.devilry_core_tags.devilry_single_examiner_long_displayname_plain(assignment, examiner, devilryrole)

Same as devilry_single_examiner_long_displayname() but returns the examiner without styling.

devilry.apps.core.templatetags.devilry_core_tags.devilry_single_examiner_short_displayname(assignment, examiner, devilryrole)

Returns the examiner wrapped in HTML formatting tags perfect for showing the user inline in a non-verbose manner.

Handles anonymization based on assignment.anonymizationmode and devilryrole.

Parameters:
devilry.apps.core.templatetags.devilry_core_tags.devilry_multiple_candidates_long_displayname(assignment, candidates, devilryrole)

Returns the candidates wrapped in HTML formatting tags perfect for showing the candidates inline in a verbose manner.

Typically used for showing all the candidates in an devilry.apps.core.models_group.AssignmentGroup.

Handles anonymization based on assignment.anonymizationmode and devilryrole.

Parameters:
devilry.apps.core.templatetags.devilry_core_tags.devilry_multiple_candidates_short_displayname(assignment, candidates, devilryrole)

Returns the candidates wrapped in HTML formatting tags perfect for showing the candidates inline in a non-verbose manner.

Typically used for showing all the candidates in an devilry.apps.core.models_group.AssignmentGroup.

Handles anonymization based on assignment.anonymizationmode and devilryrole.

Parameters:
devilry.apps.core.templatetags.devilry_core_tags.devilry_multiple_examiners_long_displayname(assignment, examiners, devilryrole)

Returns the examiners wrapped in HTML formatting tags perfect for showing the examiners inline in a verbose manner.

Typically used for showing all the examiners in an devilry.apps.core.models_group.AssignmentGroup.

Handles anonymization based on assignment.anonymizationmode and devilryrole.

Parameters:
devilry.apps.core.templatetags.devilry_core_tags.devilry_multiple_examiners_short_displayname(assignment, examiners, devilryrole)

Returns the examiners wrapped in HTML formatting tags perfect for showing the examiners inline in a non-verbose manner.

Typically used for showing all the examiners in an devilry.apps.core.models_group.AssignmentGroup.

Handles anonymization based on assignment.anonymizationmode and devilryrole.

Parameters:
devilry.apps.core.templatetags.devilry_core_tags.devilry_groupstatus(group)

Get the status for the given AssignmentGroup.

The output is one of the following texts wrapped in some <span> elements with appropriate css classes:

  • "waiting for feedback"

  • "waiting for deliveries"

  • "corrected"

Note

We normally do not show the corrected status, but instead show the grade using devilry_grade_full(), at least in listings and other places where space is premium.

Assumes the AssignmentGroup queryset is annotated with:

  • annotate_with_is_waiting_for_feedback()

  • annotate_with_is_waiting_for_deliveries()

  • annotate_with_is_corrected()

Parameters:

group – A An devilry.apps.core.models.AssignmentGroup object.

devilry.apps.core.templatetags.devilry_core_tags.devilry_grade_short(assignment, points)

Renders a grade as in its shortest form - no information about passed or failed, only the grade text (E.g.: “passed”, “8/10”, “A”).

Parameters:
devilry.apps.core.templatetags.devilry_core_tags.devilry_grade_full(assignment, points, devilryrole)

Renders a grade as in its long form - including information about passed or failed. Examples:

"passed"
"8/10 (passed)"
"F (failed)"

If the students_can_see_points attribute of the assignment is set to True, students are allowed to see the points behind a grade, so we include the points. Examples:

"passed (10/10)"
"failed (0/10)"
"8/10 (passed)"
"F (failed - 10/100)"
"A (passed - 97/100)"
Parameters:
  • assignment – An devilry.apps.core.models.Assignment object.

  • points (int) – The points to render the grade for.

  • devilryrole (str) – Must be one of the choices documented in devilry.apps.core.models.Assignment.examiners_must_be_anonymized_for_devilryrole().

devilry.apps.core.templatetags.devilry_core_tags.devilry_grade_full_plain(assignment, points, devilryrole)

Renders a grade as in its long form - including information about passed or failed without styling.

devilry.apps.core.templatetags.devilry_core_tags.devilry_comment_summary(group)

Renders a comment summary for the given AssignmentGroup.

Assumes that the AssignmentGroup has been annotated with:

  • annotate_with_number_of_private_groupcomments_from_user().

  • annotate_with_number_of_private_imageannotationcomments_from_user().

Parameters:

group – An devilry.apps.core.models.AssignmentGroup object annotated as explained above.

devilry.apps.core.templatetags.devilry_core_tags.devilry_relatedexaminers_on_period_tag(period_tag)

Renders the devilry.apps.core.models.relateduser.RelatedExaminer in a comma separated format if there are any examiners, else it renders NO EXAMINERS.

Parameters:

period_tag – a PeriodTag instance.

devilry.apps.core.templatetags.devilry_core_tags.devilry_relatedstudents_on_period_tag(period_tag)

Renders the devilry.apps.core.models.relateduser.RelatedStudent in a comma separated format if there are any students, else it renders NO STUDENTS.

Parameters:

period_tag – a PeriodTag object.

devilry.apps.core.templatetags.devilry_core_tags.devilry_relatedusers_on_period_tag(period_tag)

Renders the devilry.apps.core.models.RelatedExaminer and devilry.apps.core.models.RelatedStudent comma separated.

Uses tags devilry_relatedexaminers_on_period_tag() and devilry_relatedstudents_on_period_tag().

Parameters:

period_tag – a devilry.apps.core.models.period_tag.PeriodTag object.

devilry.apps.core.templatetags.devilry_core_tags.devilry_test_css_class(suffix)

Adds a CSS class for automatic tests. CSS classes added using this template tag is only included when the the :setting:`DEVILRY_INCLUDE_TEST_CSS_CLASSES` setting is set to True.

To use this template tag, you provide a suffix as input, and the output will be `` test-<suffix> ``. Notice that we include space before and after the css class - this means that you do not need to add any extra spaces within your class-attribute to make room for the automatic test only css class.

Examples

Use the template tag to add test only css classes:

{% load cradmin_tags %}

<p class="paragraph paragraph--large{% devilry_test_css_class 'introduction' %}">
    The introduction
</p>

Ensure that your test settings have DEVILRY_INCLUDE_TEST_CSS_CLASSES = True.

Write tests based on the test css class:

from django import test
import htmls

class TestCase(test.TestCase):

    def test_introduction(self):
        response = some_code_to_get_response()
        selector = htmls.S(response.content)
        with self.assertEqual(
            'The introduction',
            selector.one('test-introduction')
Parameters:

suffix – The suffix for your css class. The actual css class will be `` test-<suffix> ``.