From: Guillaume Pellerin Date: Tue, 24 Jan 2017 20:42:35 +0000 (+0100) Subject: Add script manual admin submission X-Git-Tag: 1.1~36 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=f3a07dd4b86d5a28a033770714cf3cf52a88011d;p=teleforma.git Add script manual admin submission --- diff --git a/teleforma/exam/admin.py b/teleforma/exam/admin.py index ea2109d7..1c9f23c2 100644 --- a/teleforma/exam/admin.py +++ b/teleforma/exam/admin.py @@ -37,6 +37,7 @@ class ScriptAdmin(admin.ModelAdmin): readonly_fields = ['date_added','uuid','box_uuid','sha1','mime_type'] list_filter = ['period', 'course__title', 'session', 'type', 'status'] list_display = ['title', 'author_name', 'file_size', 'status'] + actions = ['submit',] def author_name(self, instance): return instance.author.username @@ -50,9 +51,15 @@ class ScriptAdmin(admin.ModelAdmin): else: return '0' + def submit(self, request, queryset): + for script in queryset.all(): + script.status = 2 + script.submit() + + submit.short_description = "Submit scripts" + admin.site.register(Script, ScriptAdmin) admin.site.register(ScriptPage) admin.site.register(ScriptType) admin.site.register(Quota, QuotaAdmin) - diff --git a/teleforma/exam/models.py b/teleforma/exam/models.py index 59a0bae7..a919475f 100644 --- a/teleforma/exam/models.py +++ b/teleforma/exam/models.py @@ -409,9 +409,9 @@ class Script(BaseResource): if not self.status == 0 and self.file: if not self.box_uuid: self.uuid_link() - self.box_upload() - if not self.corrector and self.t == 1: - self.auto_set_corrector() + self.box_upload() + if not self.corrector and self.t == 1: + self.auto_set_corrector() else: if not self.corrector: self.auto_set_corrector() diff --git a/teleforma/management/commands/teleforma-exam-submit-scripts-debug.py b/teleforma/management/commands/teleforma-exam-submit-scripts-debug.py index 3465aa9b..97971e66 100644 --- a/teleforma/management/commands/teleforma-exam-submit-scripts-debug.py +++ b/teleforma/management/commands/teleforma-exam-submit-scripts-debug.py @@ -29,7 +29,7 @@ class Logger: class Command(BaseCommand): help = "submit all script to Box View" args = "log_file" - + def handle(self, *args, **options): translation.activate(settings.LANGUAGE_CODE) logger = Logger(args[0]) @@ -41,4 +41,3 @@ class Command(BaseCommand): logger.logger.info(str(script.id) + ' : ' + script.url) logger.logger.info(script.status) time.sleep(10) -