本文整理汇总了Golang中github.com/astaxie/beego.NewFlash函数的典型用法代码示例。如果您正苦于以下问题:Golang NewFlash函数的具体用法?Golang NewFlash怎么用?Golang NewFlash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewFlash函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ByMailIncident
func (this *AdminController) ByMailIncident() {
flash := beego.NewFlash()
o := orm.NewOrm()
o.Using("default")
var incidents []*models.Incident
mail := this.GetSession("uid")
num, err := o.QueryTable("Incident").Filter("User", mail).RelatedSel().All(&incidents)
if err != orm.ErrNoRows && num > 0 {
this.TplNames = "index/index.tpl"
this.Data["incidents"] = incidents
flash := beego.NewFlash()
flash.Notice("Mes incidents déclarés")
flash.Store(&this.Controller)
} else {
// No result
flash.Error("Aucun Incident dans la Base de données")
flash.Store(&this.Controller)
this.Redirect("/", 302)
}
Template(this, "user", "myincident", "Liste de mes incidents déclarés")
}
开发者ID:kameleon83,项目名称:managIncident,代码行数:31,代码来源:index.go
示例2: Update
func (manage *ManageController) Update() {
o := orm.NewOrm()
o.Using("default")
flash := beego.NewFlash()
//convert the string value to an int
if articleId, err := strconv.Atoi(manage.Ctx.Input.Param(":id")); err == nil {
article := models.Article{Id: articleId}
if o.Read(&article) == nil {
article.Client = "Sitepoint"
article.Url = "http:"
if num, err := o.Update(&article); err == nil {
flash.Notice("Record Was Update.")
flash.Store(&manage.Controller)
beego.Info("Record Was Update. ", num)
} else {
flash.Notice("Record Was NOT Updated.")
flash.Store(&manage.Controller)
beego.Error("Couldn't find article matching id: ", articleId)
}
} else {
flash.Notice("Record Was NOT Updated.")
flash.Store(&manage.Controller)
beego.Error("Couldn't convert id from a string to a number. ", err)
}
}
// redirect afterwards
manage.Redirect("/manage/view", 302)
}
开发者ID:lynndotconfig,项目名称:go-blog,代码行数:32,代码来源:manage.go
示例3: DeleteDemand
func (this *AdminController) DeleteDemand() {
o := orm.NewOrm()
o.Using("default")
demandId, _ := strconv.Atoi(this.Ctx.Input.Param(":id"))
register := models.Register{}
flash := beego.NewFlash()
if exist := o.QueryTable(register.TableName()).Filter("Id", demandId).Exist(); exist {
if num, err := o.Delete(&models.Register{Id: demandId}); err == nil {
beego.Info("Record Deleted. ", num)
flash.Notice("La demande a bien été supprimé")
} else {
beego.Error("La demande n'a pu être supprimé. Raison: ", err)
}
} else {
flash.Notice("La demande n'existe pas %d", demandId)
}
flash.Store(&this.Controller)
this.Redirect("/incident-manager/admin/register", 302)
}
开发者ID:kameleon83,项目名称:managIncident,代码行数:26,代码来源:demand.go
示例4: Get
// update criteria
func (c *Crit) Get() {
c.Data["isEdit"] = true
c.TplNames = "crit/form.tpl"
c.Data["xsrfdata"] = template.HTML(c.XsrfFormHtml())
id, err := strconv.Atoi(c.Ctx.Input.Param(":id"))
if err != nil {
beego.Error(err)
id = 0
}
var crit M.Crit
if DM.FindByPk(&crit, id) != nil {
flash := beego.NewFlash()
flash.Notice(T("crit_not_found"))
flash.Store(&c.Controller)
c.Redirect(beego.UrlFor("Crit.Index"), 302)
return
}
var deps []M.Dep
err = DM.FindAll(&M.Dep{}, &deps, M.Sf{"Id", "Title"}, M.Where{})
if err != nil {
beego.Error(err)
}
c.Data["deps"] = deps
c.Data["crit"] = crit
}
开发者ID:grr89,项目名称:hrkb,代码行数:28,代码来源:crit.go
示例5: DoLogin
func (this *MainController) DoLogin() {
var (
uemail string = strings.TrimSpace(this.GetString("uemail"))
upw string = strings.TrimSpace(this.GetString("upw"))
)
user, err := buser.FindUserByEmail(uemail)
log.Println("user " + user.Username)
log.Println("user.Password " + user.Password)
log.Println("utils.Md5(upw) " + utils.Md5(upw))
if (err != nil) || (user.Password != utils.Md5(upw)) || (user.Uid < 1) {
flash := beego.NewFlash()
flash.Set("uemail", uemail)
flash.Set("error", utils.WrapString("登录出错,请检查用户名密码是否正确"))
flash.Store(&this.Controller)
url := utils.U("")
this.Redirect(url, 302)
} else {
this.SetSession("IsLoggedIn", true)
uc := context.UserContext{}
context.SetUserContext(user.Uid, uc)
url := utils.U("home")
this.Redirect(url, 302)
}
}
开发者ID:sndnvaps,项目名称:gooa,代码行数:26,代码来源:main.go
示例6: Profile
// 个人信息
func (this *MainController) Profile() {
beego.ReadFromRequest(&this.Controller)
user, _ := models.UserGetById(this.userId)
if this.isPost() {
flash := beego.NewFlash()
user.Email = this.GetString("email")
user.Update()
password1 := this.GetString("password1")
password2 := this.GetString("password2")
if password1 != "" {
if len(password1) < 6 {
flash.Error("密码长度必须大于6位")
flash.Store(&this.Controller)
this.redirect(beego.URLFor(".Profile"))
} else if password2 != password1 {
flash.Error("两次输入的密码不一致")
flash.Store(&this.Controller)
this.redirect(beego.URLFor(".Profile"))
} else {
user.Salt = string(utils.RandomCreateBytes(10))
user.Password = libs.Md5([]byte(password1 + user.Salt))
user.Update()
}
}
flash.Success("修改成功!")
flash.Store(&this.Controller)
this.redirect(beego.URLFor(".Profile"))
}
this.Data["pageTitle"] = "个人信息"
this.Data["user"] = user
this.display()
}
开发者ID:avldya,项目名称:webcron,代码行数:35,代码来源:main.go
示例7: DeleteUser
func (this *AdminController) DeleteUser() {
o := orm.NewOrm()
o.Using("default")
usersId, _ := strconv.Atoi(this.Ctx.Input.Param(":id"))
users := models.User{}
flash := beego.NewFlash()
if exist := o.QueryTable(users.TableName()).Filter("Id", usersId).Exist(); exist {
if num, err := o.Delete(&models.User{Id: usersId}); err == nil {
beego.Info("Record Deleted. ", num)
flash.Warning("L'utilisateur a bien été supprimé")
} else {
beego.Error("L'utilisateur n'a pu être supprimé. Raison: ", err)
}
} else {
flash.Error("L'utilisateur n'existe pas %d", usersId)
}
flash.Store(&this.Controller)
this.Redirect("/incident-manager/admin/user", 302)
}
开发者ID:kameleon83,项目名称:managIncident,代码行数:26,代码来源:user.go
示例8: Verify
func (c *UserController) Verify() {
c.setupView("user/verify")
flash := beego.NewFlash()
uuid := c.Ctx.Input.Param(":uuid")
user := &models.AuthUser{
Reg_key: uuid,
}
o := orm.NewOrm()
o.Using("default")
errRead := o.Read(user, "Reg_key")
if errRead != nil {
flash.Error("Invalid data!")
flash.Store(&c.Controller)
return
}
user.Reg_key = ""
numRows, errUpdate := o.Update(user, "Reg_key")
if errUpdate != nil {
fmt.Println(errUpdate)
return
}
if numRows > 0 {
flash.Notice("Account verified!")
flash.Store(&c.Controller)
}
}
开发者ID:namilabs,项目名称:namilabs-in-beego,代码行数:27,代码来源:user.go
示例9: EditUser
func (this *AdminController) EditUser() {
o := orm.NewOrm()
o.Using("default")
usersId, _ := strconv.Atoi(this.Ctx.Input.Param(":id"))
users := models.User{}
flash := beego.NewFlash()
err := o.QueryTable("user").Filter("id", usersId).One(&users)
if err != orm.ErrNoRows {
err := this.ParseForm(&users)
if err != nil {
beego.Error("Impossible de parser. Raison: ", err)
} else {
valid := validation.Validation{}
valid.Required(users.Mail, "mail")
valid.Required(users.Role, "role")
isValid, _ := valid.Valid(users)
if this.Ctx.Input.Method() == "POST" {
if !isValid {
flash.Error("Impossible de mettre à jour l'utilisateur")
flash.Store(&this.Controller)
this.Redirect("/incident-manager/admin/user", 302)
} else {
_, err := o.Update(&users)
if err == nil {
flash.Notice("Utilisateur " + users.Mail + " mis à jour")
flash.Store(&this.Controller)
this.Redirect("/incident-manager/admin/user", 302)
} else {
fmt.Println("erreur")
beego.Debug("Mise à jour Impossible dû a : ", err)
}
}
}
}
this.Redirect("/incident-manager/admin/user", 302)
} else {
flash.Notice("Utilisateur %d n'existe pas", usersId)
flash.Store(&this.Controller)
this.Redirect("/incident-manager/", 302)
}
}
开发者ID:kameleon83,项目名称:managIncident,代码行数:60,代码来源:user.go
示例10: Contactsave
func (c *ContactController) Contactsave() {
fmt.Println("Contactsave kick")
var f interface{}
json.Unmarshal(c.Ctx.Input.CopyBody(100), &f)
m := f.(map[string]interface{})
// fmt.Println(m["name"])
// fmt.Println(m["email"])
contact := new(contact.Contact)
contact.Name = m["name"].(string)
contact.Email = m["email"].(string)
err := c.repository.Save(contact)
flash := beego.NewFlash()
if err != nil {
flash.Error("The contact could not be saved. Please, try again.")
} else {
flash.Notice("The contact has been saved.")
}
flash.Store(&c.Controller)
contact2, _ := c.repository.FindAll()
c.Data["json"] = &contact2
c.ServeJSON()
// c.Redirect("/contact", 302)
}
开发者ID:gusa1120,项目名称:beego_sample,代码行数:28,代码来源:default.go
示例11: Signup
func (this *UserController) Signup() {
uid := this.GetSession("Uid")
if uid != nil {
this.Redirect("/", 302)
}
if this.Ctx.Input.Param("0") != "submit" {
this.Redirect("/user/login", 302)
}
user := models.User{
Username: this.GetString("username"),
Password: this.GetString("passkey"),
Name: this.GetString("name"),
College: this.GetString("college"),
Email: this.GetString("email"),
}
// All the fields verified, as well checked if username and email are unique
err := user.SignupVerify()
if err != nil {
flash := beego.NewFlash()
flash.Error(err.Error())
flash.Store(&this.Controller)
}
uid, done := user.Create()
if done {
this.SetSession("Uid", this.GetString("username"))
this.SetSession("id", uid)
this.Redirect("/", 302)
}
this.Redirect("/user/login", 302)
}
开发者ID:JRonak,项目名称:OnlineJudge,代码行数:33,代码来源:UserController.go
示例12: Remove
func (c *Lang) Remove() {
s := T("lang_not_found")
d := M.Lang{}
id, err := strconv.Atoi(c.Ctx.Input.Param(":id"))
if err == nil {
err = DM.DeleteByPkWithFetch(&d, id)
}
if err == nil {
s = T("lang_removed")
err = c.cleanLang(d.Code)
}
if err != nil {
beego.Error(err)
}
if c.IsAjax() {
c.Data["json"] = RJson{s, err == nil}
return
}
flash := beego.NewFlash()
flash.Notice(s)
flash.Store(&c.Controller)
c.Redirect(beego.UrlFor("Lang.Index"), 302)
}
开发者ID:grr89,项目名称:hrkb,代码行数:32,代码来源:lang.go
示例13: DeleteUser
// 删除用户
func (this *UserController) DeleteUser() {
flash := beego.NewFlash()
if checkAccountSession(&this.Controller) {
id := this.Ctx.Input.Param(":id") // /user/:id 删除用户的路径
idNum, err := strconv.ParseInt(id, 10, 64)
if err != nil {
beego.Error("删除用户失败:" + err.Error())
flash.Error("删除用户失败!")
flash.Store(&this.Controller)
return
}
models.DeleteUser(idNum) //删除用户
this.DelSession("user") //清空session
flash.Notice("用户删除成功!")
flash.Store(&this.Controller)
this.Redirect("/", 302) //重定向到主页
return
} else {
flash.Error("您尚未登录,请登录!")
flash.Store(&this.Controller)
this.Redirect("/login", 302) //跳转到登录页
return
}
}
开发者ID:a648132694,项目名称:goblog,代码行数:26,代码来源:user.go
示例14: Get
func (self *EditQuestionHandler) Get() {
self.TplNames = "sdc/edit-question.html"
flash := beego.NewFlash()
qid, _ := self.GetInt(":qid")
if qid_handler, err := model.GetQuestion(qid); err == nil && qid_handler != nil {
uid, _ := self.GetSession("userid").(int64)
role, _ := self.GetSession("userrole").(int64)
allow := bool(false)
if qid_handler.Uid == uid && qid_handler.Id == qid {
allow = true
} else if role < 0 {
allow = true
}
if allow {
self.Data["question"] = *qid_handler
self.Data["inode"], _ = model.GetNode(qid_handler.Nid)
} else {
//没有权限执行该操作则直接跳转到登录页面
self.Redirect("/user/signin/", 302)
}
} else {
flash.Error(fmt.Sprint(err))
flash.Store(&self.Controller)
return
}
}
开发者ID:jango2015,项目名称:sdc,代码行数:34,代码来源:EditQuestionHandler.go
示例15: Get
func (self *EditAnswerHandler) Get() {
self.TplNames = "sdc/edit-answer.html"
flash := beego.NewFlash()
aid, _ := self.GetInt(":aid")
if aid_handler, err := model.GetAnswer(aid); err == nil && aid_handler != nil {
uid, _ := self.GetSession("userid").(int64)
role, _ := self.GetSession("userrole").(int64)
allow := bool(false)
if aid_handler.Uid == uid && aid_handler.Id == aid {
allow = true
} else if role < 0 {
allow = true
}
if allow {
self.Data["answer"] = *aid_handler
} else {
//没有权限执行该操作则直接跳转到登录页面
self.Redirect("/user/signin/", 302)
}
} else {
flash.Error(fmt.Sprint(err))
flash.Store(&self.Controller)
return
}
}
开发者ID:jango2015,项目名称:sdc,代码行数:31,代码来源:EditAnswerHandler.go
示例16: DeleteTopic
// 根据文章id删除文章
func (this *TopicController) DeleteTopic() {
flash := beego.NewFlash()
if checkAccountSession(&this.Controller) { //验证用户是否已登录
id, err := strconv.ParseInt(this.Ctx.Input.Param(":id"), 10, 64)
if err != nil {
beego.Error("转换文章id失败")
flash.Error("删除文章失败!")
flash.Store(&this.Controller)
return
}
if !models.DeleteTopic(id) {
beego.Error("删除文章失败")
flash.Error("删除文章失败!")
flash.Store(&this.Controller)
return
}
this.Redirect("/", 302) //删除成功回首页
return
} else {
flash.Error("您尚未登录,请登录!")
flash.Store(&this.Controller)
this.Redirect("/login", 302) //跳转到登录页
return
}
}
开发者ID:a648132694,项目名称:goblog,代码行数:29,代码来源:topic.go
示例17: Get
func (self *EditAnswerController) Get() {
self.TplNames = "q/edit-answer.html"
self.LayoutSections["Heads"] = "q/head.html"
self.LayoutSections["Scripts"] = "q/scripts.html"
flash := beego.NewFlash()
aid, _ := self.GetInt64(":aid")
a := &models.Reply{Id: aid}
if err := a.Read(); err == orm.ErrNoRows {
flash.Error(fmt.Sprint(err))
flash.Store(&self.Controller)
return
}
uid, _ := self.GetSession("userid").(int64)
role, _ := self.GetSession("userrole").(int64)
if isAllow(a, uid, aid, role) {
q := &models.Question{Id: a.Pid}
if err := q.ReadOneOnly("Title", "Content"); err == orm.ErrNoRows {
flash.Error("对应的问题已删除。")
flash.Store(&self.Controller)
return
}
self.Data["q"] = *q
self.Data["a"] = *a
} else {
//没有权限执行该操作则直接跳转到登录页面
self.Redirect("/u/signin/", 302)
}
}
开发者ID:wcreate,项目名称:lawoto,代码行数:32,代码来源:edit.go
示例18: Write
// 글쓰기 //
func (write *BoardController) Write() {
write.Layout = "admin/layout.html"
write.LayoutSections = make(map[string]string)
write.LayoutSections["Header"] = "board/common/header.html"
write.LayoutSections["Footer"] = "board/common/footer.html"
write.TplNames = "board/write.html"
flash := beego.ReadFromRequest(&write.Controller)
if ok := flash.Data["error"]; ok != "" {
write.Data["flash"] = ok
}
o := orm.NewOrm()
o.Using("default")
board := models.Board{}
if err := write.ParseForm(&board); err != nil {
beego.Error("에러발생 : ", err)
} else {
write.Data["boards"] = board
valid := validation.Validation{}
isValid, _ := valid.Valid(board)
if write.Ctx.Input.Method() == "POST" {
if !isValid {
write.Data["Errors"] = valid.ErrorsMap
beego.Error("폼이 에러")
} else {
searchArticle := models.Board{Idx: board.Idx}
beego.Debug("추가된 게시물 : ", board.Idx)
err = o.Read(&searchArticle)
beego.Debug("Err:", err)
flash := beego.NewFlash()
if err == orm.ErrNoRows || err == orm.ErrMissPK {
beego.Debug("Query 내역 : ", board)
id, err := o.Insert(&board)
if err == nil {
msg := fmt.Sprintf("게시글이 다음과 같은 고유번호로 생성되었다 IDX :", id)
beego.Debug(msg)
flash.Notice(msg)
flash.Store(&write.Controller)
} else {
msg := fmt.Sprintf("다음과 같은 이유로 새로운 게시물을 추가할수 없다. 사유 : ", err)
beego.Debug(msg)
flash.Error(msg)
flash.Store(&write.Controller)
}
// 내용을 Insert후 /board 로 리다이렉트
write.Redirect("/board", 302)
} else {
beego.Debug("Article found matching details supplied. Cannot insert")
}
}
}
}
}
开发者ID:GeoLyu,项目名称:Gopen,代码行数:61,代码来源:board.go
示例19: Login
func (c *LoginController) Login() {
if c.IsLogin {
c.Ctx.Redirect(302, c.UrlFor("UsersController.Index"))
return
}
c.TplNames = "login/login.tpl"
c.Data["xsrfdata"] = template.HTML(c.XsrfFormHtml())
if !c.Ctx.Input.IsPost() {
return
}
flash := beego.NewFlash()
email := c.GetString("Email")
password := c.GetString("Password")
user, err := lib.Authenticate(email, password)
if err != nil || user.Id < 1 {
flash.Warning(err.Error())
flash.Store(&c.Controller)
return
}
flash.Success("Success logged in")
flash.Store(&c.Controller)
c.SetLogin(user)
c.Redirect(c.UrlFor("UsersController.Index"), 303)
}
开发者ID:gusa1120,项目名称:beego_sample,代码行数:32,代码来源:login.go
示例20: GetUserInfo
// 根据用户名查看用户详细信息
func (this *UserController) GetUserInfo() {
flash := beego.NewFlash()
if checkAccountSession(&this.Controller) {
username := this.Ctx.Input.Param(":username") //user/:username
user, err := models.GetUserInfo(username)
if err != nil {
beego.Error("获取用户信息失败:" + err.Error())
flash.Error("获取用户信息失败!")
flash.Store(&this.Controller)
this.Redirect("/", 302)
return
}
if this.GetSession("user") != nil {
user := this.GetSession("user").(*models.User) //从Session中获取用户信息
this.Data["Nickname"] = user.Nickname
this.Data["Username"] = user.Username
this.Data["IsLogin"] = true
}
this.Data["User"] = user
this.TplNames = "user.html"
} else {
flash.Error("您尚未登录,请登录!")
flash.Store(&this.Controller)
this.Redirect("/login", 302) //跳转到登录页
return
}
}
开发者ID:a648132694,项目名称:goblog,代码行数:29,代码来源:user.go
注:本文中的github.com/astaxie/beego.NewFlash函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论