def __init__(self, *args, **kwargs): super(Voter, self).__init__(*args, **kwargs) # stub the user so code is not full of IF statements if not self.user: self.user = User(user_type='password', user_id=self.voter_email, name=self.voter_name)
def generate_voters(election, num_voters=1000, start_with=1): # generate the user for v_num in range(start_with, start_with + num_voters): user = User(user_type='password', user_id='testuser%s' % v_num, name='Test User %s' % v_num) user.save() voter = Voter(uuid=str(uuid.uuid1()), election=election, voter_type=user.user_type, voter_id=user.user_id) voter.save()
def get_user(self): # stub the user so code is not full of IF statements return self.user or User(user_type='password', user_id=self.voter_email, name=self.voter_name)