import logging
from django.core.management.base import BaseCommand


logger = logging.getLogger(__name__)


class Command(BaseCommand):
    help = "This runs the MCCB1sSLA report"

    def handle(self, *args, **options):
        self.create_report()

    def create_report():
        print("stuff goes here")

        # '{"action": "Export", "csrfmiddlewaretoken": "PQk4Pt55CL0NBapx9hSqZTJkSn6tL6TL", "date_from": "08/05/2021", "date_to": "10/05/2021"}'

        # report_data = json_stuff_goes_here
        #         ExportTask().delay(user_person.pk, filename_of_report, mi_cb1_extract_agilisys, report_data)

import logging
from django.core.management.base import BaseCommand
from reports.tasks import ExportTask
from core.models import get_web_user
from django.views.decorators.csrf import csrf_exempt

logger = logging.getLogger(__name__)


class Command(BaseCommand):
    help = "This runs the MCCB1sSLA report"

    def handle(self, *args, **options):
        self.create_report()

    @csrf_exempt
    def create_report(self):
        report_data = '{"action": "Export", "csrfmiddlewaretoken": "PQk4Pt55CL0NBapx9hSqZTJkSn6tL6TL", "date_from": "2021-05-08", "date_to": "2021-05-10"}'

        # report_data = json_stuff_goes_here
        web_user = get_web_user()
        filename_of_report = "WEEKLY-REPORT-TEST.csv"
        ExportTask().delay(web_user.pk, filename_of_report, "MICB1Extract", report_data)

Send weekly report to aws
Send weekly report to aws

  import logging
  from django.core.management.base import BaseCommand
- 
+ from reports.tasks import ExportTask
+ from core.models import get_web_user
+ from django.views.decorators.csrf import csrf_exempt
  
  logger = logging.getLogger(__name__)
  
  
  class Command(BaseCommand):
      help = "This runs the MCCB1sSLA report"
  
      def handle(self, *args, **options):
          self.create_report()
  
+     @csrf_exempt
-     def create_report():
+     def create_report(self):
-         print("stuff goes here")
- 
-         # '{"action": "Export", "csrfmiddlewaretoken": "PQk4Pt55CL0NBapx9hSqZTJkSn6tL6TL", "date_from": "08/05/2021", "date_to": "10/05/2021"}'
+         report_data = '{"action": "Export", "csrfmiddlewaretoken": "PQk4Pt55CL0NBapx9hSqZTJkSn6tL6TL", "date_from": "2021-05-08", "date_to": "2021-05-10"}'
  
          # report_data = json_stuff_goes_here
+         web_user = get_web_user()
+         filename_of_report = "WEEKLY-REPORT-TEST.csv"
-         #         ExportTask().delay(user_person.pk, filename_of_report, mi_cb1_extract_agilisys, report_data)
+         ExportTask().delay(web_user.pk, filename_of_report, "MICB1Extract", report_data)
  
Send weekly report to aws
## Code Before:
import logging
from django.core.management.base import BaseCommand


logger = logging.getLogger(__name__)


class Command(BaseCommand):
    help = "This runs the MCCB1sSLA report"

    def handle(self, *args, **options):
        self.create_report()

    def create_report():
        print("stuff goes here")

        # '{"action": "Export", "csrfmiddlewaretoken": "PQk4Pt55CL0NBapx9hSqZTJkSn6tL6TL", "date_from": "08/05/2021", "date_to": "10/05/2021"}'

        # report_data = json_stuff_goes_here
        #         ExportTask().delay(user_person.pk, filename_of_report, mi_cb1_extract_agilisys, report_data)

## Instruction:
Send weekly report to aws
## Code After:
import logging
from django.core.management.base import BaseCommand
from reports.tasks import ExportTask
from core.models import get_web_user
from django.views.decorators.csrf import csrf_exempt

logger = logging.getLogger(__name__)


class Command(BaseCommand):
    help = "This runs the MCCB1sSLA report"

    def handle(self, *args, **options):
        self.create_report()

    @csrf_exempt
    def create_report(self):
        report_data = '{"action": "Export", "csrfmiddlewaretoken": "PQk4Pt55CL0NBapx9hSqZTJkSn6tL6TL", "date_from": "2021-05-08", "date_to": "2021-05-10"}'

        # report_data = json_stuff_goes_here
        web_user = get_web_user()
        filename_of_report = "WEEKLY-REPORT-TEST.csv"
        ExportTask().delay(web_user.pk, filename_of_report, "MICB1Extract", report_data)
