class InviteForm(Form): email = Field(label="メールアドレス", required=True) icon = FileField(label="プロフィール画像", initial=load_noimage_user()) name = Field(label="名前") roles = Field(label="役割", listed=True) screen_name = Field(label="ログイン名") editable = Field(label="プロフィールの変更を許可", initial=False)
def create(self, req): template = self.view.get_template("user/create.html") invites = User.query.filter(User.password == None).all() if req.method == "POST": try: form = InviteForm(req.post()) user = UserInvite() user.email = form["email"] user.name = form["name"] user.screen_name = form["screen_name"] user._icon = resize_icon(form["icon"]) user.roles = ":".join(form["roles"]) user.create() user.mail( "Mitamaに招待されています", "下記リンクから、Mitamaに参加しましょう\n{}".format( self.app.convert_fullurl(req, "/signup?token=" + user.token))) return Response.render( template, { "invites": invites, "roles": Role.list(), "icon": load_noimage_user() }) except Exception as err: error = str(err) return Response.render( template, { "invites": invites, "roles": Role.list(), "name": form["name"], "screen_name": form["screen_name"], "icon": resize_icon(form["icon"]), "error": error, }, ) return Response.render(template, { "invites": invites, "roles": Role.list(), "icon": load_noimage_user() })
class RegisterForm(Form): icon = FileField(label="プロフィール画像", initial=load_noimage_user()) screen_name = Field(label="ログイン名", required=True) name = Field(label="名前", required=True) password = Field(label="パスワード", required=True)
def load_noimage(self): return load_noimage_user()