from django.core.management.base import BaseCommand
from django.utils.translation import activate

from kirppu.accounting import accounting_receipt


class Command(BaseCommand):
    help = 'Dump accounting CSV to standard output'

    def add_arguments(self, parser):
        parser.add_argument('--lang', type=str, help="Change language, for example: en")

    def handle(self, *args, **options):
        if "lang" in options:
            activate(options["lang"])
        accounting_receipt(self.stdout)

from django.core.management.base import BaseCommand
from django.utils.translation import activate

from kirppu.accounting import accounting_receipt


class Command(BaseCommand):
    help = 'Dump accounting CSV to standard output'

    def add_arguments(self, parser):
        parser.add_argument('--lang', type=str, help="Change language, for example: en")
        parser.add_argument('event', type=str, help="Event slug to dump data for")

    def handle(self, *args, **options):
        if "lang" in options:
            activate(options["lang"])

        from kirppu.models import Event
        event = Event.objects.get(slug=options["event"])
        accounting_receipt(self.stdout, event)

Fix accounting data dump command.
Fix accounting data dump command.

  from django.core.management.base import BaseCommand
  from django.utils.translation import activate
  
  from kirppu.accounting import accounting_receipt
  
  
  class Command(BaseCommand):
      help = 'Dump accounting CSV to standard output'
  
      def add_arguments(self, parser):
          parser.add_argument('--lang', type=str, help="Change language, for example: en")
+         parser.add_argument('event', type=str, help="Event slug to dump data for")
  
      def handle(self, *args, **options):
          if "lang" in options:
              activate(options["lang"])
-         accounting_receipt(self.stdout)
  
+         from kirppu.models import Event
+         event = Event.objects.get(slug=options["event"])
+         accounting_receipt(self.stdout, event)
+ 
Fix accounting data dump command.
## Code Before:
from django.core.management.base import BaseCommand
from django.utils.translation import activate

from kirppu.accounting import accounting_receipt


class Command(BaseCommand):
    help = 'Dump accounting CSV to standard output'

    def add_arguments(self, parser):
        parser.add_argument('--lang', type=str, help="Change language, for example: en")

    def handle(self, *args, **options):
        if "lang" in options:
            activate(options["lang"])
        accounting_receipt(self.stdout)

## Instruction:
Fix accounting data dump command.
## Code After:
from django.core.management.base import BaseCommand
from django.utils.translation import activate

from kirppu.accounting import accounting_receipt


class Command(BaseCommand):
    help = 'Dump accounting CSV to standard output'

    def add_arguments(self, parser):
        parser.add_argument('--lang', type=str, help="Change language, for example: en")
        parser.add_argument('event', type=str, help="Event slug to dump data for")

    def handle(self, *args, **options):
        if "lang" in options:
            activate(options["lang"])

        from kirppu.models import Event
        event = Event.objects.get(slug=options["event"])
        accounting_receipt(self.stdout, event)
