def handle(self, *args, **kwargs):
     if not settings.DEBUG:
         raise CommandError("IMPORTANT: Make sure you only run this on a "
                            "Development environment ")
     print("Make sure, the project code base has NOT the development phase "
           "changes merged, before running this command")
     answer = raw_input("Does the project codebase ONLY contain the "
                        "Ideation codebase. (yes/no)? ")
     if answer != 'yes':
         raise CommandError("Make sure your codebase .")
     answer = raw_input("This will IRREVERSIBLY add TEST DATA to your "
                        "database. Proceed (yes/no)? ")
     if answer != 'yes':
         raise CommandError("Phew. Import canceled.")
     now = datetime.utcnow()
     project = Project.objects.get(slug=IGNITE_PROJECT_SLUG)
     challenge = Challenge.objects.get(slug=IGNITE_CHALLENGE_SLUG)
     ideation = Phase.objects.get(name=IGNITE_IDEATION_NAME)
     category = Category.objects.all()[0]
     try:
         development = Phase.objects.get(name=IGNITE_DEVELOPMENT_NAME)
     except Phase.DoesNotExist:
         development = None
     # Open ideation phase
     ideation = update_phase_date(ideation,
                                  now - relativedelta(days=3),
                                  now + relativedelta(days=30), 1)
     if development:
         development = update_phase_date(development,
                                         now + relativedelta(days=50),
                                         now + relativedelta(days=80), 2)
     submission_list = create_submissions(ideation, category)
     print "DONE!", len(submission_list), "submissions created"
Exemplo n.º 2
0
 def handle(self, *args, **kwargs):
     if not settings.DEBUG:
         raise CommandError("IMPORTANT: Make sure you only run this on a "
                            "Development environment ")
     print(
         "Make sure, the project code base has NOT the development phase "
         "changes merged, before running this command")
     answer = raw_input("Does the project codebase ONLY contain the "
                        "Ideation codebase. (yes/no)? ")
     if answer != 'yes':
         raise CommandError("Make sure your codebase .")
     answer = raw_input("This will IRREVERSIBLY add TEST DATA to your "
                        "database. Proceed (yes/no)? ")
     if answer != 'yes':
         raise CommandError("Phew. Import canceled.")
     now = datetime.utcnow()
     project = Project.objects.get(slug=IGNITE_PROJECT_SLUG)
     challenge = Challenge.objects.get(slug=IGNITE_CHALLENGE_SLUG)
     ideation = Phase.objects.get(name=IGNITE_IDEATION_NAME)
     category = Category.objects.all()[0]
     try:
         development = Phase.objects.get(name=IGNITE_DEVELOPMENT_NAME)
     except Phase.DoesNotExist:
         development = None
     # Open ideation phase
     ideation = update_phase_date(ideation, now - relativedelta(days=3),
                                  now + relativedelta(days=30), 1)
     if development:
         development = update_phase_date(development,
                                         now + relativedelta(days=50),
                                         now + relativedelta(days=80), 2)
     submission_list = create_submissions(ideation, category)
     print "DONE!", len(submission_list), "submissions created"
    def handle(self, *args, **options):
        answer = raw_input('This will IRREVERSIBLY add TEST DATA to your '
                           'database. Proceed (yes/no)? ')
        if answer != 'yes':
            raise CommandError('Phew. Import canceled.')

        # Any super user is a judge
        judging_group = Group.objects.get(name='Judges')
        for user in User.objects.filter(is_superuser=True):
            judging_group.user_set.add(user)

        if options['judging']:
            print "Creating Judges"
            for i in range(10):
                judge = create_user(_random_words(1))
                judging_group.user_set.add(judge.user)
            criteria = JudgingCriterion.objects.all()
            if not criteria:
                print "Creating judging criteria"
                questions = ['Awesomeness', 'Inovation', 'Feasibility']
                criteria_list = [JudgingCriterion.objects.create(question=q) \
                                 for q in questions]

        ideation = Phase.objects.get_ideation_phase()
        if not ideation:
            raise CommandError('You need an Ideation Phase')
        development = Phase.objects.get_development_phase()
        if not development:
            # We need a development phase
            print "Creating a Development phase"
            challenge = Challenge.objects.get(slug=IGNITE_CHALLENGE_SLUG)
            development = Phase.objects.create(name=IGNITE_DEVELOPMENT_NAME,
                                               challenge=challenge, order=2)
        category = Category.objects.all()[0]
        now = datetime.utcnow()
        delta = relativedelta(days=15)
        # Ideation ``Phase``
        if options['ideation']:
            print "Opening Ideation Phase"
            start_date = now - delta
            end_date = now + delta
            judging_start_date = end_date
            judging_end_date = end_date
        else:
            print "Closing Ideation Phase"
            start_date = now - delta - delta
            end_date = now - delta
            judging_start_date = end_date
            if options['judging']:
                print "Opening judging on Ideation"
                judging_end_date = end_date + delta + delta
            else:
                judging_end_date = end_date
        ideation = self._update_object(ideation, start_date=start_date,
                                       end_date=end_date,
                                       judging_start_date=judging_start_date,
                                       judging_end_date=judging_end_date)
        if options['judging']:
            print "Adding judging criteria to Ideation"
            for criterion in criteria_list:
                ideation.phasecriterion_set.create(criterion=criterion)
        if options['submissions']:
            print "Adding submissions for the Ideation Phase"
            create_submissions(ideation, category, with_parents=True)
        if options['winners']:
            print "Setting up winners for the Ideation Phase"
            get_random_winners(ideation)
        # Development ``Phase``
        if options['development']:
            print "Opening Development Phase"
            start_date = now - relativedelta(days=3)
            end_date = now + delta + delta
        else:
            print "Closing Development Phase"
            start_date = now - delta - relativedelta(days=3)
            end_date = now - relativedelta(days=3)
        development = self._update_object(development,
                                          start_date=start_date,
                                          end_date=end_date)
        # create ``PhaseRounds`` for the development phase
        with_open_rounds = not options['closed_rounds']
        rounds = self._update_rounds(development, with_open_rounds)
        if options['submissions']:
            print "Adding submissions for the Development Phase"
            create_submissions(development, category, phase_round=rounds[0],
                               with_parents=True)
        if options['winners']:
            print "Setting up winners for the Development Phase"
            get_random_winners(development, phase_round=rounds[0])

        if options['webcast']:
            try:
                release = Release.objects.get(phase=ideation)
            except Release.DoesNotExist:
                print "Creating a Release for the timeslots"
                release = Release.objects.create(name='Release Ideation',
                                                 phase=ideation,
                                                 is_current=True)
            timeslot_date = now + relativedelta(days=15)
            print "Creating Timeslots for the release"
            for i in range(10):
                TimeSlot.objects.create(start_date=timeslot_date,
                                        end_date=timeslot_date,
                                        release=release)
        print "Done!"
    def handle(self, *args, **options):
        answer = raw_input('This will IRREVERSIBLY add TEST DATA to your '
                           'database. Proceed (yes/no)? ')
        if answer != 'yes':
            raise CommandError('Phew. Import canceled.')

        # Any super user is a judge
        judging_group = Group.objects.get(name='Judges')
        for user in User.objects.filter(is_superuser=True):
            judging_group.user_set.add(user)

        if options['judging']:
            print "Creating Judges"
            for i in range(10):
                judge = create_user(_random_words(1))
                judging_group.user_set.add(judge.user)
            criteria = JudgingCriterion.objects.all()
            if not criteria:
                print "Creating judging criteria"
                questions = ['Awesomeness', 'Inovation', 'Feasibility']
                criteria_list = [JudgingCriterion.objects.create(question=q) \
                                 for q in questions]

        ideation = Phase.objects.get_ideation_phase()
        if not ideation:
            raise CommandError('You need an Ideation Phase')
        development = Phase.objects.get_development_phase()
        if not development:
            # We need a development phase
            print "Creating a Development phase"
            challenge = Challenge.objects.get(slug=IGNITE_CHALLENGE_SLUG)
            development = Phase.objects.create(name=IGNITE_DEVELOPMENT_NAME,
                                               challenge=challenge,
                                               order=2)
        category = Category.objects.all()[0]
        now = datetime.utcnow()
        delta = relativedelta(days=15)
        # Ideation ``Phase``
        if options['ideation']:
            print "Opening Ideation Phase"
            start_date = now - delta
            end_date = now + delta
            judging_start_date = end_date
            judging_end_date = end_date
        else:
            print "Closing Ideation Phase"
            start_date = now - delta - delta
            end_date = now - delta
            judging_start_date = end_date
            if options['judging']:
                print "Opening judging on Ideation"
                judging_end_date = end_date + delta + delta
            else:
                judging_end_date = end_date
        ideation = self._update_object(ideation,
                                       start_date=start_date,
                                       end_date=end_date,
                                       judging_start_date=judging_start_date,
                                       judging_end_date=judging_end_date)
        if options['judging']:
            print "Adding judging criteria to Ideation"
            for criterion in criteria_list:
                ideation.phasecriterion_set.create(criterion=criterion)
        if options['submissions']:
            print "Adding submissions for the Ideation Phase"
            create_submissions(ideation, category, with_parents=True)
        if options['winners']:
            print "Setting up winners for the Ideation Phase"
            get_random_winners(ideation)
        # Development ``Phase``
        if options['development']:
            print "Opening Development Phase"
            start_date = now - relativedelta(days=3)
            end_date = now + delta + delta
        else:
            print "Closing Development Phase"
            start_date = now - delta - relativedelta(days=3)
            end_date = now - relativedelta(days=3)
        development = self._update_object(development,
                                          start_date=start_date,
                                          end_date=end_date)
        # create ``PhaseRounds`` for the development phase
        with_open_rounds = not options['closed_rounds']
        rounds = self._update_rounds(development, with_open_rounds)
        if options['submissions']:
            print "Adding submissions for the Development Phase"
            create_submissions(development,
                               category,
                               phase_round=rounds[0],
                               with_parents=True)
        if options['winners']:
            print "Setting up winners for the Development Phase"
            get_random_winners(development, phase_round=rounds[0])

        if options['webcast']:
            try:
                release = Release.objects.get(phase=ideation)
            except Release.DoesNotExist:
                print "Creating a Release for the timeslots"
                release = Release.objects.create(name='Release Ideation',
                                                 phase=ideation,
                                                 is_current=True)
            timeslot_date = now + relativedelta(days=15)
            print "Creating Timeslots for the release"
            for i in range(10):
                TimeSlot.objects.create(start_date=timeslot_date,
                                        end_date=timeslot_date,
                                        release=release)
        print "Done!"