def devdata(): """Create development data (users, objects).""" with mixer.ctx(loglevel='DEBUG'): mixer.guard(Operator.email == '*****@*****.**').blend( Operator, email='*****@*****.**', password='******') mixer.guard(Operator.email == '*****@*****.**').blend( Operator, email='*****@*****.**', password='******', is_manager=True) mixer.guard(Operator.email == '*****@*****.**').blend( Operator, email='*****@*****.**', password='******', is_super=True) events = mixer.cycle(2).blend('salesmeter.models.Event') orders = mixer.cycle(2).blend( 'salesmeter.models.Order', phone=mixer.FAKE, buyer=mixer.RANDOM) orders.append(None) partner = mixer.blend('salesmeter.models.Partner') sets = mixer.cycle(2).blend('salesmeter.models.TicketSet') mixer.cycle(30).blend( 'salesmeter.models.Ticket', price=mixer.RANDOM, status=mixer.RANDOM, modified=lambda: datetime(*mixer.faker.date_time_this_month().timetuple()[:7]), event=mixer.RANDOM(*events), ticketset=mixer.RANDOM(*sets), partner=partner, order=mixer.RANDOM(*orders), )
def create_superuser(email: str, password: str): """Create superuser.""" mixer.guard(Operator.email == email).blend( Operator, email=email, password=password, is_super=True) app.logger.info('Operator %s has been created.', email)