Code Duplication    Length = 13-14 lines in 2 locations

web/opensubmit/admin/course.py 1 location

@@ 18-31 (lines=14) @@
15
    result += format_html('<a href="%s" style="white-space: nowrap">eMail to students</a>'%reverse('mailcourse', args=(course.pk,)))
16
    return result
17
18
class CourseAdmin(django.contrib.admin.ModelAdmin):
19
    list_display = ['__str__', 'active', 'owner', assignments, actions]
20
    filter_horizontal = ['tutors']
21
22
    class Media:
23
        css = {'all': ('css/teacher.css',)}
24
25
    def get_queryset(self, request):
26
        ''' Restrict the listed courses for the current user.'''
27
        qs = super(CourseAdmin, self).get_queryset(request)
28
        if request.user.is_superuser:
29
            return qs
30
        else:
31
            return qs.filter(Q(tutors__pk=request.user.pk) | Q(owner=request.user)).distinct()
32

web/opensubmit/admin/submissionfile.py 1 location

@@ 16-28 (lines=13) @@
13
    return submfile.replaced_by is None
14
not_withdrawn.boolean = True
15
16
class SubmissionFileAdmin(ModelAdmin):
17
    list_display = ['__str__', 'fetched', submissions, not_withdrawn]
18
19
    class Media:
20
        css = {'all': ('css/teacher.css',)}
21
22
    def get_queryset(self, request):
23
        ''' Restrict the listed submission files for the current user.'''
24
        qs = super(SubmissionFileAdmin, self).get_queryset(request)
25
        if request.user.is_superuser:
26
            return qs
27
        else:
28
            return qs.filter(Q(submissions__assignment__course__tutors__pk=request.user.pk) | Q(submissions__assignment__course__owner=request.user)).distinct()
29