Permalink
Browse files

Model.get_safe_attributes_names and Model.get_attributes_description …

…is removed
  • Loading branch information...
1 parent c649977 commit fbd9996304ee8f419f822b3bd275a7b0535604d8 @jifeon committed Apr 30, 2012
View
12 demos/blog/models/comment.js
@@ -12,17 +12,11 @@ Comment.prototype.get_table_name = function () {
};
-Comment.prototype.get_safe_attributes_names = function () {
- return [ 'text' ];
-};
-
-
Comment.prototype.attributes = function(){
return {
- 'user_id' : [ 'required' ],
- 'post_id' : [ 'required' ],
- 'text' : [
- 'required',
+ 'user_id post_id' : 'required',
+ 'text' : [
+ 'safe required',
{ max_length : 1024 }
]
};
View
13 demos/blog/models/post.js
@@ -22,22 +22,15 @@ Post.prototype.relations = function () {
};
-Post.prototype.get_safe_attributes_names = function () {
- return ['name', 'description'];
-};
-
-
Post.prototype.attributes = function(){
return {
- user_id : [
- 'required'
- ],
+ user_id : 'required',
name : [
- 'required',
+ 'safe required',
{ "max_length" : 256 }
],
description : [
- 'required',
+ 'safe required',
{ "max_length" : 4096 }
]
};
View
9 demos/blog/models/user.js
@@ -11,17 +11,12 @@ User.prototype.get_table_name = function(){
}
-User.prototype.get_safe_attributes_names = function () {
- return ['login', 'pass'];
-};
-
-
User.prototype.attributes = function(){
return {
login : [
- 'required',
+ 'safe required',
{ range_length : [4, 30] }
],
- pass : 'required md5'
+ pass : 'safe required md5'
};
}
View
27 framework/base/model.js
@@ -82,6 +82,11 @@ Model.prototype.create_attribute = function( attr, description ){
};
+Model.prototype.remove_attribute = function(){
+
+};
+
+
Model.prototype.set_attribute = function ( name, value, do_filters ) {
var descriptor = this._[name];
descriptor.value = do_filters !== false
@@ -215,28 +220,6 @@ Model.prototype.remove = function ( callback ) {
};
-Model.prototype.get_safe_attributes_names = function () {
- if ( !this._safe_attributes ) this._process_attributes();
-
- this.get_safe_attributes_names = function(){
- return this._safe_attributes;
- }
-
- return this.get_safe_attributes_names();
-};
-
-
-Model.prototype.get_attributes_description = function(){
- if ( !this._attr_description ) this._process_attributes();
-
- this.get_attributes_description = function(){
- return this._attr_description;
- }
-
- return this.get_attributes_description();
-};
-
-
Model.prototype.equals = function ( model ) {
if ( this.constructor != model.constructor ) return false;
View
8 tests/applications/ar_app/models/post.js
@@ -10,9 +10,11 @@ Post.prototype.get_table_name = function(){
}
-Post.prototype.get_safe_attributes_names = function(){
- return [ 'title' ];
-}
+Post.prototype.attributes = function(){
+ return {
+ title : 'safe'
+ }
+};
Post.prototype.relations = function(){
View
8 tests/applications/ar_app/models/post_ext.js
@@ -20,9 +20,11 @@ PostExt.prototype.get_table_name = function(){
}
-PostExt.prototype.get_safe_attributes_names = function(){
- return [ 'title' ];
-}
+PostExt.prototype.attributes = function(){
+ return {
+ title : 'safe'
+ }
+};
PostExt.prototype.relations = function () {
View
10 tests/applications/normal_app/models/test_model.js
@@ -1,16 +1,18 @@
module.exports = TestModel.inherits( autodafe.Model );
-TestModel.prototype.get_safe_attributes_names = function(){
- return [ 'param1', 'param2' ];
-}
-
function TestModel( params ) {
this._init( params );
this.param = params.param || 42;
this.param1 = 33;
}
+TestModel.prototype.attributes = function(){
+ return {
+ 'param1 param2' : 'safe'
+ }
+}
+
TestModel.prototype.test = function () {
return this.param;
};
View
6 tests/applications/old_test_app/models/ui_test.js
@@ -11,8 +11,10 @@ function UITest( params ) {
});
}
-UITest.prototype.get_safe_attributes_names = function(){
- return [ 'p1', 'p2' ];
+UITest.prototype.attributes = function(){
+ return {
+ 'p1 p2' : 'safe'
+ };
}
UITest.user_rights = {

0 comments on commit fbd9996

Please sign in to comment.