Code Duplication    Length = 13-16 lines in 2 locations

web/opensubmit/views/api.py 2 locations

@@ 28-43 (lines=16) @@
25
logger = logging.getLogger('OpenSubmit')
26
27
28
class ValidityScriptView(BinaryDownloadMixin, DetailView):
29
    '''
30
    Download of validity test script for an assignment.
31
    '''
32
    model = Assignment
33
34
    def get_object(self, queryset=None):
35
        ass = super().get_object(queryset)
36
        if self.kwargs['secret'] != settings.JOB_EXECUTOR_SECRET:
37
            raise PermissionDenied
38
        else:
39
            if not ass.validity_script_download:
40
                raise PermissionDenied
41
        self.f = ass.attachment_test_validity
42
        self.fname = self.f.name[self.f.name.rfind('/') + 1:]
43
        return ass
44
45
46
class FullScriptView(BinaryDownloadMixin, DetailView):
@@ 46-58 (lines=13) @@
43
        return ass
44
45
46
class FullScriptView(BinaryDownloadMixin, DetailView):
47
    '''
48
    Download of full test script for an assignment.
49
    '''
50
    model = Assignment
51
52
    def get_object(self, queryset=None):
53
        ass = super().get_object(queryset)
54
        if self.kwargs['secret'] != settings.JOB_EXECUTOR_SECRET:
55
            raise PermissionDenied
56
        self.f = ass.attachment_test_full
57
        self.fname = self.f.name[self.f.name.rfind('/') + 1:]
58
        return ass
59
60
61
@method_decorator(csrf_exempt, name='dispatch')