func (self *loadhabitrequestsController) Get(sn *session.Session) {
	habit := new(model.Habit)
	ret_val := returnVal{}
	if !sn.IsLogin {
		ret_val.Status = Fail
		ret_val.Content = RequireLogin
	} else {
		habit.UserId = sn.Cache.Values.User_id
		if requests, err := habit.LoadHabitInvitation(); err != nil {
			ret_val.Status = Fail
			ret_val.Content = err.Error()
		} else {
			ret_val.Status = Success
			for _, value := range requests {
				ret_val.Content += fmt.Sprintf("%d:%s:%s=", value.Id, value.Content, value.Username)
			}
		}
	}
	self.Controller.Respond(sn.ResponseWriter, "json", ret_val, nil)
}
func (self *newhabitController) Post(sn *session.Session) {
	habit := new(model.Habit)
	ret_val := returnVal{}
	if err := form2Struct(sn.Request.Form, habit); err != nil {
		ret_val.Status = Fail
		ret_val.Content = err.Error()
	} else {
		habit.UserId = sn.Cache.Values.User_id
		if habit.FriendId == 0 {
			habit.FriendId = habit.UserId
			habit.Approved = true
		}
		if err := habit.Create(); err != nil {
			ret_val.Status = Fail
			ret_val.Content = err.Error()
		} else {
			ret_val.Status = Success
			ret_val.Content = fmt.Sprintf("%d:%s:%d", habit.Id, habit.Content, habit.Progress)
		}
	}
	self.Controller.Respond(sn.ResponseWriter, "json", ret_val, nil)
}
func (self *checkinhabitController) Post(sn *session.Session) {
	habit := new(model.Habit)
	ret_val := returnVal{}
	if !sn.IsLogin {
		ret_val.Status = Fail
		ret_val.Content = RequireLogin
	} else {
		if err := form2Struct(sn.Request.Form, habit); err != nil {
			ret_val.Status = Fail
			ret_val.Content = err.Error()
		} else {
			habit.UserId = sn.Cache.Values.User_id
			if err := habit.Update(); err != nil {
				ret_val.Status = Fail
				ret_val.Content = err.Error()
			} else {
				ret_val.Status = Success
				ret_val.Content = strconv.Itoa(habit.Id)
			}
		}
	}
	self.Controller.Respond(sn.ResponseWriter, "json", ret_val, nil)
}