Skip to content

Commit 8ed7a27

Browse files
committed
fix(review): use dispatched grade labels in admin and fix difficulty help_text
1 parent a56b2c2 commit 8ed7a27

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

django/apps/review/admin.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
from django.contrib.admin import ModelAdmin, register, RelatedOnlyFieldListFilter
2+
from django.utils.translation import gettext_lazy as _
23

34
from apps.review.models import Review
45

56

67
@register(Review)
78
class ReviewAdmin(ModelAdmin):
8-
date_hierarchy = 'thesis__published_at'
9-
list_display = ['thesis', 'user', 'created', 'grade_proposal']
9+
date_hierarchy = "thesis__published_at"
10+
list_display = ["thesis", "user", "created", "grade_proposal_display"]
1011

1112
list_filter = (
12-
('user', RelatedOnlyFieldListFilter),
13-
'grade_proposal',
13+
("user", RelatedOnlyFieldListFilter),
14+
"grade_proposal",
1415
)
16+
17+
@staticmethod
18+
def grade_proposal_display(obj: Review) -> str:
19+
choices_class = obj.get_grades_choices()
20+
try:
21+
return choices_class(obj.grade_proposal).label
22+
except ValueError:
23+
return str(obj.grade_proposal)
24+
25+
grade_proposal_display.short_description = _("Proposed grade")

django/apps/review/models/review.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class DifficultyNewChoices(IntegerChoices):
6565
)
6666
difficulty = models.PositiveSmallIntegerField(
6767
verbose_name=_('Difficulty'),
68-
help_text=_('As value between 1 and 3 inclusive, higher is harder.'),
68+
help_text=_('As value between 1 and 3 inclusive.'),
6969
validators=[MinValueValidator(1), MaxValueValidator(3)],
7070
choices=DifficultyChoices.choices,
7171
)

django/docker-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ run() {
44
# Start process as unprivileged user
55
# Use `exec` to replace original process.
66
# This makes it possible for Docker to send signals to the process.
7-
exec su root -c "$*"
7+
exec su django -c "$*"
88
}
99

1010
case $1 in

0 commit comments

Comments
 (0)