diff --git a/Gemfile.lock b/Gemfile.lock index b3bfbf37d..81a1c6c7a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -336,9 +336,9 @@ GEM faraday (~> 0.9) jwt (~> 1.5) multi_json (~> 1.10) - simple_form (3.1.0) - actionpack (~> 4.0) - activemodel (~> 4.0) + simple_form (3.3.1) + actionpack (> 4, < 5.1) + activemodel (> 4, < 5.1) simple_oauth (0.3.1) simplecov (0.10.0) docile (~> 1.1.0) diff --git a/app/assets/stylesheets/common/simple_form.css.scss b/app/assets/stylesheets/common/simple_form.css.scss index 11d44233f..ee64e96a6 100644 --- a/app/assets/stylesheets/common/simple_form.css.scss +++ b/app/assets/stylesheets/common/simple_form.css.scss @@ -5,6 +5,7 @@ form.simple_form { label { display: inline; vertical-align: middle; + margin-left: 0.5em; } } diff --git a/app/controllers/wiki_pages_controller.rb b/app/controllers/wiki_pages_controller.rb index 383f48c87..daed5b0d6 100644 --- a/app/controllers/wiki_pages_controller.rb +++ b/app/controllers/wiki_pages_controller.rb @@ -1,7 +1,7 @@ class WikiPagesController < ApplicationController respond_to :html, :xml, :json, :js before_filter :member_only, :except => [:index, :show, :show_or_new] - before_filter :moderator_only, :only => [:destroy] + before_filter :builder_only, :only => [:destroy] before_filter :normalize_search_params, :only => [:index] rescue_from ActiveRecord::StatementInvalid, :with => :rescue_exception rescue_from ActiveRecord::RecordNotFound, :with => :rescue_exception @@ -61,7 +61,7 @@ class WikiPagesController < ApplicationController def destroy @wiki_page = WikiPage.find(params[:id]) - @wiki_page.destroy + @wiki_page.update_attribute(:is_deleted, true) respond_with(@wiki_page) end diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index f32699763..1021f8c36 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -6,14 +6,13 @@ class WikiPage < ActiveRecord::Base before_validation :initialize_creator, :on => :create before_validation :initialize_updater after_save :create_version - before_destroy :create_mod_action_for_destroy belongs_to :creator, :class_name => "User" belongs_to :updater, :class_name => "User" validates_uniqueness_of :title, :case_sensitive => false validates_presence_of :title - validate :validate_locker_is_moderator + validate :validate_locker_is_builder validate :validate_not_locked - attr_accessible :title, :body, :is_locked, :other_names + attr_accessible :title, :body, :is_locked, :is_deleted, :other_names has_one :tag, :foreign_key => "name", :primary_key => "title" has_one :artist, lambda {where(:is_active => true)}, :foreign_key => "name", :primary_key => "title" has_many :versions, lambda {order("wiki_page_versions.id ASC")}, :class_name => "WikiPageVersion", :dependent => :destroy @@ -23,6 +22,10 @@ class WikiPage < ActiveRecord::Base where("title = ?", title.mb_chars.downcase.tr(" ", "_")) end + def active + where("is_deleted = false") + end + def recent order("updated_at DESC").limit(25) end @@ -65,6 +68,10 @@ class WikiPage < ActiveRecord::Base q = q.where("creator_id = (select _.id from users _ where lower(_.name) = ?)", params[:creator_name].tr(" ", "_").mb_chars.downcase) end + if params[:hide_deleted] =~ /y/i + q = q.where("is_deleted = false") + end + if params[:other_names_present] == "yes" q = q.where("other_names is not null and other_names != ''") elsif params[:other_names_present] == "no" @@ -114,15 +121,15 @@ class WikiPage < ActiveRecord::Base titled(title).select("title, id").first end - def validate_locker_is_moderator - if is_locked_changed? && !CurrentUser.is_moderator? - errors.add(:is_locked, "can be modified by moderators only") + def validate_locker_is_builder + if is_locked_changed? && !CurrentUser.is_builder? + errors.add(:is_locked, "can be modified by builders only") return false end end def validate_not_locked - if is_locked? && !CurrentUser.is_moderator? + if is_locked? && !CurrentUser.is_builder? errors.add(:is_locked, "and cannot be updated") return false end @@ -187,12 +194,13 @@ class WikiPage < ActiveRecord::Base :title => title, :body => body, :is_locked => is_locked, + :is_deleted => is_deleted, :other_names => other_names ) end def create_version - if title_changed? || body_changed? || is_locked_changed? || other_names_changed? + if title_changed? || body_changed? || is_locked_changed? || is_deleted_changed? || other_names_changed? if merge_version? merge_version else @@ -231,12 +239,8 @@ class WikiPage < ActiveRecord::Base end.map {|x| x.mb_chars.downcase.tr(" ", "_").to_s} end - def create_mod_action_for_destroy - ModAction.create(:description => "permanently deleted wiki page [[#{title}]]") - end - def visible? - artist.blank? || !artist.is_banned? || CurrentUser.is_moderator? + artist.blank? || !artist.is_banned? || CurrentUser.is_builder? end def other_names_array diff --git a/app/models/wiki_page_version.rb b/app/models/wiki_page_version.rb index 962d13a7f..5e580061d 100644 --- a/app/models/wiki_page_version.rb +++ b/app/models/wiki_page_version.rb @@ -41,7 +41,7 @@ class WikiPageVersion < ActiveRecord::Base end def visible? - artist.blank? || !artist.is_banned? || CurrentUser.is_moderator? + artist.blank? || !artist.is_banned? || CurrentUser.is_builder? end def other_names_array diff --git a/app/views/wiki_page_versions/index.html.erb b/app/views/wiki_page_versions/index.html.erb index 3f6811454..21e352480 100644 --- a/app/views/wiki_page_versions/index.html.erb +++ b/app/views/wiki_page_versions/index.html.erb @@ -15,6 +15,7 @@