Code Duplication    Length = 13-17 lines in 2 locations

web/opensubmit/views/api.py 2 locations

@@ 28-44 (lines=17) @@
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 'secret' in self.kwargs:
37
            if self.kwargs['secret'] != settings.JOB_EXECUTOR_SECRET:
38
                raise PermissionDenied
39
        else:
40
            if not ass.validity_script_download:
41
                raise PermissionDenied
42
        self.f = ass.attachment_test_validity
43
        self.fname = self.f.name[self.f.name.rfind('/') + 1:]
44
        return ass
45
46
47
class FullScriptView(BinaryDownloadMixin, DetailView):
@@ 47-59 (lines=13) @@
44
        return ass
45
46
47
class FullScriptView(BinaryDownloadMixin, DetailView):
48
    '''
49
    Download of full test script for an assignment.
50
    '''
51
    model = Assignment
52
53
    def get_object(self, queryset=None):
54
        ass = super().get_object(queryset)
55
        if self.kwargs['secret'] != settings.JOB_EXECUTOR_SECRET:
56
            raise PermissionDenied
57
        self.f = ass.attachment_test_full
58
        self.fname = self.f.name[self.f.name.rfind('/') + 1:]
59
        return ass
60
61
62
@method_decorator(csrf_exempt, name='dispatch')