exports.definition = {
	config : {
		columns : {
			id : "TEXT NOT NULL PRIMARY KEY",
			userName : "TEXT UNIQUE NOT NULL",
			nickName : "TEXT",
			password : "TEXT NOT NULL",
			activeProjectId : "TEXT NOT NULL",
			activeCurrencyId : "TEXT NOT NULL",
			activeAccountId : "TEXT NOT NULL",
			friendAuthorization : "TEXT NOT NULL",
			defaultFriendCategoryId : "TEXT NOT NULL",
			messageBoxId : "TEXT NOT NULL"
			// ,
			// age : "INTEGER",
			// birthday : "TEXT"
		},
		defaults : {
			userName : "",
			friendAuthorization : "required"
		},
		hasMany : {
	    	projects : {type : "Project", attribute : "ownerUser" },
	    	friendCategories : { type : "FriendCategory", attribute : "ownerUser" },
	    	currencies : {type : "Currency", attribute : "ownerUser"},
	    	moneyAccounts : {type : "MoneyAccount", attribute : "ownerUser"}
		},
		belongsTo : {
			activeProject : {type : "Project", attribute : null},
			activeCurrency : {type : "Currency", attribute : null},
			activeAccount : {type : "MoneyAccount", attribute : null},
			defaultFriendCategory : {type : "FriendCategory", attribute : null},
			messageBox : {type : "MessageBox", attribute : null}
		},
		rowView : "user/userRow",
		adapter : {
			collection_name : "User",
			idAttribute : "id",
			type : "sql",
			db_name : "hoyoji"
		}
	},
	extendModel : function(Model) {
		_.extend(Model.prototype, Alloy.Globals.XModel, {
			validators : {
				userName : function(xValidateComplete) {
					if(!this.isNew()){
						if(this.hasChanged("userName")){
							xValidateComplete({ msg : "用户名不能被修改" });
						} 
					}
					xValidateComplete();
				},
				password : function(xValidateComplete) {
					var error;
					if (!this.has("password") || this.get("password").length < 6) {
						error = {
							msg : "请输入至少六位数的密码"
						};
					}
					xValidateComplete(error);
				},
				password2 : function(xValidateComplete) {
					var error;
					if (!this.has("password2") || this.get("password2").length < 6) {
						error = {
							msg : "请输入至少六位数的密码"
						};
					} else if (this.get("password2") !== this.get("password")) {
						error = {
							msg : "两次输入的密码不一样"
						};
					}
					xValidateComplete(error);
				}
			}			
		});
		return Model;
	},
	extendCollection : function(Collection) {
		_.extend(Collection.prototype, Alloy.Globals.XCollection, {
			// extended functions and properties go here
		});
		return Collection;
	}
}

@@ -252,24 +252,29 @@
 %22,%0A%09%09%09active
+Money
 AccountId : 
@@ -984,16 +984,21 @@
 %09%09active
+Money
 Account 

edit user