Passed
Pull Request — master (#40)
by Paolo
01:44
created

excel.tasks   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 15
dl 0
loc 36
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A ImportTemplateTask.import_data_from_file() 0 4 1
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
"""
4
Created on Tue Jul  9 11:50:39 2019
5
6
@author: Paolo Cozzi <[email protected]>
7
"""
8
9
from celery.utils.log import get_task_logger
10
11
from image.celery import app as celery_app, MyTask
12
from image_app.models import Submission
13
from submissions.tasks import ImportGenericTaskMixin
14
15
from .helpers import upload_template
16
17
# Get an instance of a logger
18
logger = get_task_logger(__name__)
19
20
21
class ImportTemplateTask(ImportGenericTaskMixin, MyTask):
22
    name = "Import Template"
23
    description = """Import Template data from Excel file"""
24
    submission_model = Submission
25
    datasource_type = "Template"
26
27
    def import_data_from_file(self, submission_obj):
28
        """Call the custom import method"""
29
30
        return upload_template(submission_obj)
31
32
33
# register explicitly tasks
34
# https://github.com/celery/celery/issues/3744#issuecomment-271366923
35
celery_app.tasks.register(ImportTemplateTask)
36