Skip to content

Commit

Permalink
Merge pull request #206 from openedx/zshkoor/django42
Browse files Browse the repository at this point in the history
fix: Added support for django42
  • Loading branch information
zubairshakoorarbisoft authored Aug 1, 2023
2 parents 6fadad5 + 95635a2 commit 5db9c66
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ jobs:
os: [ubuntu-20.04]
python-version: ['3.8']
toxenv: [
quality, docs, django32-drf312, django32-drf314,
django40-drf312, django40-drf314
quality, docs, django32-drf314, django42-drf314
]

steps:
Expand All @@ -39,7 +38,7 @@ jobs:
run: tox

- name: Run Coverage
if: matrix.python-version == '3.8' && matrix.toxenv=='django32-drf312'
if: matrix.python-version == '3.8' && matrix.toxenv=='django42-drf314'
uses: codecov/codecov-action@v1
with:
flags: unittests
Expand Down
2 changes: 1 addition & 1 deletion submissions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
""" API for creating submissions and scores. """
__version__ = '3.5.6'
__version__ = '3.6.0'
43 changes: 26 additions & 17 deletions submissions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,28 @@ class StudentItemAdminMixin:
'student_item__id'
)

@admin.display(
ordering='student_item__course_id'
)
def course_id(self, obj):
return obj.student_item.course_id
course_id.admin_order_field = 'student_item__course_id'

@admin.display(
ordering='student_item__item_id'
)
def item_id(self, obj):
return obj.student_item.item_id
item_id.admin_order_field = 'student_item__item_id'

@admin.display(
ordering='student_item__student_id'
)
def student_id(self, obj):
return obj.student_item.student_id
student_id.admin_order_field = 'student_item__student_id'

@admin.display(
description='S.I. ID',
ordering='student_item__id',
)
def student_item_id(self, obj):
""" Formated student item id. """
url = reverse(
Expand All @@ -36,17 +46,16 @@ def student_item_id(self, obj):
)
return format_html(f'<a href="{url}">{obj.student_item.id}</a>')

student_item_id.admin_order_field = 'student_item__id'
student_item_id.short_description = 'S.I. ID'


@admin.register(StudentItem)
class StudentItemAdmin(admin.ModelAdmin):
list_display = ('id', 'course_id', 'item_type', 'item_id', 'student_id')
list_filter = ('item_type',)
search_fields = ('id', 'course_id', 'item_type', 'item_id', 'student_id')
readonly_fields = ('course_id', 'item_type', 'item_id', 'student_id')


@admin.register(Submission)
class SubmissionAdmin(admin.ModelAdmin, StudentItemAdminMixin):
""" Student Submission Admin View. """
list_display = (
Expand Down Expand Up @@ -83,6 +92,7 @@ class SubmissionInlineAdmin(admin.TabularInline, StudentItemAdminMixin):
extra = 0


@admin.register(TeamSubmission)
class TeamSubmissionAdmin(admin.ModelAdmin):
""" Student Submission Admin View. """

Expand All @@ -92,6 +102,7 @@ class TeamSubmissionAdmin(admin.ModelAdmin):
inlines = (SubmissionInlineAdmin,)


@admin.register(Score)
class ScoreAdmin(admin.ModelAdmin, StudentItemAdminMixin):
""" Student Score Admin View. """
list_display = (
Expand All @@ -114,6 +125,7 @@ def points(self, score):
return f"{score.points_earned}/{score.points_possible}"


@admin.register(ScoreSummary)
class ScoreSummaryAdmin(admin.ModelAdmin, StudentItemAdminMixin):
""" Student Score Summary Admin View. """
list_display = (
Expand All @@ -127,25 +139,22 @@ class ScoreSummaryAdmin(admin.ModelAdmin, StudentItemAdminMixin):
)
exclude = ('highest', 'latest')

@admin.display(
description='Highest'
)
def highest_link(self, score_summary):
"""Returns highest link"""
url = reverse(
'admin:submissions_score_change', args=[score_summary.highest.id]
)
return format_html(f'<a href="{url}">{score_summary.highest}</a>')

highest_link.short_description = 'Highest'

@admin.display(
description='Latest'
)
def latest_link(self, score_summary):
"""Returns latest link"""
url = reverse(
'admin:submissions_score_change', args=[score_summary.latest.id]
)
return format_html(f'<a href="{url}">{score_summary.latest}</a>')

latest_link.short_description = 'Latest'


admin.site.register(Score, ScoreAdmin)
admin.site.register(StudentItem, StudentItemAdmin)
admin.site.register(Submission, SubmissionAdmin)
admin.site.register(TeamSubmission, TeamSubmissionAdmin)
admin.site.register(ScoreSummary, ScoreSummaryAdmin)
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ setenv =
deps =
-r{toxinidir}/requirements/test.txt
django32: Django>=3.2,<4.0
django40: Django>=4.0,<4.1
drf312: djangorestframework<3.13.0
django42: Django>=4.2,<4.3
drf314: djangorestframework<3.15.0
commands =
python -Wd -m pytest {posargs}
Expand Down

0 comments on commit 5db9c66

Please sign in to comment.