Esempio n. 1
0
    def get(self, request, job_id):
        """status of an import job"""
        job = get_object_or_404(models.ImportJob, id=job_id)
        if job.user != request.user:
            raise PermissionDenied

        try:
            task = app.AsyncResult(job.task_id)
            # triggers attribute error if the task won't load
            task.status  # pylint: disable=pointless-statement
        except (ValueError, AttributeError):
            task = None

        items = job.items.order_by("index").all()
        failed_items = [i for i in items if i.fail_reason]
        items = [i for i in items if not i.fail_reason]
        return TemplateResponse(
            request,
            "import_status.html",
            {
                "job": job,
                "items": items,
                "failed_items": failed_items,
                "task": task
            },
        )
Esempio n. 2
0
def import_status(request, job_id):
    ''' status of an import job '''
    job = models.ImportJob.objects.get(id=job_id)
    if job.user != request.user:
        raise PermissionDenied
    task = app.AsyncResult(job.task_id)
    return TemplateResponse(
        request, 'import_status.html', {
            'title': 'Import Status',
            'job': job,
            'items': job.items.order_by('index').all(),
            'task': task
        })
Esempio n. 3
0
 def get(self, request, job_id):
     """ status of an import job """
     job = models.ImportJob.objects.get(id=job_id)
     if job.user != request.user:
         raise PermissionDenied
     task = app.AsyncResult(job.task_id)
     items = job.items.order_by("index").all()
     failed_items = [i for i in items if i.fail_reason]
     items = [i for i in items if not i.fail_reason]
     return TemplateResponse(
         request,
         "import_status.html",
         {"job": job, "items": items, "failed_items": failed_items, "task": task},
     )
Esempio n. 4
0
 def get(self, request, job_id):
     ''' status of an import job '''
     job = models.ImportJob.objects.get(id=job_id)
     if job.user != request.user:
         raise PermissionDenied
     task = app.AsyncResult(job.task_id)
     items = job.items.order_by('index').all()
     failed_items = [i for i in items if i.fail_reason]
     items = [i for i in items if not i.fail_reason]
     return TemplateResponse(
         request, 'import_status.html', {
             'title': 'Import Status',
             'job': job,
             'items': items,
             'failed_items': failed_items,
             'task': task
         })