def require_allow_write_gpx
require_capability(:allow_write_gpx)
end
+ def require_allow_write_notes
+ require_capability(:allow_write_notes)
+ end
##
# require that the user is a moderator, or fill out a helpful error message
before_filter :setup_user_auth, :only => [:create, :comment]
before_filter :authorize, :only => [:close, :destroy]
before_filter :check_api_writable, :only => [:create, :comment, :close, :destroy]
+ before_filter :require_allow_write_notes, :only => [:create, :comment, :close, :destroy]
before_filter :set_locale, :only => [:mine]
after_filter :compress_output
around_filter :api_call_handle_error, :api_call_timeout
attr_accessible :name, :url, :support_url, :callback_url,
:allow_read_prefs, :allow_write_prefs,
:allow_write_diary, :allow_write_api,
- :allow_read_gpx, :allow_write_gpx
+ :allow_read_gpx, :allow_write_gpx,
+ :allow_write_notes
before_validation :generate_keys, :on => :create
# have to say up-front what permissions they want and when users sign up they
# can agree or not agree to each of them.
PERMISSIONS = [:allow_read_prefs, :allow_write_prefs, :allow_write_diary,
- :allow_write_api, :allow_read_gpx, :allow_write_gpx ]
+ :allow_write_api, :allow_read_gpx, :allow_write_gpx,
+ :allow_write_notes]
def generate_keys
self.key = OAuth::Helper.generate_key(40)[0,40]
--- /dev/null
+class AddWriteNotesPermission < ActiveRecord::Migration
+ def up
+ add_column :oauth_tokens, :allow_write_notes, :boolean, :null => false, :default => false
+ add_column :client_applications, :allow_write_notes, :boolean, :null => false, :default => false
+ end
+
+ def down
+ remove_column :client_applications, :allow_write_notes
+ remove_column :oauth_tokens, :allow_write_notes
+ end
+end
allow_write_diary boolean DEFAULT false NOT NULL,
allow_write_api boolean DEFAULT false NOT NULL,
allow_read_gpx boolean DEFAULT false NOT NULL,
- allow_write_gpx boolean DEFAULT false NOT NULL
+ allow_write_gpx boolean DEFAULT false NOT NULL,
+ allow_write_notes boolean DEFAULT false NOT NULL
);
callback_url character varying(255),
verifier character varying(20),
scope character varying(255),
- valid_to timestamp without time zone
+ valid_to timestamp without time zone,
+ allow_write_notes boolean DEFAULT false NOT NULL
);
INSERT INTO schema_migrations (version) VALUES ('20121203124841');
+INSERT INTO schema_migrations (version) VALUES ('20130328184137');
+
INSERT INTO schema_migrations (version) VALUES ('21');
INSERT INTO schema_migrations (version) VALUES ('22');