diff --git a/app/models/ability.rb b/app/models/ability.rb index fd55d4291..6a0d2d96c 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -17,7 +17,7 @@ class Ability can :archive, Project, :visibility => 'open' can :read, Issue, :project => {:visibility => 'open'} can :search, BuildList - can :read, BuildList, :project => {:visibility => 'open'} + can [:read, :everything], BuildList, :project => {:visibility => 'open'} can :read, ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work can :read, Advisory can(:advisories, Platform) {APP_CONFIG['anonymous_access']} @@ -62,10 +62,10 @@ class Ability can(:destroy, Project) {|project| project.owner_type == 'Group' and project.owner.actors.exists?(:actor_type => 'User', :actor_id => user.id, :role => 'admin')} can :remove_user, Project - can [:read, :owned], BuildList, :user_id => user.id - can [:read, :related], BuildList, :project => {:owner_type => 'User', :owner_id => user.id} - can [:read, :related], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids} - can(:read, BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project} + can [:read, :owned, :everything], BuildList, :user_id => user.id + can [:read, :related, :everything], BuildList, :project => {:owner_type => 'User', :owner_id => user.id} + can [:read, :related, :everything], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids} + can([:read, :everything], BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project} can([:create, :update], BuildList) {|build_list| build_list.project.is_package && can?(:write, build_list.project)} can(:publish, BuildList) do |build_list| diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 3df87673d..1349f8b6b 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -106,14 +106,16 @@ class BuildList < ActiveRecord::Base # WTF? around_transition -> infinite loop before_transition do |build_list, transition| - if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(build_list.status) - MassBuild.decrement_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id + status = BuildList::HUMAN_STATUSES[build_list.status] + if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status) + MassBuild.decrement_counter "#{status.to_s}_count", build_list.mass_build_id end end after_transition do |build_list, transition| - if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(build_list.status) - MassBuild.increment_counter "#{BuildList::HUMAN_STATUSES[build_list.status].to_s}_count", build_list.mass_build_id + status = BuildList::HUMAN_STATUSES[build_list.status] + if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status) + MassBuild.increment_counter "#{status.to_s}_count", build_list.mass_build_id end end diff --git a/app/models/build_list/filter.rb b/app/models/build_list/filter.rb index 48f0b59cc..345a138dc 100644 --- a/app/models/build_list/filter.rb +++ b/app/models/build_list/filter.rb @@ -52,8 +52,10 @@ class BuildList::Filter :mass_build_id => nil })) - @options[:ownership] = @options[:ownership].presence || (@project || !@user ? 'index' : 'owned') - @options[:status] = @options[:status].try(:to_i) + @options[:ownership] = @options[:ownership].presence || (@project || !@user ? 'everything' : 'owned') + @options[:status] = @options[:status].present? ? @options[:status].to_i : nil + @options[:created_at_start] = build_date_from_params(:created_at_start, @options) + @options[:created_at_end] = build_date_from_params(:created_at_end, @options) @options[:updated_at_start] = build_date_from_params(:updated_at_start, @options) @options[:updated_at_end] = build_date_from_params(:updated_at_end, @options) @options[:project_version] = @options[:project_version].presence diff --git a/app/views/platforms/mass_builds/index.html.haml b/app/views/platforms/mass_builds/index.html.haml index 15ba91f7a..e1115e0fa 100644 --- a/app/views/platforms/mass_builds/index.html.haml +++ b/app/views/platforms/mass_builds/index.html.haml @@ -37,13 +37,13 @@ - @mass_builds.each do |mass_build| %tr %td= mass_build.id - %td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id}) + %td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'everything'}) %td.min_width_120 - MassBuild::COUNT_STATUSES.each do |status| - = link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'index'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {})) + = link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'everything'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {})) = mass_build.read_attribute "#{status}_count" .both - %td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platform_mass_build_path(@platform, mass_build.id), :target => "_blank" if can?(:failed_builds_list, mass_build) + %td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platform_mass_build_path(@platform, mass_build.id, :format => :txt), :target => "_blank" if can?(:failed_builds_list, mass_build) %td= link_to image_tag('x.png'), cancel_platform_mass_build_path(@platform, mass_build.id), :method => :post, :confirm => t("layout.mass_builds.cancel_confirm") if can?(:cancel, mass_build) %td %a.toggle_btn{:href => "#toggle_#{ mass_build.id }", :'data-target' => "#toggle_#{ mass_build.id }"}= t("layout.mass_builds.extended_data") diff --git a/app/views/projects/build_lists/_filter.html.haml b/app/views/projects/build_lists/_filter.html.haml index 0d7d38eaa..a9ca14988 100644 --- a/app/views/projects/build_lists/_filter.html.haml +++ b/app/views/projects/build_lists/_filter.html.haml @@ -31,8 +31,8 @@ .lefter= t("layout.build_lists.ownership.related") .both .table - .lefter= f.radio_button :ownership, 'index', :class => 'niceRadio', :id => 'myradio3' - .lefter= t("layout.build_lists.ownership.index") + .lefter= f.radio_button :ownership, 'everything', :class => 'niceRadio', :id => 'myradio3' + .lefter= t("layout.build_lists.ownership.everything") .both %br = f.submit t("layout.search.header") diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index cdcf7530e..20d1177fa 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -80,7 +80,7 @@ en: header: Build list ownership owned: My related: Related - index: All + everything: All build_server_status: header: Build server status diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 5c5820a9d..09dd8ef46 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -79,7 +79,7 @@ ru: header: Принадлежность заданий owned: Мне related: Связанные со мной - index: Все + everything: Все build_server_status: header: Статус сборочного сервера diff --git a/db/schema.rb b/db/schema.rb index 9b5f06c2b..dd125c3d3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -159,12 +159,12 @@ ActiveRecord::Schema.define(:version => 20120730214052) do end create_table "flash_notifies", :force => true do |t| - t.text "body_ru", :null => false - t.text "body_en", :null => false - t.string "status", :null => false - t.boolean "published", :default => true, :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.text "body_ru" + t.text "body_en" + t.string "status" + t.boolean "published", :default => true + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "groups", :force => true do |t| @@ -321,19 +321,17 @@ ActiveRecord::Schema.define(:version => 20120730214052) do t.text "description" t.string "ancestry" t.boolean "has_issues", :default => true + t.boolean "has_wiki", :default => false t.string "srpm_file_name" t.string "srpm_content_type" t.integer "srpm_file_size" t.datetime "srpm_updated_at" - t.boolean "has_wiki", :default => false t.string "default_branch", :default => "master" t.boolean "is_package", :default => true, :null => false t.integer "average_build_time", :default => 0, :null => false t.integer "build_count", :default => 0, :null => false end - add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true, :case_sensitive => false - create_table "register_requests", :force => true do |t| t.string "name" t.string "email" @@ -395,6 +393,7 @@ ActiveRecord::Schema.define(:version => 20120730214052) do 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 "reset_password_token" t.datetime "remember_created_at" t.datetime "created_at", :null => false @@ -402,8 +401,11 @@ ActiveRecord::Schema.define(:version => 20120730214052) do t.string "uname" t.string "role" t.string "language", :default => "en" - t.datetime "reset_password_sent_at" + 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" @@ -415,9 +417,6 @@ ActiveRecord::Schema.define(:version => 20120730214052) do t.integer "failed_attempts", :default => 0 t.string "unlock_token" t.datetime "locked_at" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" t.string "authentication_token" t.integer "build_priority", :default => 50 end diff --git a/spec/controllers/projects/build_lists_controller_spec.rb b/spec/controllers/projects/build_lists_controller_spec.rb index ef95a4cf7..0cb7e4b2f 100644 --- a/spec/controllers/projects/build_lists_controller_spec.rb +++ b/spec/controllers/projects/build_lists_controller_spec.rb @@ -125,7 +125,7 @@ describe Projects::BuildListsController do end it 'should show only accessible build_lists' do - get :index, :filter => {:ownership => 'index'} + get :index, :filter => {:ownership => 'everything'} assigns(:build_lists).should include(@build_list1) assigns(:build_lists).should_not include(@build_list2) assigns(:build_lists).should include(@build_list3) @@ -210,7 +210,7 @@ describe Projects::BuildListsController do end it 'should show only accessible build_lists' do - get :index, :filter => {:ownership => 'index'} + get :index, :filter => {:ownership => 'everything'} assigns(:build_lists).should include(@build_list1) assigns(:build_lists).should_not include(@build_list2) assigns(:build_lists).should include(@build_list3) @@ -297,17 +297,17 @@ describe Projects::BuildListsController do it 'should filter by project_name' do # Project.where(:id => build_list2.project.id).update_all(:name => 'project_name') - get :index, :filter => {:project_name => @build_list2.project.name, :ownership => 'index'} + get :index, :filter => {:project_name => @build_list2.project.name, :ownership => 'everything'} assigns[:build_lists].should_not include(@build_list1) assigns[:build_lists].should include(@build_list2) assigns[:build_lists].should_not include(@build_list3) end it 'should filter by project_name and start_date' do - get :index, :filter => {:project_name => @build_list3.project.name, :ownership => 'index', - :"updated_at_start(1i)" => @build_list3.updated_at.year.to_s, - :"updated_at_start(2i)" => @build_list3.updated_at.month.to_s, - :"updated_at_start(3i)" => @build_list3.updated_at.day.to_s} + get :index, :filter => {:project_name => @build_list3.project.name, :ownership => 'everything', + "created_at_start(1i)" => @build_list3.created_at.year.to_s, + "created_at_start(2i)" => @build_list3.created_at.month.to_s, + "created_at_start(3i)" => @build_list3.created_at.day.to_s} assigns[:build_lists].should_not include(@build_list1) assigns[:build_lists].should_not include(@build_list2) assigns[:build_lists].should include(@build_list3)