Skip to content

Commit

Permalink
made the active conitions for buttons use proper Enums
Browse files Browse the repository at this point in the history
  • Loading branch information
jooooosef authored and ybrnr committed Oct 28, 2024
1 parent 042d6d8 commit 73c3a65
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
12 changes: 6 additions & 6 deletions evap/results/templates/results_evaluation_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h3 class="mb-0">{{ evaluation.full_name }} ({{ evaluation.course.semester.name
<a
href="{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view_general_results=full&view_contributor_results={{ view_contributor_results.value }}"
role="button"
class="btn btn-sm btn-light{% if view_general_results.value == 'full' %} active{% endif %} {% if not can_see_general_textanswers %} disabled {% endif %}"
class="btn btn-sm btn-light{% if view_general_results == ViewGeneralResults.FULL %} active{% endif %} {% if not can_see_general_textanswers %} disabled {% endif %}"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{% blocktranslate %}All results of general questions (including text answers){% endblocktranslate %}"
Expand All @@ -55,7 +55,7 @@ <h3 class="mb-0">{{ evaluation.full_name }} ({{ evaluation.course.semester.name
<a
href="{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view_general_results=ratings&view_contributor_results={{ view_contributor_results.value }}"
role="button"
class="btn btn-sm btn-light{% if view_general_results.value == 'ratings' %} active{% endif %} {% if not can_see_general_textanswers %} disabled {% endif %}"
class="btn btn-sm btn-light{% if view_general_results == ViewGeneralResults.RATINGS %} active{% endif %} {% if not can_see_general_textanswers %} disabled {% endif %}"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{% translate 'Only rating results of general questions (without text answers)' %}"
Expand All @@ -76,7 +76,7 @@ <h3 class="mb-0">{{ evaluation.full_name }} ({{ evaluation.course.semester.name
<a
href="{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view_general_results={{ view_general_results.value }}&view_contributor_results=full"
role="button"
class="btn btn-sm btn-light{% if view_contributor_results.value == 'full' %} active{% endif %} {% if not can_see_contributor_textanswers %} disabled {% endif %}"
class="btn btn-sm btn-light{% if view_contributor_results == ViewContributorResults.FULL %} active{% endif %} {% if not can_see_contributor_textanswers %} disabled {% endif %}"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{% blocktranslate %}All results of contributor questions available for you (including text answers){% endblocktranslate %}"
Expand All @@ -88,18 +88,18 @@ <h3 class="mb-0">{{ evaluation.full_name }} ({{ evaluation.course.semester.name
<a
href="{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view_general_results={{ view_general_results.value }}&view_contributor_results=ratings"
role="button"
class="btn btn-sm btn-light{% if view_contributor_results.value == 'ratings' %} active{% endif %} {% if not can_see_contributor_textanswers %} disabled {% endif %}"
class="btn btn-sm btn-light{% if view_contributor_results == ViewContributorResults.RATINGS %} active{% endif %} {% if not can_see_contributor_textanswers %} disabled {% endif %}"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{% translate 'Only rating results of contributor questions (without text answers)' %}"
>
{% translate 'Ratings' %}
</a>
{% if user.is_staff and view_contributor_results.value == 'personal' or is_contributor %}
{% if user.is_staff and view_contributor_results == ViewContributorResults.PERSONAL or is_contributor %}
<a
href="{% url 'results:evaluation_detail' evaluation.course.semester.id evaluation.id %}?view_general_results={{ view_general_results.value }}&view_contributor_results=personal"
role="button"
class="btn btn-sm btn-light{% if view_contributor_results == 'personal' %} active{% endif %} {% if not can_see_contributor_textanswers %} disabled {% endif %}"
class="btn btn-sm btn-light{% if view_contributor_results == ViewContributorResults.PERSONAL %} active{% endif %} {% if not can_see_contributor_textanswers %} disabled {% endif %}"
data-bs-toggle="tooltip"
data-bs-placement="bottom"
title="{% translate 'All results of contributor questions regarding yourself, hiding other contributors' %}"
Expand Down
6 changes: 6 additions & 0 deletions evap/results/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,17 @@


class ViewGeneralResults(Enum):
@property
def do_not_call_in_templates(self):
return False # ich darf das weil django kaputt is (pass geht auch :o)

Check warning on line 43 in evap/results/tools.py

View check run for this annotation

Codecov / codecov/patch

evap/results/tools.py#L43

Added line #L43 was not covered by tests
FULL = "full"
RATINGS = "ratings"


class ViewContributorResults(Enum):
@property
def do_not_call_in_templates(self):
return True

Check warning on line 51 in evap/results/tools.py

View check run for this annotation

Codecov / codecov/patch

evap/results/tools.py#L51

Added line #L51 was not covered by tests
FULL = "full"
RATINGS = "ratings"
PERSONAL = "personal"
Expand Down
2 changes: 2 additions & 0 deletions evap/results/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ def evaluation_detail(request, semester_id, evaluation_id):
"can_see_contributor_textanswers": TextAnswer.objects.filter(
contribution__contributor=view_as_user, contribution__evaluation=evaluation
).exists(),
"ViewContributorResults": ViewContributorResults,
"ViewGeneralResults": ViewGeneralResults,
}
return render(request, "results_evaluation_detail.html", template_data)

Expand Down

0 comments on commit 73c3a65

Please sign in to comment.