From 11c67fb07dc1a6216888a4c74a200750dd76e41c Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 29 May 2012 16:09:37 +0600 Subject: [PATCH] Revert "[refs #90] issue status -> state" & changed state -> status This reverts commit 7470ee76e4783a0fbbd98607406d7b770a2980d1. Conflicts: app/controllers/projects/issues_controller.rb db/migrate/20120412173938_create_pull_requests.rb db/schema.rb --- app/assets/javascripts/extra/tracker.js | 2 +- app/controllers/projects/issues_controller.rb | 4 ++-- .../projects/pull_requests_controller.rb | 6 +++--- app/models/ability.rb | 2 +- app/models/issue.rb | 10 +++++----- app/models/pull_request.rb | 12 ++++++------ .../projects/issues/_manage_sidebar.html.haml | 8 ++++---- app/views/projects/issues/_status.html.haml | 4 ++-- app/views/projects/issues/index.html.haml | 4 ++-- app/views/projects/pull_requests/new.html.haml | 6 +++--- app/views/projects/pull_requests/show.html.haml | 4 ++-- config/locales/models/issue.en.yml | 4 ++-- config/locales/models/issue.ru.yml | 4 ++-- .../20120412173938_create_pull_requests.rb | 2 -- db/schema.rb | 16 +++++++--------- spec/factories/issues.rb | 2 +- 16 files changed, 43 insertions(+), 47 deletions(-) diff --git a/app/assets/javascripts/extra/tracker.js b/app/assets/javascripts/extra/tracker.js index 347da7b98..25dc641b6 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 = 'state=' + $('#issues_status').attr('value'); + var status = 'status=' + $('#issues_status').attr('value'); $.ajax({ type: type_request, url: url, diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 82bbbbc6b..b975fd3a4 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -11,7 +11,7 @@ class Projects::IssuesController < Projects::BaseController def index(status = 200) @is_assigned_to_me = params[:filter] == 'to_me' - @state = params[:state] == 'closed' ? 'closed' : 'open' + @status = params[:status] == '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 Projects::IssuesController < Projects::BaseController end @opened_issues = @issues.opened.count @closed_issues = @issues.closed.count - @issues = @issues.where(:state => @state) + @issues = @issues.where(:status => @status) @issues = @issues.includes(:assignee, :user).order('serial_id desc').uniq.paginate :per_page => 10, :page => params[:page] diff --git a/app/controllers/projects/pull_requests_controller.rb b/app/controllers/projects/pull_requests_controller.rb index f05b59f1f..7f3021e63 100644 --- a/app/controllers/projects/pull_requests_controller.rb +++ b/app/controllers/projects/pull_requests_controller.rb @@ -18,8 +18,8 @@ class Projects::PullRequestsController < Projects::BaseController @pull.head_project = @project @pull.base_ref = (params[:pull_request][:base_ref].presence if params[:pull_request]) || @pull.base_project.default_branch @pull.head_ref = params[:treeish].presence || (params[:pull_request][:head_ref].presence if params[:pull_request]) || @pull.head_project.default_branch - @pull.state = @pull.soft_check - if @pull.state == 'already' + @pull.status = @pull.soft_check + if @pull.status == 'already' flash[:warning] = I18n.t('projects.pull_requests.up_to_date', :base_ref => @pull.base_ref, :head_ref => @pull.head_ref) else repo = Git::Repository.new(@pull.path) @@ -39,7 +39,7 @@ class Projects::PullRequestsController < Projects::BaseController if @pull.save @pull.check - if @pull.state == 'already' + if @pull.status == 'already' @pull.destroy @pull.errors.add(:head_ref, I18n.t('projects.pull_requests.up_to_date', :base_ref => @pull.base_ref, :head_ref => @pull.head_ref)) diff --git a/app/models/ability.rb b/app/models/ability.rb index 4b3536741..e5dc01c19 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -116,7 +116,7 @@ class Ability can(:update, Comment) {|comment| comment.user_id == user.id or local_admin?(comment.project || comment.commentable.project)} cannot :manage, Comment, :commentable_type => 'Issue', :commentable => {:project => {:has_issues => false}} # switch off issues - can [:merge], PullRequest, :state => 'ready' + can [:merge], PullRequest, :status => 'ready' end # Shared cannot rights for all users (registered, admin) diff --git a/app/models/issue.rb b/app/models/issue.rb index c2956b1ad..01f882010 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(:state => 'open') - scope :closed, where(:state => 'closed') + scope :opened, where(:status => 'open') + scope :closed, where(:status => 'closed') def assign_uname assignee.uname if assignee @@ -39,18 +39,18 @@ class Issue < ActiveRecord::Base end def closed? - closed_by && closed_at && state == 'closed' + closed_by && closed_at && status == 'closed' end def set_close(closed_by) self.closed_at = Time.now self.closer = closed_by - self.state = 'closed' + self.status = 'closed' end def set_open self.closed_at = self.closed_by = nil - self.state = 'open' + self.status = 'open' end def collect_recipient_ids diff --git a/app/models/pull_request.rb b/app/models/pull_request.rb index dabb87eb9..273aca546 100644 --- a/app/models/pull_request.rb +++ b/app/models/pull_request.rb @@ -2,7 +2,7 @@ class PullRequest < ActiveRecord::Base belongs_to :issue, :autosave => true, :dependent => :destroy, :touch => true, :validate => true belongs_to :base_project, :class_name => 'Project', :foreign_key => 'base_project_id' belongs_to :head_project, :class_name => 'Project', :foreign_key => 'head_project_id' - delegate :user, :title, :body, :serial_id, :assignee, :state, :to => :issue, :allow_nil => true + delegate :user, :title, :body, :serial_id, :assignee, :status, :to => :issue, :allow_nil => true accepts_nested_attributes_for :issue #attr_accessible #FIXME disable for development validate :uniq_merge @@ -16,9 +16,9 @@ class PullRequest < ActiveRecord::Base before_create :clean_dir after_destroy :clean_dir - scope :needed_checking, includes(:issue).where(:issues => {:state => ['open', 'blocked', 'ready', 'already']}) + scope :needed_checking, includes(:issue).where(:issues => {:status => ['open', 'blocked', 'ready', 'already']}) - state_machine :initial => :open do + state_machine :status, :initial => :open do #after_transition [:ready, :blocked] => [:merged, :closed] do |pull, transition| # FileUtils.rm_rf(pull.path) # What about diff? #end @@ -48,12 +48,12 @@ class PullRequest < ActiveRecord::Base end end - def state=(value) - issue.state = value + def status=(value) + issue.status = value end def can_merge? - state == 'ready' + status == 'ready' end def check diff --git a/app/views/projects/issues/_manage_sidebar.html.haml b/app/views/projects/issues/_manage_sidebar.html.haml index 6b01c3065..7568765e7 100644 --- a/app/views/projects/issues/_manage_sidebar.html.haml +++ b/app/views/projects/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.state') + %h3=t('activerecord.attributes.issue.status') #switcher.issue_status{:class => "#{@issue.closed? ? 'switcher-off' : 'switcher'} #{can_manage ? "switch_issue_status" : ''}"} - .swleft=t('layout.issues.state.open') - .swright=t('layout.issues.state.closed') + .swleft=t('layout.issues.status.open') + .swright=t('layout.issues.status.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[state]" + =hidden_field_tag "issue_status", @issue.closed? ? 'closed' : 'open', :name => "issue[status]" .bordered.nopadding %h3=t('layout.issues.assignee') - if @issue.persisted? diff --git a/app/views/projects/issues/_status.html.haml b/app/views/projects/issues/_status.html.haml index 6aa5692a9..1975e359c 100644 --- a/app/views/projects/issues/_status.html.haml +++ b/app/views/projects/issues/_status.html.haml @@ -1,7 +1,7 @@ #closed_issue_text - - if @issue.state == 'closed' && @issue.closed_at && @issue.closed_by + - if @issue.status == 'closed' && @issue.closed_at && @issue.closed_by #closed-comment.comment-closed{:style => 'display: block;'} - .state=t('layout.issues.state.closed') + .state=t('layout.issues.status.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/projects/issues/index.html.haml b/app/views/projects/issues/index.html.haml index 9a9233cd7..02c05d53f 100644 --- a/app/views/projects/issues/index.html.haml +++ b/app/views/projects/issues/index.html.haml @@ -3,12 +3,12 @@ -render 'index_sidebar' #closed-switcher.blue-switcher - =hidden_field_tag :issues_status, @state, :id => 'issues_status' + =hidden_field_tag :issues_status, @status, :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: #{@state == 'open' ? '0' : '130'}px;"} + #blue-switch-select.selected{:style => "margin-left: #{@status == 'open' ? '0' : '130'}px;"} .both .both #table1 diff --git a/app/views/projects/pull_requests/new.html.haml b/app/views/projects/pull_requests/new.html.haml index c2b795525..e4c53495d 100644 --- a/app/views/projects/pull_requests/new.html.haml +++ b/app/views/projects/pull_requests/new.html.haml @@ -7,7 +7,7 @@ %a{"data-toggle" => "tab", :href => "##{base}"}=title .tab-content.pull_diff_fix #discussion.tab-pane.active - =form_for @pull, :url => (@pull.state != 'already' ? project_pull_requests_path : new_project_pull_requests_path), :html => {:class => 'well well-large'} do |f| + =form_for @pull, :url => (@pull.status != 'already' ? project_pull_requests_path : new_project_pull_requests_path), :html => {:class => 'well well-large'} do |f| .leftlist=f.label :base_project, t('.base_project'), :class => :label .rightlist = @pull.base_project.full_name @@ -35,10 +35,10 @@ .both .leftlist for debug - .rightlist=@pull.state + .rightlist=@pull.status .both .leftlist - .rightlist=f.submit t(@pull.state != 'already' ? '.submit' : '.update'), :class => 'btn btn-primary disabled', 'data-loading-text' => t('layout.processing')#, :id => 'create_pull' + .rightlist=f.submit t(@pull.status != 'already' ? '.submit' : '.update'), :class => 'btn btn-primary disabled', 'data-loading-text' => t('layout.processing')#, :id => 'create_pull' .both #diff.tab-pane diff --git a/app/views/projects/pull_requests/show.html.haml b/app/views/projects/pull_requests/show.html.haml index aab1bde29..b42a8a4bd 100644 --- a/app/views/projects/pull_requests/show.html.haml +++ b/app/views/projects/pull_requests/show.html.haml @@ -25,8 +25,8 @@ .leftlist=t('activerecord.attributes.issue.body') .rightlist=@pull.issue.body .both - .leftlist=t('activerecord.attributes.issue.state') - .rightlist=@pull.issue.state + .leftlist=t('activerecord.attributes.issue.status') + .rightlist=@pull.issue.status .both - if can? :merge, @pull =form_for PullRequest.new, :url => merge_project_pull_request_path(@project, @pull), :html => { :method => :put, :class => :form } do |f| diff --git a/config/locales/models/issue.en.yml b/config/locales/models/issue.en.yml index 62a44cbe8..bb6b3111d 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 - state: Status + status: Status layout: issues: @@ -27,7 +27,7 @@ en: open: Open closed: Closed any: Any - state: + status: 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 b1174dde5..74745f91c 100644 --- a/config/locales/models/issue.ru.yml +++ b/config/locales/models/issue.ru.yml @@ -7,7 +7,7 @@ ru: assignee: Назначена assignee_id: Назначена project: Проект - state: Статус + status: Статус layout: issues: @@ -27,7 +27,7 @@ ru: open: Открытые closed: Закрытые any: Все - state: + status: open: Открыто closed: Закрыто subscribe: Подписка на уведомления diff --git a/db/migrate/20120412173938_create_pull_requests.rb b/db/migrate/20120412173938_create_pull_requests.rb index d881370e0..618ccef61 100644 --- a/db/migrate/20120412173938_create_pull_requests.rb +++ b/db/migrate/20120412173938_create_pull_requests.rb @@ -1,7 +1,5 @@ class CreatePullRequests < ActiveRecord::Migration def change - rename_column :issues, :status, :state - create_table :pull_requests do |t| t.integer :issue_id, :null => false t.integer :base_project_id, :null => false diff --git a/db/schema.rb b/db/schema.rb index 8887b72ce..216d2d891 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -17,8 +17,8 @@ ActiveRecord::Schema.define(:version => 20120515095324) do t.integer "user_id", :null => false t.string "kind" t.text "data" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "advisories", :force => true do |t| @@ -182,7 +182,7 @@ ActiveRecord::Schema.define(:version => 20120515095324) do t.integer "assignee_id" t.string "title" t.text "body" - t.string "state", :default => "open" + t.string "status", :default => "open" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.integer "user_id" @@ -373,9 +373,8 @@ ActiveRecord::Schema.define(:version => 20120515095324) do create_table "users", :force => true do |t| t.string "name" - t.string "email", :default => "", :null => false - t.string "encrypted_password", :limit => 128, :default => "", :null => false - t.string "password_salt", :default => "", :null => false + t.string "email", :default => "", :null => false + t.string "encrypted_password", :default => "", :null => false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" @@ -384,12 +383,11 @@ ActiveRecord::Schema.define(:version => 20120515095324) do t.text "ssh_key" t.string "uname" t.string "role" - t.string "language", :default => "en" + t.string "language", :default => "en" + t.integer "own_projects_count", :default => 0, :null => false t.string "confirmation_token" t.datetime "confirmed_at" t.datetime "confirmation_sent_at" - t.integer "own_projects_count", :default => 0, :null => false - t.datetime "reset_password_sent_at" t.text "professional_experience" t.string "site" t.string "company" diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb index a4da02cef..a76caea56 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 - state "open" + status "open" end end