Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
janno42 committed Jul 7, 2024
2 parents b3929c1 + 14fdbd3 commit 1208607
Show file tree
Hide file tree
Showing 28 changed files with 465 additions and 97 deletions.
19 changes: 19 additions & 0 deletions deployment/localsettings.template.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from fractions import Fraction

from django.utils.safestring import mark_safe

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql', # postgresql', 'mysql', 'sqlite3' or 'oracle'.
Expand All @@ -15,3 +19,18 @@

# Make apache work when DEBUG == False
ALLOWED_HOSTS = ["localhost", "127.0.0.1"]

### Evaluation progress rewards
GLOBAL_EVALUATION_PROGRESS_REWARDS: list[tuple[Fraction, str]] = [
(Fraction("0"), "0€"),
(Fraction("0.25"), "1.000€"),
(Fraction("0.6"), "3.000€"),
(Fraction("0.7"), "7.000€"),
(Fraction("0.9"), "10.000€"),
]
GLOBAL_EVALUATION_PROGRESS_EXCLUDED_COURSE_TYPE_IDS: list[int] = []
GLOBAL_EVALUATION_PROGRESS_EXCLUDED_EVALUATION_IDS: list[int] = []
GLOBAL_EVALUATION_PROGRESS_INFO_TEXT = {
"de": mark_safe("Deine Teilnahme am Evaluationsprojekt wird helfen. Evaluiere also <b>jetzt</b>!"),
"en": mark_safe("Your participation in the evaluation helps, so evaluate <b>now</b>!"),
}
33 changes: 33 additions & 0 deletions evap/evaluation/migrations/0144_alter_evaluation_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 5.0.6 on 2024-06-17 23:00

import django_fsm
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("evaluation", "0143_alter_evaluation_state"),
]

operations = [
migrations.AlterField(
model_name="evaluation",
name="state",
field=django_fsm.FSMIntegerField(
choices=[
(10, "new"),
(20, "prepared"),
(30, "editor approved"),
(40, "approved"),
(50, "in evaluation"),
(60, "evaluated"),
(70, "reviewed"),
(80, "published"),
],
default=10,
protected=True,
verbose_name="state",
),
),
]
28 changes: 16 additions & 12 deletions evap/evaluation/models_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from django.template.defaultfilters import yesno
from django.utils.formats import localize
from django.utils.translation import gettext_lazy as _
from typing_extensions import assert_never

from evap.evaluation.tools import capitalize_first

Expand Down Expand Up @@ -100,18 +101,21 @@ def field_context_data(self):

@property
def message(self):
if self.action_type == InstanceActionType.CHANGE:
if self.content_object:
message = _("The {cls} {obj} was changed.")
else: # content_object might be deleted
message = _("A {cls} was changed.")
elif self.action_type == InstanceActionType.CREATE:
if self.content_object:
message = _("The {cls} {obj} was created.")
else:
message = _("A {cls} was created.")
elif self.action_type == InstanceActionType.DELETE:
message = _("A {cls} was deleted.")
match self.action_type:
case InstanceActionType.CHANGE:
if self.content_object:
message = _("The {cls} {obj} was changed.")
else: # content_object might be deleted
message = _("A {cls} was changed.")
case InstanceActionType.CREATE:
if self.content_object:
message = _("The {cls} {obj} was created.")
else:
message = _("A {cls} was created.")
case InstanceActionType.DELETE:
message = _("A {cls} was deleted.")
case _:
assert_never(self.action_type)

return message.format(
cls=capitalize_first(self.content_type.model_class()._meta.verbose_name),
Expand Down
2 changes: 1 addition & 1 deletion evap/evaluation/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
const baseOptions = {
createOnBlur: true,
placeholder: "{% translate 'Please select...' %}",
hidePlaceholder: true,
hidePlaceholder: element.hasAttribute("data-tomselect-fullwidth") ? false : true,
minimumInputLength,
render: {
option_create: (data, escape) => `<div class="create">${ escape(data.input) }</div>`,
Expand Down
8 changes: 8 additions & 0 deletions evap/evaluation/templatetags/evaluation_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ def percentage_one_decimal(fraction, population):
return None


@register.filter
def percentage_zero_on_error(fraction, population):
try:
return f"{int(float(fraction) / float(population) * 100):.0f}%"
except (ZeroDivisionError, ValueError):
return "0%"


@register.filter
def to_colors(question_result: RatingResult | None):
if question_result is None:
Expand Down
Loading

0 comments on commit 1208607

Please sign in to comment.