Exemplo n.º 1
0
def new_coach():
    """creates new coach"""
    try:
        user = current_user()
        name = user['username'] + "#" + user['discriminator']
        coach = CoachService.new_coach(name, user['id'])
    except TransactionError as exc:
        raise InvalidUsage(str(exc), status_code=403)

    result = coach_schema.dump(coach)
    return jsonify(result.data)
Exemplo n.º 2
0
 async def newcoach(self, ctx):
     """Creates new coach account"""
     coach = CoachService.discord_user_to_coach(ctx.author)
     if coach:
         await ctx.send(f"**{ctx.author.mention}** account exists already")
     elif Coach.get_by_discord_id(ctx.author.id, deleted=True):
         await ctx.send(
             f"**{ctx.author.mention}** account is inactive, use the web page to activate it"
         )
     else:
         coach = CoachService.new_coach(ctx.author, ctx.author.id)
         msg = f"**{ctx.author.mention}** account created\n" \
             + f"**Bank:** {coach.account.amount} coins\n" \
             + f"**Rules**: <{RULES_LINK}>"
         await ctx.send(msg)
Exemplo n.º 3
0
 def populate_db(self):
     with self.app.app_context():
         c = CoachService.new_coach("TomasT", "1")
         db.session.add(c)
         db.session.commit()