
from django.core.management.base import BaseCommand
from wger.exercises.models import Exercise


class Command(BaseCommand):
    '''
    Read out the user submitted exercise.

    Used to generate the AUTHORS file for a release
    '''

    help = 'Read out the user submitted exercise'

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

        exercises = Exercise.objects.filter(status=Exercise.EXERCISE_STATUS_ACCEPTED)
        usernames = []
        for exercise in exercises:
            username = exercise.user.username
            if username not in usernames:
                usernames.append(username)
                self.stdout.write('{0}\n'.format(username))


from django.core.management.base import BaseCommand
from wger.exercises.models import Exercise


class Command(BaseCommand):
    '''
    Read out the user submitted exercise.

    Used to generate the AUTHORS file for a release
    '''

    help = 'Read out the user submitted exercise'

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

        exercises = Exercise.objects.filter(status=Exercise.EXERCISE_STATUS_ACCEPTED)
        usernames = []
        for exercise in exercises:
            if exercise.user not in usernames:
                usernames.append(exercise.user)
                self.stdout.write(exercise.user)

Fix management command for submitted exercises
Fix management command for submitted exercises

  
  from django.core.management.base import BaseCommand
  from wger.exercises.models import Exercise
  
  
  class Command(BaseCommand):
      '''
      Read out the user submitted exercise.
  
      Used to generate the AUTHORS file for a release
      '''
  
      help = 'Read out the user submitted exercise'
  
      def handle(self, *args, **options):
  
          exercises = Exercise.objects.filter(status=Exercise.EXERCISE_STATUS_ACCEPTED)
          usernames = []
          for exercise in exercises:
-             username = exercise.user.username
-             if username not in usernames:
+             if exercise.user not in usernames:
-                 usernames.append(username)
+                 usernames.append(exercise.user)
-                 self.stdout.write('{0}\n'.format(username))
+                 self.stdout.write(exercise.user)
  
Fix management command for submitted exercises
## Code Before:

from django.core.management.base import BaseCommand
from wger.exercises.models import Exercise


class Command(BaseCommand):
    '''
    Read out the user submitted exercise.

    Used to generate the AUTHORS file for a release
    '''

    help = 'Read out the user submitted exercise'

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

        exercises = Exercise.objects.filter(status=Exercise.EXERCISE_STATUS_ACCEPTED)
        usernames = []
        for exercise in exercises:
            username = exercise.user.username
            if username not in usernames:
                usernames.append(username)
                self.stdout.write('{0}\n'.format(username))

## Instruction:
Fix management command for submitted exercises
## Code After:

from django.core.management.base import BaseCommand
from wger.exercises.models import Exercise


class Command(BaseCommand):
    '''
    Read out the user submitted exercise.

    Used to generate the AUTHORS file for a release
    '''

    help = 'Read out the user submitted exercise'

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

        exercises = Exercise.objects.filter(status=Exercise.EXERCISE_STATUS_ACCEPTED)
        usernames = []
        for exercise in exercises:
            if exercise.user not in usernames:
                usernames.append(exercise.user)
                self.stdout.write(exercise.user)
