From 2cb2fb3e12ccc7769e97705b858774fc02633bbb Mon Sep 17 00:00:00 2001 From: Yannick Francois Date: Thu, 26 Sep 2013 16:56:54 +0200 Subject: [PATCH] Remove some unnecessary code from note model --- app/controllers/admin/notes_controller.rb | 7 +++---- app/models/note.rb | 10 ++++------ app/views/admin/notes/new.html.erb | 4 ++-- spec/models/note_spec.rb | 21 ++++++++++++--------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/app/controllers/admin/notes_controller.rb b/app/controllers/admin/notes_controller.rb index c3dc5f5e97..4eff85f497 100644 --- a/app/controllers/admin/notes_controller.rb +++ b/app/controllers/admin/notes_controller.rb @@ -3,7 +3,7 @@ module Admin; end class Admin::NotesController < Admin::BaseController layout "administration" cache_sweeper :blog_sweeper - + def index; redirect_to :action => 'new' ; end def new; new_or_edit; end def edit; new_or_edit; end @@ -21,7 +21,6 @@ def get_or_build_status note.text_filter = current_user.default_text_filter note.published = true note.published_at = Time.now - note.push_to_twitter = true end end @@ -51,8 +50,8 @@ def new_or_edit if @note.save flash[:notice] = _("Note was successfully %s.", message) - if params[:note][:push_to_twitter] and params[:note][:push_to_twitter] != "0" and (@note.twitter_id.nil? or @note.twitter_id.empty?) - unless @note.send_to_twitter + if params[:note][:push_to_twitter] && @note.twitter_id.blank? + unless @note.send_to_twitter flash[:notice] = nil flash[:error] = _("Oooops something wrong happened") end diff --git a/app/models/note.rb b/app/models/note.rb index 882b89e6d8..4e76a9a51c 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -7,15 +7,14 @@ class Note < Content serialize :settings, Hash - setting :twitter_id, :string, "" - setting :in_reply_to_status_id, :string, "" - setting :in_reply_to_protected, :boolean, false - setting :in_reply_to_message, :string, "" + setting :twitter_id, :string, "" + setting :in_reply_to_status_id, :string, "" + setting :in_reply_to_protected, :boolean, false + setting :in_reply_to_message, :string, "" belongs_to :user validates_presence_of :body validates_uniqueness_of :permalink, :guid - attr_accessor :push_to_twitter after_create :set_permalink, :shorten_url before_create :create_guid @@ -63,7 +62,6 @@ def twitter_message end def send_to_twitter - return false unless self.push_to_twitter # Then, what are we doing here?! return false unless Blog.default.has_twitter_configured? return false unless self.user.has_twitter_configured? diff --git a/app/views/admin/notes/new.html.erb b/app/views/admin/notes/new.html.erb index a759fd0c67..64c86f6513 100644 --- a/app/views/admin/notes/new.html.erb +++ b/app/views/admin/notes/new.html.erb @@ -13,11 +13,11 @@ <%= _("Publish settings") %> <%= twitter_disabled_message(this_blog, current_user) %> - <%= text_field 'note', 'in_reply_to_status_id', :class => 'input-block-level', :placeholder => _("tweet id like 123456"), disabled: twitter_available?(this_blog, current_user) %> + <%= text_field 'note', 'in_reply_to_status_id', :class => 'input-block-level', :placeholder => _("tweet id like 123456"), disabled: !twitter_available?(this_blog, current_user) %> <%= text_field 'note', 'permalink', :class => 'input-block-level' %>