def generate_random_test_data(): """ Generate some random test data. """ # create the evaluations i = 0 Evaluation.objects.all().delete() for country in Country.objects.all(): # update country fields with random values country.regional_bureaux = random.choice( Country.REGIONAL_BUREAU_CHOICES)[0] country.desk_study = random.choice([True, False]) country.country_visit = random.choice([True, False]) country.planned = random.choice([True, False]) country.planning_date = get_random_date() country.save() # generate 1 to 5 evals per country for eva in range(1, randint(1, 5)): i = i + 1 print 'Generating eva %s for %s' % (i, country.name) e = Evaluation() e.title = 'Eval %s' % i e.country = country e.date = get_random_date() e.link = 'http://example.com/%s/%s' % (country.name, i) e.evaluation_type = random.choice( Evaluation.EVALUTATION_TYPE_CHOICES)[0] e.save()
def generate_random_test_data(): """ Generate some random test data. """ # create the evaluations i = 0 Evaluation.objects.all().delete() for country in Country.objects.all(): # update country fields with random values country.regional_bureaux = random.choice(Country.REGIONAL_BUREAU_CHOICES)[0] country.desk_study = random.choice([True, False]) country.country_visit = random.choice([True, False]) country.planned = random.choice([True, False]) country.planning_date = get_random_date() country.save() # generate 1 to 5 evals per country for eva in range(1, randint(1, 5)): i = i + 1 print "Generating eva %s for %s" % (i, country.name) e = Evaluation() e.title = "Eval %s" % i e.country = country e.date = get_random_date() e.link = "http://example.com/%s/%s" % (country.name, i) e.evaluation_type = random.choice(Evaluation.EVALUTATION_TYPE_CHOICES)[0] e.save()
def buildEmptyEvaluation(self,userID, rideID): """Make an empty evaluation for userID and instructionID @pre : userID is the id of a user rideID is the id of the ride @post : the empty evaluation for userID and instructionID is now present in DB the thread that will launch the delay making the evaluation after 3 days unavailable is launched. """ ride = Ride.objects.get(id = rideID) if ride.offer.proposal.user.id!=userID: u_from = ride.offer.proposal.user else: u_from = ride.offer.request.user myeval = Evaluation(ride=ride, user_from=u_from, user_to=UserProfile.objects.get(id=userID), locked=False, ride_time=datetime.datetime.today()) myeval.save() delay = delayAction(86400*3, self.send_to, (self.get_port, ('closeevaluation', myeval.id))) delay.start()