From 628fed40ea8c2c56b9872bf3894261ffa2e1f1d6 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 20 Apr 2012 23:19:23 +0600 Subject: [PATCH] [refs #90] issue status -> state --- app/assets/javascripts/extra/tracker.js | 2 +- app/controllers/issues_controller.rb | 10 +++++----- app/models/issue.rb | 10 +++++----- app/views/issues/_manage_sidebar.html.haml | 8 ++++---- app/views/issues/_status.html.haml | 4 ++-- app/views/issues/index.html.haml | 4 ++-- config/locales/models/issue.en.yml | 4 ++-- config/locales/models/issue.ru.yml | 4 ++-- db/migrate/20120412173938_create_pull_requests.rb | 2 +- db/schema.rb | 3 +-- spec/factories/issues.rb | 2 +- 11 files changed, 26 insertions(+), 27 deletions(-) diff --git a/app/assets/javascripts/extra/tracker.js b/app/assets/javascripts/extra/tracker.js index 25dc641b6..347da7b98 100644 --- a/app/assets/javascripts/extra/tracker.js +++ b/app/assets/javascripts/extra/tracker.js @@ -90,7 +90,7 @@ $(document).ready(function() { var filter_form = $('#filter_issues'); url = url || filter_form.attr("action"); var label_form = $('#filter_labels'); - var status = 'status=' + $('#issues_status').attr('value'); + var status = 'state=' + $('#issues_status').attr('value'); $.ajax({ type: type_request, url: url, diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 0ce847f58..79b5b33ac 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -11,7 +11,7 @@ class IssuesController < ApplicationController def index(status = 200) @is_assigned_to_me = params[:filter] == 'to_me' - @status = params[:status] == 'closed' ? 'closed' : 'open' + @state = params[:state] == 'closed' ? 'closed' : 'open' @labels = params[:labels] || [] @issues = @project.issues @issues = @issues.where(:assignee_id => current_user.id) if @is_assigned_to_me @@ -22,7 +22,7 @@ class IssuesController < ApplicationController end @opened_issues = @issues.opened.count @closed_issues = @issues.closed.count - @issues = @issues.where(:status => @status) + @issues = @issues.where(:state => @state) @issues = @issues.includes(:assignee, :user).order('serial_id desc').uniq.paginate :per_page => 10, :page => params[:page] @@ -54,10 +54,10 @@ class IssuesController < ApplicationController end def update - if params[:issue] && status = params[:issue][:status] + if params[:issue] && state = params[:issue][:state] action = 'issues/_status' - @issue.set_close(current_user) if status == 'closed' - @issue.set_open if status == 'open' + @issue.set_close(current_user) if state == 'closed' + @issue.set_open if state == 'open' status = 200 if @issue.save render action, :status => (status || 500), :layout => false elsif params[:issue] diff --git a/app/models/issue.rb b/app/models/issue.rb index a37de6b75..dc03018e8 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -21,8 +21,8 @@ class Issue < ActiveRecord::Base attr_accessible :labelings_attributes, :title, :body, :assignee_id accepts_nested_attributes_for :labelings, :allow_destroy => true - scope :opened, where(:status => 'open') - scope :closed, where(:status => 'closed') + scope :opened, where(:state => 'open') + scope :closed, where(:state => 'closed') def assign_uname assignee.uname if assignee @@ -39,18 +39,18 @@ class Issue < ActiveRecord::Base end def closed? - closed_by && closed_at && status == 'closed' + closed_by && closed_at && state == 'closed' end def set_close(closed_by) self.closed_at = Time.now self.closer = closed_by - self.status = 'closed' + self.state = 'closed' end def set_open self.closed_at = self.closed_by = nil - self.status = 'open' + self.state = 'open' end def collect_recipient_ids diff --git a/app/views/issues/_manage_sidebar.html.haml b/app/views/issues/_manage_sidebar.html.haml index 1d0c5a877..a519d9470 100644 --- a/app/views/issues/_manage_sidebar.html.haml +++ b/app/views/issues/_manage_sidebar.html.haml @@ -2,13 +2,13 @@ - can_manage = can?(:update, @issue) && @issue.persisted? || @issue.new_record? - if @issue.persisted? .bordered.nopadding - %h3=t('activerecord.attributes.issue.status') + %h3=t('activerecord.attributes.issue.state') #switcher.issue_status{:class => "#{@issue.closed? ? 'switcher-off' : 'switcher'} #{can_manage ? "switch_issue_status" : ''}"} - .swleft=t('layout.issues.status.open') - .swright=t('layout.issues.status.closed') + .swleft=t('layout.issues.state.open') + .swright=t('layout.issues.state.closed') - if can_manage =form_tag [@project, @issue], :id => 'update_issue_status', :method => :put do - =hidden_field_tag "issue_status", @issue.closed? ? 'closed' : 'open', :name => "issue[status]" + =hidden_field_tag "issue_status", @issue.closed? ? 'closed' : 'open', :name => "issue[state]" .bordered.nopadding %h3=t('layout.issues.assignee') - if @issue.persisted? diff --git a/app/views/issues/_status.html.haml b/app/views/issues/_status.html.haml index 1975e359c..6aa5692a9 100644 --- a/app/views/issues/_status.html.haml +++ b/app/views/issues/_status.html.haml @@ -1,7 +1,7 @@ #closed_issue_text - - if @issue.status == 'closed' && @issue.closed_at && @issue.closed_by + - if @issue.state == 'closed' && @issue.closed_at && @issue.closed_by #closed-comment.comment-closed{:style => 'display: block;'} - .state=t('layout.issues.status.closed') + .state=t('layout.issues.state.closed') .text .avatar= image_tag(avatar_url(@issue.closer), :alt => 'avatar') .name="#{@issue.closer.uname} (#{@issue.closer.name}) #{t('layout.issues.at')} #{@issue.closed_at.to_s(:long)}" diff --git a/app/views/issues/index.html.haml b/app/views/issues/index.html.haml index 8214fcccd..644541cf8 100644 --- a/app/views/issues/index.html.haml +++ b/app/views/issues/index.html.haml @@ -3,12 +3,12 @@ -render :partial => 'issues/index_sidebar' #closed-switcher.blue-switcher - =hidden_field_tag :issues_status, @status, :id => 'issues_status' + =hidden_field_tag :issues_status, @state, :id => 'issues_status' .open ="#{t('layout.issues.statuses.open')} (#{@opened_issues})" #closed-tasks.closed ="#{t('layout.issues.statuses.closed')} (#{@closed_issues})" - #blue-switch-select.selected{:style => "margin-left: #{@status == 'open' ? '0' : '130'}px;"} + #blue-switch-select.selected{:style => "margin-left: #{@state == 'open' ? '0' : '130'}px;"} .both .both #table1 diff --git a/config/locales/models/issue.en.yml b/config/locales/models/issue.en.yml index bb6b3111d..62a44cbe8 100644 --- a/config/locales/models/issue.en.yml +++ b/config/locales/models/issue.en.yml @@ -7,7 +7,7 @@ en: assignee: Assigned assignee_id: Assigned project: Project - status: Status + state: Status layout: issues: @@ -27,7 +27,7 @@ en: open: Open closed: Closed any: Any - status: + state: open: Open closed: Closed subscribe: Subscribe to notifications diff --git a/config/locales/models/issue.ru.yml b/config/locales/models/issue.ru.yml index 74745f91c..b1174dde5 100644 --- a/config/locales/models/issue.ru.yml +++ b/config/locales/models/issue.ru.yml @@ -7,7 +7,7 @@ ru: assignee: Назначена assignee_id: Назначена project: Проект - status: Статус + state: Статус layout: issues: @@ -27,7 +27,7 @@ ru: open: Открытые closed: Закрытые any: Все - status: + state: open: Открыто closed: Закрыто subscribe: Подписка на уведомления diff --git a/db/migrate/20120412173938_create_pull_requests.rb b/db/migrate/20120412173938_create_pull_requests.rb index 8b8b15fdc..851272f37 100644 --- a/db/migrate/20120412173938_create_pull_requests.rb +++ b/db/migrate/20120412173938_create_pull_requests.rb @@ -1,7 +1,7 @@ class CreatePullRequests < ActiveRecord::Migration def change add_column :issues, :type, :string - add_column :issues, :state, :string + rename_column :issues, :status, :state add_column :issues, :data, :text, :null => false, :default => 0 end end diff --git a/db/schema.rb b/db/schema.rb index 7d911ec3d..28d92d517 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -140,14 +140,13 @@ ActiveRecord::Schema.define(:version => 20120418100619) do t.integer "assignee_id" t.string "title" t.text "body" - t.string "status", :default => "open" + t.string "state", :default => "open" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.integer "user_id" t.datetime "closed_at" t.integer "closed_by" t.string "type" - t.string "state" t.text "data", :default => "0", :null => false end diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb index a76caea56..a4da02cef 100644 --- a/spec/factories/issues.rb +++ b/spec/factories/issues.rb @@ -6,6 +6,6 @@ FactoryGirl.define do association :project, :factory => :project association :user, :factory => :user association :assignee, :factory => :user - status "open" + state "open" end end