From 8350fc8fb14dbd484a9929264d110a11521f1f3b Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Fri, 4 May 2012 21:12:51 +0400 Subject: [PATCH 1/8] [issue 428] Added advisory. --- app/controllers/build_lists_controller.rb | 59 +++++--- app/models/ability.rb | 4 +- app/models/advisory.rb | 23 +++ app/models/build_list.rb | 19 ++- app/models/collaborator.rb | 2 +- app/models/platform.rb | 2 + app/models/project.rb | 6 +- app/views/advisories/_form.html.haml | 15 ++ .../build_lists/_include_repos.html.haml | 2 +- app/views/build_lists/new.html.haml | 6 +- app/views/build_lists/show.html.haml | 134 ++++++++++-------- config/routes.rb | 2 +- .../20120428053303_create_advisories.rb | 16 +++ ...20428054604_create_advisories_platforms.rb | 18 +++ ...28070521_add_advisory_id_to_build_lists.rb | 7 + ...20428105843_rename_pl_bpl_in_build_list.rb | 15 ++ db/schema.rb | 54 +++++-- .../build_lists_controller_spec.rb | 6 +- spec/factories/build_lists.rb | 6 +- spec/models/advisory_spec.rb | 5 + 20 files changed, 287 insertions(+), 114 deletions(-) create mode 100644 app/models/advisory.rb create mode 100644 app/views/advisories/_form.html.haml create mode 100644 db/migrate/20120428053303_create_advisories.rb create mode 100644 db/migrate/20120428054604_create_advisories_platforms.rb create mode 100644 db/migrate/20120428070521_add_advisory_id_to_build_lists.rb create mode 100644 db/migrate/20120428105843_rename_pl_bpl_in_build_list.rb create mode 100644 spec/models/advisory_spec.rb diff --git a/app/controllers/build_lists_controller.rb b/app/controllers/build_lists_controller.rb index 17f4b27f8..af297ca3b 100644 --- a/app/controllers/build_lists_controller.rb +++ b/app/controllers/build_lists_controller.rb @@ -7,7 +7,7 @@ class BuildListsController < ApplicationController before_filter :authenticate_build_service!, :only => CALLBACK_ACTIONS skip_before_filter :authenticate_user!, :only => [:show, :index, :search] if APP_CONFIG['anonymous_access'] before_filter :find_project, :only => NESTED_ACTIONS - before_filter :find_build_list, :only => [:show, :publish, :cancel, :reject_publish] + before_filter :find_build_list, :only => [:show, :publish, :cancel, :reject_publish, :update] before_filter :find_build_list_by_bs, :only => [:publish_build, :status_build, :pre_build, :post_build, :circle_build] before_filter :find_platform, :only => [:create] @@ -44,13 +44,13 @@ class BuildListsController < ApplicationController # Disable auto_publish if platform released params[:build_list][:auto_publish] = false if @platform.released Arch.where(:id => params[:arches]).each do |arch| - Platform.main.where(:id => params[:bpls]).each do |bpl| + Platform.main.where(:id => params[:build_for_platforms]).each do |build_for_platform| @build_list = @project.build_lists.build(params[:build_list]) @build_list.commit_hash = @project.git_repository.commits(@build_list.project_version.match(/^latest_(.+)/).to_a.last || @build_list.project_version).first.id if @build_list.project_version - @build_list.bpl = bpl; @build_list.arch = arch; @build_list.user = current_user - @build_list.include_repos = @build_list.include_repos.select {|ir| @build_list.bpl.repository_ids.include? ir.to_i} + @build_list.build_for_platform = build_for_platform; @build_list.arch = arch; @build_list.user = current_user + @build_list.include_repos = @build_list.include_repos.select {|ir| @build_list.build_for_platform.repository_ids.include? ir.to_i} @build_list.priority = 100 # User builds more priority than mass rebuild with zero priority - flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :bpl => bpl.name, :pl => @build_list.pl} + flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :build_for_platform => build_for_platform.name, :save_to_platform => @build_list.save_to_platform} if @build_list.save notices << t("flash.build_list.saved", flash_options) else @@ -73,20 +73,16 @@ class BuildListsController < ApplicationController @item_groups = @build_list.items.group_by_level end - def publish - if @build_list.publish - redirect_to :back, :notice => t('layout.build_lists.publish_success') - else - redirect_to :back, :notice => t('layout.build_lists.publish_fail') - end - end - - def reject_publish - if @build_list.reject_publish - redirect_to :back, :notice => t('layout.build_lists.reject_publish_success') - else - redirect_to :back, :notice => t('layout.build_lists.reject_publish_fail') + def update + # King Arthur, we are under attack! + if ( !@build_list.can_publish? || cannot?(:publish, @build_list) ) && params[:publish].present? or + ( !@build_list.can_reject_publish? || cannot?(:reject_publish, @build_list) ) && params[:reject_publish].present? + redirect_to :forbidden and return end + #raise + publish if params[:publish].present? + reject_publish if params[:reject_publish].present? + #raise end def cancel @@ -165,7 +161,7 @@ class BuildListsController < ApplicationController end def find_platform - @platform = Platform.find params[:build_list][:pl_id] + @platform = Platform.find params[:build_list][:save_to_platform_id] end def find_build_list @@ -181,4 +177,29 @@ class BuildListsController < ApplicationController render :nothing => true, :status => 403 end end + + def publish + @build_list.update_type = params[:build_list][:update_type] if params[:build_list][:update_type].present? + if params[:create_advisory].present? + a = @build_list.build_advisory + a.update_type = @build_list.update_type + a.project = @build_list.project + a.platforms << @build_list.save_to_platform unless a.platforms.include? @build_list.save_to_platform + redirect_to :back, :notice => t('layout.build_lists.publish_fail') unless a.update_attributes(params[:build_list][:advisory]) + end + if @build_list.save and @build_list.publish + redirect_to :back, :notice => t('layout.build_lists.publish_success') + else + redirect_to :back, :notice => t('layout.build_lists.publish_fail') + end + end + + def reject_publish + if @build_list.reject_publish + redirect_to :back, :notice => t('layout.build_lists.reject_publish_success') + else + redirect_to :back, :notice => t('layout.build_lists.reject_publish_fail') + end + end + end diff --git a/app/models/ability.rb b/app/models/ability.rb index 8e4c60bf9..5ac6d6309 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -69,10 +69,10 @@ class Ability can(:read, BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project} can(:create, BuildList) {|build_list| build_list.project.is_rpm && can?(:write, build_list.project)} can(:publish, BuildList) do |build_list| - build_list.can_publish? and build_list.pl.released ? local_admin?(build_list.pl) : can?(:write, build_list.project) + build_list.can_publish? and build_list.save_to_platform.released ? local_admin?(build_list.save_to_platform) : can?(:write, build_list.project) end can(:reject_publish, BuildList) do |build_list| - build_list.can_reject_publish? and build_list.pl.released and local_admin?(build_list.pl) + build_list.can_reject_publish? and build_list.save_to_platform.released and local_admin?(build_list.save_to_platform) end can(:cancel, BuildList) {|build_list| build_list.can_cancel? && can?(:write, build_list.project)} diff --git a/app/models/advisory.rb b/app/models/advisory.rb new file mode 100644 index 000000000..b9df1946b --- /dev/null +++ b/app/models/advisory.rb @@ -0,0 +1,23 @@ +class Advisory < ActiveRecord::Base + has_and_belongs_to_many :platforms + has_many :build_lists + belongs_to :project + + validates :description, :update_type, :presence => true + + after_create :generate_advisory_id + + ID_TEMPLATE = 'ROSA%s-%d:%04d' + TYPES = {'security' => 'SA', 'bugfix' => 'A'} + + def to_param + advisory_id + end + + protected + + def generate_advisory_id + self.advisory_id = sprintf(ID_TEMPLATE, :type => TYPES[self.update_type], :year => Time.now.utc.year, :id => self.id) + self.save + end +end diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 38fb4111b..12779db0a 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -2,18 +2,25 @@ class BuildList < ActiveRecord::Base belongs_to :project belongs_to :arch - belongs_to :pl, :class_name => 'Platform' - belongs_to :bpl, :class_name => 'Platform' + belongs_to :save_to_platform, :class_name => 'Platform' + belongs_to :build_for_platform, :class_name => 'Platform' belongs_to :user has_many :items, :class_name => "BuildList::Item", :dependent => :destroy + belongs_to :advisory + validates :project_id, :project_version, :arch, :include_repos, :presence => true validates_numericality_of :priority, :greater_than_or_equal_to => 0 UPDATE_TYPES = %w[security bugfix enhancement recommended newpackage] - validates :update_type, :inclusion => UPDATE_TYPES + RELEASE_UPDATE_TYPES = %w[security bugfix] + + validates :update_type, :inclusion => UPDATE_TYPES, + :unless => Proc.new { |b| b.save_to_platform.released } + validates :update_type, :inclusion => RELEASE_UPDATE_TYPES, + :if => Proc.new { |b| b.save_to_platform.released } validate lambda { - errors.add(:bpl, I18n.t('flash.build_list.wrong_platform')) if pl.platform_type == 'main' && pl_id != bpl_id + errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_platform')) if save_to_platform.platform_type == 'main' && save_to_platform_id != build_for_platform_id } # The kernel does not send these statuses directly @@ -123,7 +130,7 @@ class BuildList < ActiveRecord::Base end def can_reject_publish? - can_publish? and pl.released + can_publish? and save_to_platform.released end def cancel @@ -167,7 +174,7 @@ class BuildList < ActiveRecord::Base def place_build #XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos, priority - self.status = BuildServer.add_build_list project.name, project_version, pl.name, arch.name, (pl_id == bpl_id ? '' : bpl.name), update_type, build_requires, id, include_repos, priority + self.status = BuildServer.add_build_list project.name, project_version, save_to_platform.name, arch.name, (save_to_platform_id == build_for_platform_id ? '' : build_for_platform.name), update_type, build_requires, id, include_repos, priority self.status = BUILD_PENDING if self.status == 0 save end diff --git a/app/models/collaborator.rb b/app/models/collaborator.rb index c0b0e35af..8b1f1b412 100644 --- a/app/models/collaborator.rb +++ b/app/models/collaborator.rb @@ -4,7 +4,7 @@ class Collaborator include ActiveModel::Validations include ActiveModel::Serializers::JSON include ActiveModel::MassAssignmentSecurity - extend ActiveModel::Naming + extend ActiveModel::Naming attr_accessor :role, :actor, :project, :relation attr_reader :id, :actor_id, :actor_type, :actor_name, :project_id diff --git a/app/models/platform.rb b/app/models/platform.rb index 376d17cc7..56254c23e 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -13,6 +13,8 @@ class Platform < ActiveRecord::Base has_many :actors, :as => :target, :class_name => 'Relation', :dependent => :destroy has_many :members, :through => :actors, :source => :actor, :source_type => 'User' + has_and_belongs_to_many :advisories + validates :description, :presence => true validates :visibility, :presence => true, :inclusion => {:in => VISIBILITIES} validates :name, :uniqueness => {:case_sensitive => false}, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-]+$/ } diff --git a/app/models/project.rb b/app/models/project.rb index 5049446a0..109a20fe9 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -17,6 +17,8 @@ class Project < ActiveRecord::Base has_many :groups, :through => :relations, :source => :actor, :source_type => 'Group' has_many :labels + has_many :advisories + validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^[a-zA-Z0-9_\-\+\.]+$/} validates :owner, :presence => true validate { errors.add(:base, :can_have_less_or_equal, :count => MAX_OWN_PROJECTS) if owner.projects.size >= MAX_OWN_PROJECTS } @@ -61,8 +63,8 @@ class Project < ActiveRecord::Base arch = Arch.find_by_name(arch) if arch.acts_like?(:string) build_lists.create do |bl| - bl.pl = platform - bl.bpl = platform + bl.save_to_platform = platform + bl.build_to_platform = platform bl.update_type = 'newpackage' bl.arch = arch bl.project_version = "latest_#{platform.name}" diff --git a/app/views/advisories/_form.html.haml b/app/views/advisories/_form.html.haml new file mode 100644 index 000000000..a21ff2acb --- /dev/null +++ b/app/views/advisories/_form.html.haml @@ -0,0 +1,15 @@ +%h3= t("layout.advisories.form_header") + +.leftlist + = f.label :description, t("activerecord.attributes.advisory.description") +.rightlist + = f.text_area :description, :class => 'text_field', :cols => 80 +.both + +.leftlist + = f.label :references, t("activerecord.attributes.advisory.references") + %span.hint + = t("layout.advisories.ref_comment") +.rightlist + = f.text_area :references, :class => 'text_field', :cols => 80 +.both diff --git a/app/views/build_lists/_include_repos.html.haml b/app/views/build_lists/_include_repos.html.haml index 372d3865a..11ef89f97 100644 --- a/app/views/build_lists/_include_repos.html.haml +++ b/app/views/build_lists/_include_repos.html.haml @@ -1,4 +1,4 @@ - platform.repositories.each do |repo| .both - = check_box_tag "build_list[include_repos][]", repo.id, repo.name == 'main' || @project.repositories.map(&:id).include?(repo.id), :id => "include_repos_#{repo.id}", :pl_id => platform.id, :rep_name => repo.name + = check_box_tag "build_list[include_repos][]", repo.id, repo.name == 'main' || @project.repositories.map(&:id).include?(repo.id), :id => "include_repos_#{repo.id}", :save_to_platform_id => platform.id, :rep_name => repo.name = label_tag "include_repos_#{repo.id}", repo.name diff --git a/app/views/build_lists/new.html.haml b/app/views/build_lists/new.html.haml index ad53ea951..cec71e29b 100644 --- a/app/views/build_lists/new.html.haml +++ b/app/views/build_lists/new.html.haml @@ -1,18 +1,18 @@ -set_meta_tags :title => [title_object(@project), t('layout.build_lists.new_header')] = form_for [@project, @build_list], :html => { :class => :form, :method => :post } do |f| %section.left - %h3= t("activerecord.attributes.build_list.bpl") + %h3= t("activerecord.attributes.build_list.build_for_platofrm") .all_platforms - Platform.main.each do |pl| - if pl.repository_ids.size > 0 .both - = check_box_tag "bpls[]", pl.id, (params[:bpls]||[]).include?(pl.id.to_s), :class => 'build_bpl_ids', :id => "bpls_#{pl.id}", :'data-released' => pl.released ? 1 : 0 + = check_box_tag "build_for_platforms[]", pl.id, (params[:build_for_platforms]||[]).include?(pl.id.to_s), :class => 'build_bpl_ids', :id => "bpls_#{pl.id}", :'data-released' => pl.released ? 1 : 0 = label_tag "bpls_#{pl.id}", pl.name .offset25{:style => 'padding-left: 25px'} = render 'include_repos', :platform => pl %section.right %h3= t("activerecord.attributes.build_list.pl") - .lineForm= f.select :pl_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.platform.id]} + .lineForm= f.select :save_to_platform_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.platform.id]} %h3= t("activerecord.attributes.build_list.project_version") - if controller.action_name == 'new' .lineForm= f.select :project_version, @project.versions_for_group_select, :selected => "latest_" + @project.default_branch diff --git a/app/views/build_lists/show.html.haml b/app/views/build_lists/show.html.haml index 2ae62610e..ebce1bd73 100644 --- a/app/views/build_lists/show.html.haml +++ b/app/views/build_lists/show.html.haml @@ -4,66 +4,84 @@ %p= @build_list.human_status %p= @build_list.updated_at .both -%h3= t("layout.build_lists.main_data") -.leftside.width125= t("activerecord.attributes.build_list.container_path") -.leftside - - if @build_list.status == BuildList::BUILD_PUBLISHED - = t("layout.build_lists.container_published") - - elsif @build_list.container_path.present? - - container_url = "http://#{request.host_with_port}/downloads#{@build_list.container_path}" - = link_to container_url, container_url -.both -.leftside.width125= t("activerecord.attributes.build_list.user") -.leftside - = link_to @build_list.user.try(:fullname), @build_list.user -.both -= link_to t("layout.publish"), publish_build_list_path(@build_list), :method => "put", :confirm => t("layout.confirm"), :class => "button tmargin10" if @build_list.can_publish? and can?(:publish, @build_list) -= link_to t("layout.reject_publish"), reject_publish_build_list_path(@build_list), :method => "put", :confirm => t("layout.confirm"), :class => "button tmargin10" if @build_list.can_reject_publish? and can?(:reject_publish, @build_list) -.hr -%h3= t("layout.build_lists.main_data") -.leftside.width125= t("activerecord.attributes.build_list.bpl") -.leftside - = link_to @build_list.bpl.name, @build_list.bpl -.both -.leftside.width125= t("activerecord.attributes.build_list.pl") -.leftside - = link_to @build_list.pl.name, @build_list.pl -.both -.leftside.width125= t("activerecord.attributes.build_list.include_repos") -.leftside= (@build_list.include_repos||[]).map{|r| Repository.find(r).name}.join(', ') -.both -.leftside.width125= t("activerecord.attributes.build_list.update_type") -.leftside= @build_list.update_type -.both -.leftside.width125= t("activerecord.attributes.build_list.build_requires") -.leftside= @build_list.build_requires -.both -.leftside.width125= t("activerecord.attributes.build_list.auto_publish") -.leftside= @build_list.auto_publish -.both -.leftside.width125= t("activerecord.attributes.build_list.project_version") -.leftside= @build_list.project_version -.both -.leftside.width125= t("activerecord.attributes.build_list.arch") -.leftside= @build_list.arch.name -.both -.leftside.width125= t("activerecord.attributes.build_list.updated_at") -.leftside= @build_list.updated_at -.both -.leftside.width125= t("activerecord.attributes.build_list.is_circle") -.leftside= t("layout.#{@build_list.is_circle?}_") -.both -- if !@build_list.in_work? && @build_list.started_at - %br - .leftside.width125 - .leftside= @build_list.human_duration += form_for @build_list do |f| + %h3= t("layout.build_lists.main_data") + .leftlist= t("activerecord.attributes.build_list.container_path") + .rightlist + - if @build_list.status == BuildList::BUILD_PUBLISHED + = t("layout.build_lists.container_published") + - elsif @build_list.container_path.present? + - container_url = "http://#{request.host_with_port}/downloads#{@build_list.container_path}" + = link_to container_url, container_url .both -- if @build_list.in_work? - %br - .leftside.width125 - .leftside - = "#{@build_list.human_current_duration} / #{@build_list.project.human_average_build_time}" + .leftlist= t("activerecord.attributes.build_list.user") + .rightlist + = link_to @build_list.user.try(:fullname), @build_list.user .both + .leftlist= t("activerecord.attributes.build_list.bpl") + .rightlist + = link_to @build_list.build_for_platform.name, @build_list.build_for_platform + .both + .leftlist= t("activerecord.attributes.build_list.pl") + .rightlist + = link_to @build_list.save_to_platform.name, @build_list.save_to_platform + .both + .leftlist= t("activerecord.attributes.build_list.include_repos") + .rightlist= (@build_list.include_repos||[]).map{|r| Repository.find(r).name}.join(', ') + .both + .leftlist= t("activerecord.attributes.build_list.update_type") + .rightlist + - if @build_list.can_publish? and can?(:publish, @build_list) + = f.select :update_type, options_for_select(BuildList::RELEASE_UPDATE_TYPES, @build_list.update_type) + - else + = @build_list.update_type + .both + .leftlist= t("activerecord.attributes.build_list.build_requires") + .rightlist= t("layout.#{@build_list.build_requires}_") + .both + .leftlist= t("activerecord.attributes.build_list.auto_publish") + .rightlist= t("layout.#{@build_list.auto_publish}_") + .both + .leftlist= t("activerecord.attributes.build_list.project_version") + .rightlist= @build_list.project_version + .both + .leftlist= t("activerecord.attributes.build_list.arch") + .rightlist= @build_list.arch.name + .both + .leftlist= t("activerecord.attributes.build_list.updated_at") + .rightlist= @build_list.updated_at + .both + .leftlist= t("activerecord.attributes.build_list.is_circle") + .rightlist= t("layout.#{@build_list.is_circle?}_") + .both + + - if @build_list.advisory.present? + .leftlist= t("layout.build_lists.connected_advisory") + .rightlist= @build_list.advisory.advisory_id + .both + - if !@build_list.in_work? && @build_list.started_at + %br + .leftlist + .rightlist= @build_list.human_duration + .both + - if @build_list.in_work? + %br + .leftlist + .rightlist + = "#{@build_list.human_current_duration} / #{@build_list.project.human_average_build_time}" + .both + + - if @build_list.can_publish? and @build_list.save_to_platform.released and @build_list.advisory.nil? + .leftlist= label_tag :create_advisory, t("layout.build_lists.create_advisory") + .rightlist= check_box_tag :create_advisory, 1, false + .both + = f.fields_for @build_list.build_advisory do |f| + = render :partial => 'advisories/form', :locals => {:f => f} + + =# link_to t("layout.publish"), publish_build_list_path(@build_list), :method => "put", :confirm => t("layout.confirm"), :class => "button tmargin10" if @build_list.can_publish? and can?(:publish, @build_list) + =# link_to t("layout.reject_publish"), reject_publish_build_list_path(@build_list), :method => "put", :confirm => t("layout.confirm"), :class => "button tmargin10" if @build_list.can_reject_publish? and can?(:reject_publish, @build_list) + = submit_tag t("layout.publish"), :confirm => t("layout.confirm"), :name => 'publish' if @build_list.can_publish? and can?(:publish, @build_list) + = submit_tag t("layout.reject_publish"), :confirm => t("layout.confirm"), :name => 'reject_publish' if @build_list.can_reject_publish? and can?(:reject_publish, @build_list) .hr %h3= t("layout.build_lists.items_header") diff --git a/config/routes.rb b/config/routes.rb index 1ede68a47..e3acc0658 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -157,7 +157,7 @@ Rosa::Application.routes.draw do match 'build_lists/new_bbdt', :to => "build_lists#new_bbdt" match 'product_status', :to => 'product_build_lists#status_build' - resources :build_lists, :only => [:index, :show] do + resources :build_lists, :only => [:index, :show, :update] do member do put :cancel put :publish diff --git a/db/migrate/20120428053303_create_advisories.rb b/db/migrate/20120428053303_create_advisories.rb new file mode 100644 index 000000000..e1a6ee8fc --- /dev/null +++ b/db/migrate/20120428053303_create_advisories.rb @@ -0,0 +1,16 @@ +class CreateAdvisories < ActiveRecord::Migration + def change + create_table :advisories do |t| + t.string :advisory_id + t.integer :project_id + t.text :description, :default => '' + t.text :references, :default => '' + t.text :update_type, :default => '' + + t.timestamps + end + add_index :advisories, :advisory_id, :unique => true + add_index :advisories, :project_id + add_index :advisories, :update_type + end +end diff --git a/db/migrate/20120428054604_create_advisories_platforms.rb b/db/migrate/20120428054604_create_advisories_platforms.rb new file mode 100644 index 000000000..aded3af7b --- /dev/null +++ b/db/migrate/20120428054604_create_advisories_platforms.rb @@ -0,0 +1,18 @@ +class CreateAdvisoriesPlatforms < ActiveRecord::Migration + def up + create_table :advisories_platforms, :id => false do |t| + t.integer :advisory_id + t.integer :platform_id + end + add_index :advisories_platforms, :advisory_id + add_index :advisories_platforms, :platform_id + add_index :advisories_platforms, [:advisory_id, :platform_id], :name => :advisory_platform_index, :unique => true + end + + def down + remove_index :advisories_platforms, :column => :advisory_id + remove_index :advisories_platforms, :column => :platform_id + remove_index :advisories_platforms, :name => :advisory_platform_index + drop_table :advisories_platforms + end +end diff --git a/db/migrate/20120428070521_add_advisory_id_to_build_lists.rb b/db/migrate/20120428070521_add_advisory_id_to_build_lists.rb new file mode 100644 index 000000000..c73f47e76 --- /dev/null +++ b/db/migrate/20120428070521_add_advisory_id_to_build_lists.rb @@ -0,0 +1,7 @@ +class AddAdvisoryIdToBuildLists < ActiveRecord::Migration + def change + add_column :build_lists, :advisory_id, :integer + add_index :build_lists, :advisory_id + + end +end diff --git a/db/migrate/20120428105843_rename_pl_bpl_in_build_list.rb b/db/migrate/20120428105843_rename_pl_bpl_in_build_list.rb new file mode 100644 index 000000000..d9f79b877 --- /dev/null +++ b/db/migrate/20120428105843_rename_pl_bpl_in_build_list.rb @@ -0,0 +1,15 @@ +class RenamePlBplInBuildList < ActiveRecord::Migration + def up + change_table :build_lists do |t| + t.rename :pl_id, :save_to_platform_id + t.rename :bpl_id, :build_for_platform_id + end + end + + def down + change_table :build_lists do |t| + t.rename :save_to_platform_id, :pl_id + t.rename :build_for_platform_id, :bpl_id + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 6a8b6fdfb..39a324e0e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,16 +11,39 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120425190938) do +ActiveRecord::Schema.define(:version => 20120428105843) do create_table "activity_feeds", :force => true do |t| 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| + t.string "advisory_id" + t.integer "project_id" + t.text "description", :default => "" + t.text "references", :default => "" + t.text "update_type", :default => "" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "advisories", ["advisory_id"], :name => "index_advisories_on_advisory_id", :unique => true + add_index "advisories", ["project_id"], :name => "index_advisories_on_project_id" + add_index "advisories", ["update_type"], :name => "index_advisories_on_update_type" + + create_table "advisories_platforms", :id => false, :force => true do |t| + t.integer "advisory_id" + t.integer "platform_id" + end + + add_index "advisories_platforms", ["advisory_id"], :name => "index_advisories_platforms_on_advisory_id" + add_index "advisories_platforms", ["advisory_id", "platform_id"], :name => "advisory_platform_index", :unique => true + add_index "advisories_platforms", ["platform_id"], :name => "index_advisories_platforms_on_platform_id" + create_table "arches", :force => true do |t| t.string "name", :null => false t.datetime "created_at" @@ -62,23 +85,25 @@ ActiveRecord::Schema.define(:version => 20120425190938) do t.datetime "notified_at" t.datetime "created_at" t.datetime "updated_at" - t.boolean "is_circle", :default => false + t.boolean "is_circle", :default => false t.text "additional_repos" t.string "name" - t.boolean "build_requires", :default => false + t.boolean "build_requires", :default => false t.string "update_type" - t.integer "bpl_id" - t.integer "pl_id" + t.integer "build_for_platform_id" + t.integer "save_to_platform_id" t.text "include_repos" t.integer "user_id" - t.boolean "auto_publish", :default => true + t.boolean "auto_publish", :default => true t.string "package_version" t.string "commit_hash" - t.integer "priority", :default => 0, :null => false + t.integer "priority", :default => 0, :null => false t.datetime "started_at" t.integer "duration" + t.integer "advisory_id" end + add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id" add_index "build_lists", ["arch_id"], :name => "index_build_lists_on_arch_id" add_index "build_lists", ["bs_id"], :name => "index_build_lists_on_bs_id", :unique => true add_index "build_lists", ["project_id"], :name => "index_build_lists_on_project_id" @@ -180,7 +205,7 @@ ActiveRecord::Schema.define(:version => 20120425190938) do t.string "owner_type" t.string "visibility", :default => "open", :null => false t.string "platform_type", :default => "main", :null => false - t.string "distrib_type", :null => false + t.string "distrib_type" end add_index "platforms", ["name"], :name => "index_platforms_on_name", :unique => true, :case_sensitive => false @@ -251,18 +276,18 @@ ActiveRecord::Schema.define(:version => 20120425190938) 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_rpm", :default => true 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 + 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" @@ -277,7 +302,6 @@ ActiveRecord::Schema.define(:version => 20120425190938) do end add_index "register_requests", ["email"], :name => "index_register_requests_on_email", :unique => true, :case_sensitive => false - add_index "register_requests", ["token"], :name => "index_register_requests_on_token", :unique => true, :case_sensitive => false create_table "relations", :force => true do |t| t.integer "actor_id" @@ -325,16 +349,16 @@ ActiveRecord::Schema.define(:version => 20120425190938) 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 "reset_password_sent_at" t.datetime "remember_created_at" t.datetime "created_at" t.datetime "updated_at" + t.text "ssh_key" t.string "uname" t.string "role" t.string "language", :default => "en" 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/controllers/build_lists_controller_spec.rb b/spec/controllers/build_lists_controller_spec.rb index b42eb08d0..32a6ced90 100644 --- a/spec/controllers/build_lists_controller_spec.rb +++ b/spec/controllers/build_lists_controller_spec.rb @@ -72,12 +72,12 @@ describe BuildListsController do @create_params = { :build_list => { :project_version => 'latest_master', - :pl_id => platform.id, + :save_to_platform_id => platform.id, :update_type => 'security', :include_repos => [platform.repositories.first.id] }, :arches => [FactoryGirl.create(:arch).id], - :bpls => [platform.id] + :build_for_platforms => [platform.id] } any_instance_of(Project, :versions => ['v1.0', 'v2.0']) end @@ -284,7 +284,7 @@ describe BuildListsController do @build_list2 = FactoryGirl.create(:build_list_core) @build_list3 = FactoryGirl.create(:build_list_core) @build_list4 = FactoryGirl.create(:build_list_core, :created_at => (Time.now - 1.day), - :project => @build_list3.project, :pl => @build_list3.pl, + :project => @build_list3.project, :save_to_platform => @build_list3.save_to_platform, :arch => @build_list3.arch) end diff --git a/spec/factories/build_lists.rb b/spec/factories/build_lists.rb index f48df51a8..2a08e1b9d 100644 --- a/spec/factories/build_lists.rb +++ b/spec/factories/build_lists.rb @@ -3,13 +3,13 @@ FactoryGirl.define do factory :build_list do association :user association :project - association :pl, :factory => :platform_with_repos + association save_to_platform, :factory => :platform_with_repos association :arch - bpl {|bl| bl.pl} + build_for_platform {|bl| bl.save_to_platform} project_version "1.0" build_requires true update_type 'security' - include_repos {|bl| bl.pl.repositories.map(&:id)} + include_repos {|bl| bl.save_to_platform.repositories.map(&:id)} commit_hash '1234567890abcdef1234567890abcdef12345678' end diff --git a/spec/models/advisory_spec.rb b/spec/models/advisory_spec.rb new file mode 100644 index 000000000..abbb38c8e --- /dev/null +++ b/spec/models/advisory_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Advisory do + pending "add some examples to (or delete) #{__FILE__}" +end From 6fe0e5b530437eac36a00b194f71c2ed927d5b3a Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Sat, 5 May 2012 02:53:45 +0400 Subject: [PATCH 2/8] [issue #428] Added AdvisoriesController & show view. --- .../platforms/advisories_controller.rb | 18 ++++++++++ .../advisories/_form.html.haml | 0 app/views/platforms/advisories/show.html.haml | 35 +++++++++++++++++++ app/views/projects/build_lists/show.html.haml | 2 +- config/routes.rb | 1 + 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 app/controllers/platforms/advisories_controller.rb rename app/views/{ => platforms}/advisories/_form.html.haml (100%) create mode 100644 app/views/platforms/advisories/show.html.haml diff --git a/app/controllers/platforms/advisories_controller.rb b/app/controllers/platforms/advisories_controller.rb new file mode 100644 index 000000000..7e8180d0b --- /dev/null +++ b/app/controllers/platforms/advisories_controller.rb @@ -0,0 +1,18 @@ +# -*- encoding : utf-8 -*- +class Platforms::AdvisoriesController < Platforms::BaseController + before_filter :authenticate_user! + before_filter :find_advisory, :only => [:show] + load_and_authorize_resource + + def index + end + + def show + end + + protected + + def find_advisory + @advisory = Advisory.where(:advisory_id => params[:id]).limit(1).first if params[:id].present? + end +end diff --git a/app/views/advisories/_form.html.haml b/app/views/platforms/advisories/_form.html.haml similarity index 100% rename from app/views/advisories/_form.html.haml rename to app/views/platforms/advisories/_form.html.haml diff --git a/app/views/platforms/advisories/show.html.haml b/app/views/platforms/advisories/show.html.haml new file mode 100644 index 000000000..1da74365e --- /dev/null +++ b/app/views/platforms/advisories/show.html.haml @@ -0,0 +1,35 @@ +-#set_meta_tags :title => [title_object(@build_list.project), t('activerecord.models.build_list')] +%h3= "#{t("activerecord.models.advisory")} #{@advisory.advisory_id}".html_safe + +.leftlist= "#{t("layout.advisories.project_name")}:".html_safe +.rightlist= @advisory.project.name +.both + +.leftlist= "#{t("layout.advisories.creation_date")}:".html_safe +.rightlist= @advisory.created_at +.both + +.leftlist= "#{t("activerecord.attributes.advisory.advisory_id")}:".html_safe +.rightlist= @advisory.advisory_id +.both + +.leftlist= "#{t("layout.advisories.affected_versions")}:".html_safe +.rightlist + - @advisory.platforms.each do |platform| + = link_to platform.name, platform_path(platform) + %br +.both + +.leftlist= "#{t("activerecord.attributes.advisory.description")}:".html_safe +.rightlist= @advisory.description +.both + +.leftlist= "#{t("activerecord.attributes.advisories.references")}:".html_safe +.rightlist + - sanitize(@advisory.references).gsub("\r", '').split("\n").each do |ref| + = link_to ref + %br +.both + +:javascript + $('article .all').addClass('bigpadding'); diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 2078803f4..e68aa9a0c 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -57,7 +57,7 @@ - if @build_list.advisory.present? .leftlist= t("layout.build_lists.connected_advisory") - .rightlist= @build_list.advisory.advisory_id + .rightlist= link_to @build_list.advisory.advisory_id, advisory_path(@build_list.advisory) .both - if !@build_list.in_work? && @build_list.started_at %br diff --git a/config/routes.rb b/config/routes.rb index ef2bcb97e..fa9245d3d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -60,6 +60,7 @@ Rosa::Application.routes.draw do end match '/private/:platform_name/*file_path' => 'privates#show' + resources :advisories, :only => [:index, :show] resources :product_build_lists, :only => [:index] end From 05ef799fa4c586654e78faff49e6d4c97e1ed0e8 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Sat, 5 May 2012 21:18:29 +0400 Subject: [PATCH 3/8] [issue #428] Added advisories list. Added translations. --- app/assets/stylesheets/design/custom.scss | 22 +++++++++++++++++++ .../advisories_controller.rb | 3 ++- app/controllers/advisories/base_controller.rb | 3 +++ app/helpers/advisories_helper.rb | 12 ++++++++++ app/models/ability.rb | 2 ++ .../advisories/_form.html.haml | 0 .../advisories/advisories/_list.html.haml | 8 +++++++ .../advisories/_list_item.html.haml | 7 ++++++ .../advisories/advisories/index.html.haml | 4 ++++ .../advisories/show.html.haml | 16 ++++++++------ app/views/advisories/base/_submenu.html.haml | 7 ++++++ app/views/projects/build_lists/show.html.haml | 4 ++-- config/locales/layout.en.yml | 2 ++ config/locales/layout.ru.yml | 2 ++ config/locales/menu.en.yml | 1 + config/locales/menu.ru.yml | 1 + config/locales/models/advisory.en.yml | 22 +++++++++++++++++++ config/locales/models/advisory.ru.yml | 22 +++++++++++++++++++ config/locales/models/build_list.en.yml | 4 ++++ config/locales/models/build_list.ru.yml | 3 +++ config/routes.rb | 5 ++++- 21 files changed, 139 insertions(+), 11 deletions(-) rename app/controllers/{platforms => advisories}/advisories_controller.rb (71%) create mode 100644 app/controllers/advisories/base_controller.rb create mode 100644 app/helpers/advisories_helper.rb rename app/views/{platforms => advisories}/advisories/_form.html.haml (100%) create mode 100644 app/views/advisories/advisories/_list.html.haml create mode 100644 app/views/advisories/advisories/_list_item.html.haml create mode 100644 app/views/advisories/advisories/index.html.haml rename app/views/{platforms => advisories}/advisories/show.html.haml (59%) create mode 100644 app/views/advisories/base/_submenu.html.haml create mode 100644 config/locales/models/advisory.en.yml create mode 100644 config/locales/models/advisory.ru.yml diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index 08aa4967e..bbb206a7d 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -456,6 +456,18 @@ table.tablesorter.platforms .th2 { width: 280px; } +table.tablesorter.advisories .th1 { + width: 120px; +} + +table.tablesorter.advisories .th2 { + width: 250px; +} + +table.tablesorter.advisories .th3 { + width: auto; +} + table.tablesorter tr td.buttons { text-align: center; } @@ -921,3 +933,13 @@ div#git_help_data p { .dropdown.open .dropdown-toggle { background: none repeat scroll 0 0; } + +.rightlist p { + padding-bottom: 1em; +} + +.leftlist span.hint { + padding-top: 1em; + display: block; + font-size: 0.9em; +} diff --git a/app/controllers/platforms/advisories_controller.rb b/app/controllers/advisories/advisories_controller.rb similarity index 71% rename from app/controllers/platforms/advisories_controller.rb rename to app/controllers/advisories/advisories_controller.rb index 7e8180d0b..068b44e8a 100644 --- a/app/controllers/platforms/advisories_controller.rb +++ b/app/controllers/advisories/advisories_controller.rb @@ -1,10 +1,11 @@ # -*- encoding : utf-8 -*- -class Platforms::AdvisoriesController < Platforms::BaseController +class Advisories::AdvisoriesController < Advisories::BaseController before_filter :authenticate_user! before_filter :find_advisory, :only => [:show] load_and_authorize_resource def index + @advisories = @advisories.paginate(:page => params[:page]) end def show diff --git a/app/controllers/advisories/base_controller.rb b/app/controllers/advisories/base_controller.rb new file mode 100644 index 000000000..25d327da1 --- /dev/null +++ b/app/controllers/advisories/base_controller.rb @@ -0,0 +1,3 @@ +# -*- encoding : utf-8 -*- +class Advisories::BaseController < ApplicationController +end diff --git a/app/helpers/advisories_helper.rb b/app/helpers/advisories_helper.rb new file mode 100644 index 000000000..30d3085e8 --- /dev/null +++ b/app/helpers/advisories_helper.rb @@ -0,0 +1,12 @@ +# -*- encoding : utf-8 -*- +module AdvisoriesHelper + def construct_ref_link(ref) + ref = sanitize(ref) + url = if ref =~ %r[^http(s?)://*] + ref + else + 'http://' << ref + end + link_to url, url + end +end diff --git a/app/models/ability.rb b/app/models/ability.rb index 4e3b61edb..d1fe8928d 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -73,6 +73,8 @@ class Ability end can(:cancel, BuildList) {|build_list| build_list.can_cancel? && can?(:write, build_list.project)} + can [:read], Advisory + can [:read, :members], Platform, :visibility => 'open' can [:read, :owned, :related, :members], Platform, :owner_type => 'User', :owner_id => user.id can [:read, :related, :members], Platform, :owner_type => 'Group', :owner_id => user.group_ids diff --git a/app/views/platforms/advisories/_form.html.haml b/app/views/advisories/advisories/_form.html.haml similarity index 100% rename from app/views/platforms/advisories/_form.html.haml rename to app/views/advisories/advisories/_form.html.haml diff --git a/app/views/advisories/advisories/_list.html.haml b/app/views/advisories/advisories/_list.html.haml new file mode 100644 index 000000000..b6d80ebc9 --- /dev/null +++ b/app/views/advisories/advisories/_list.html.haml @@ -0,0 +1,8 @@ +%table#myTable.tablesorter.advisories{:cellspacing => "0", :cellpadding => "0"} + %thead + %tr + %th.th1= t("activerecord.attributes.advisory.advisory_id") + %th.th2= t("layout.advisories.affected_versions") + %th.th3= t("activerecord.attributes.advisory.description") + %tbody + = render :partial => 'list_item', :collection => list, :as => :advisory diff --git a/app/views/advisories/advisories/_list_item.html.haml b/app/views/advisories/advisories/_list_item.html.haml new file mode 100644 index 000000000..671b43854 --- /dev/null +++ b/app/views/advisories/advisories/_list_item.html.haml @@ -0,0 +1,7 @@ +%tr{:class => cycle("odd", "even")} + %td= link_to advisory.advisory_id, advisory_path(advisory) + %td + - advisory.platforms.each do |platform| + = link_to platfrom_printed_name(platform), platform_path(platform) + %br + %td= truncate(advisory.description, :length => 50) diff --git a/app/views/advisories/advisories/index.html.haml b/app/views/advisories/advisories/index.html.haml new file mode 100644 index 000000000..431a3e919 --- /dev/null +++ b/app/views/advisories/advisories/index.html.haml @@ -0,0 +1,4 @@ +- set_meta_tags :title => t('layout.advisories.list_header') +- render :partial => 'submenu' += render :partial => 'list', :object => @advisories += will_paginate @advisories diff --git a/app/views/platforms/advisories/show.html.haml b/app/views/advisories/advisories/show.html.haml similarity index 59% rename from app/views/platforms/advisories/show.html.haml rename to app/views/advisories/advisories/show.html.haml index 1da74365e..5aba87462 100644 --- a/app/views/platforms/advisories/show.html.haml +++ b/app/views/advisories/advisories/show.html.haml @@ -1,11 +1,13 @@ -#set_meta_tags :title => [title_object(@build_list.project), t('activerecord.models.build_list')] +- render :partial => 'submenu' + %h3= "#{t("activerecord.models.advisory")} #{@advisory.advisory_id}".html_safe .leftlist= "#{t("layout.advisories.project_name")}:".html_safe -.rightlist= @advisory.project.name +.rightlist= link_to @advisory.project.name, project_path(@advisory.project) .both -.leftlist= "#{t("layout.advisories.creation_date")}:".html_safe +.leftlist= "#{t("activerecord.attributes.advisory.created_at")}:".html_safe .rightlist= @advisory.created_at .both @@ -16,18 +18,18 @@ .leftlist= "#{t("layout.advisories.affected_versions")}:".html_safe .rightlist - @advisory.platforms.each do |platform| - = link_to platform.name, platform_path(platform) + = link_to platform_printed_name(platform), platform_path(platform) %br .both .leftlist= "#{t("activerecord.attributes.advisory.description")}:".html_safe -.rightlist= @advisory.description +.rightlist= simple_format @advisory.description .both -.leftlist= "#{t("activerecord.attributes.advisories.references")}:".html_safe +.leftlist= "#{t("activerecord.attributes.advisory.references")}:".html_safe .rightlist - - sanitize(@advisory.references).gsub("\r", '').split("\n").each do |ref| - = link_to ref + - @advisory.references.gsub(/\r| /, '').split("\n").each do |ref| + = construct_ref_link(ref) %br .both diff --git a/app/views/advisories/base/_submenu.html.haml b/app/views/advisories/base/_submenu.html.haml new file mode 100644 index 000000000..00ad6e3cc --- /dev/null +++ b/app/views/advisories/base/_submenu.html.haml @@ -0,0 +1,7 @@ +- content_for :submenu do + - act = action_name.to_sym; contr = controller_name.to_sym + .left + = @advisory.advisory_id if @advisory.present? + %nav + %ul + %li= link_to t('layout.list'), advisories_path, :class => act.in?([:index]) ? 'active' : nil diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index e68aa9a0c..2c0ea1baf 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -56,7 +56,7 @@ .both - if @build_list.advisory.present? - .leftlist= t("layout.build_lists.connected_advisory") + .leftlist= t("layout.build_lists.attached_advisory") .rightlist= link_to @build_list.advisory.advisory_id, advisory_path(@build_list.advisory) .both - if !@build_list.in_work? && @build_list.started_at @@ -76,7 +76,7 @@ .rightlist= check_box_tag :create_advisory, 1, false .both = f.fields_for @build_list.build_advisory do |f| - = render :partial => 'advisories/form', :locals => {:f => f} + = render :partial => 'advisories/advisories/form', :locals => {:f => f} =# link_to t("layout.publish"), publish_build_list_path(@build_list), :method => "put", :confirm => t("layout.confirm"), :class => "button tmargin10" if @build_list.can_publish? and can?(:publish, @build_list) =# link_to t("layout.reject_publish"), reject_publish_build_list_path(@build_list), :method => "put", :confirm => t("layout.confirm"), :class => "button tmargin10" if @build_list.can_reject_publish? and can?(:reject_publish, @build_list) diff --git a/config/locales/layout.en.yml b/config/locales/layout.en.yml index 94659ac41..ac1790dd0 100644 --- a/config/locales/layout.en.yml +++ b/config/locales/layout.en.yml @@ -4,6 +4,8 @@ en: turned_on: on turned_off: off + list: List + year: year enter_commit_message: Commit message diff --git a/config/locales/layout.ru.yml b/config/locales/layout.ru.yml index 7b66a589e..ba70c945d 100644 --- a/config/locales/layout.ru.yml +++ b/config/locales/layout.ru.yml @@ -4,6 +4,8 @@ ru: turned_on: включены turned_off: выключены + list: Список + year: год enter_commit_message: Сопровождающее сообщение diff --git a/config/locales/menu.en.yml b/config/locales/menu.en.yml index 6af41623b..73d6e994b 100644 --- a/config/locales/menu.en.yml +++ b/config/locales/menu.en.yml @@ -8,6 +8,7 @@ en: projects: Projects build_lists: Task monitoring groups: Groups + advisories: Advisories bottom_menu: copyright: ROSA Lab © 2012 about: About the company diff --git a/config/locales/menu.ru.yml b/config/locales/menu.ru.yml index 209b30527..0c7c10a16 100644 --- a/config/locales/menu.ru.yml +++ b/config/locales/menu.ru.yml @@ -8,6 +8,7 @@ ru: projects: Проекты build_lists: Мониторинг задач groups: Группы + advisories: Бюллетени bottom_menu: copyright: ROSA Лаб. © 2012 about: О компании diff --git a/config/locales/models/advisory.en.yml b/config/locales/models/advisory.en.yml new file mode 100644 index 000000000..027dd62bf --- /dev/null +++ b/config/locales/models/advisory.en.yml @@ -0,0 +1,22 @@ +en: + layout: + advisories: + list_header: Advisories + form_header: New advisory + project_name: Project + affected_versions: Affected versions + ref_comment: Add links one by row + + flash: + advisories: + + activerecord: + models: + advisory: Advisory + + attributes: + advisory: + created_at: Creation date + advisory_id: Identifier + description: Description + references: References diff --git a/config/locales/models/advisory.ru.yml b/config/locales/models/advisory.ru.yml new file mode 100644 index 000000000..169bf5f70 --- /dev/null +++ b/config/locales/models/advisory.ru.yml @@ -0,0 +1,22 @@ +ru: + layout: + advisories: + list_header: Бюллетени + form_header: Новый бюллетень + project_name: Проект + affected_versions: Применен в версиях + ref_comment: Вставляйте ссылки по одной на строку + + flash: + advisories: + + activerecord: + models: + advisory: Бюллетень + + attributes: + advisory: + created_at: Дата создания + advisory_id: Идентификатор + description: Описание проблемы + references: Ссылки diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index b6654d7ab..2bc81b4e5 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -62,9 +62,13 @@ en: action: Action new_header: New build main_data: Main data + human_current_duration: Build currently takes %{hours} h. %{minutes} min. human_duration: Builded in %{hours} h. %{minutes} min. + attached_advisory: Attached advisory + create_advisory: Create new advisory + ownership: header: Build list ownership owned: My diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 8eb14665b..91010938c 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -65,6 +65,9 @@ ru: human_current_duration: Сборка длится уже %{hours} ч. %{minutes} мин. human_duration: Собрано за %{hours} ч. %{minutes} мин. + attached_advisory: Связанный бюллетень + create_advisory: Создать новый бюллетень + ownership: header: Принадлежность заданий owned: Мне diff --git a/config/routes.rb b/config/routes.rb index fa9245d3d..d6d1c3dff 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -34,6 +34,10 @@ Rosa::Application.routes.draw do resources :event_logs, :only => :index end + scope :module => 'advisories' do + resources :advisories, :only => [:index, :show] + end + scope :module => 'platforms' do resources :platforms do resources :private_users, :except => [:show, :destroy, :update] @@ -60,7 +64,6 @@ Rosa::Application.routes.draw do end match '/private/:platform_name/*file_path' => 'privates#show' - resources :advisories, :only => [:index, :show] resources :product_build_lists, :only => [:index] end From 8819d0845af7131e9c55dd164365b8c80f00448d Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Sat, 5 May 2012 23:26:34 +0400 Subject: [PATCH 4/8] [refs 428] Fix tests and merges missing --- app/controllers/projects/build_lists_controller.rb | 2 +- spec/factories/build_lists.rb | 2 +- spec/models/cancan_spec.rb | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 6e497de1e..f90402ae9 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -48,7 +48,7 @@ class Projects::BuildListsController < Projects::BaseController @build_list.commit_hash = @project.git_repository.commits(@build_list.project_version.match(/^latest_(.+)/).to_a.last || @build_list.project_version).first.id if @build_list.project_version @build_list.build_for_platform = build_for_platform; @build_list.arch = arch; @build_list.user = current_user @build_list.include_repos = @build_list.include_repos.select {|ir| @build_list.build_for_platform.repository_ids.include? ir.to_i} - @build_list.priority = 100 # User builds more priority than mass rebuild with zero priority + @build_list.priority = current_user.build_priority # User builds more priority than mass rebuild with zero priority flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :build_for_platform => build_for_platform.name, :save_to_platform => @build_list.save_to_platform} if @build_list.save notices << t("flash.build_list.saved", flash_options) diff --git a/spec/factories/build_lists.rb b/spec/factories/build_lists.rb index 2a08e1b9d..88dda9c27 100644 --- a/spec/factories/build_lists.rb +++ b/spec/factories/build_lists.rb @@ -3,7 +3,7 @@ FactoryGirl.define do factory :build_list do association :user association :project - association save_to_platform, :factory => :platform_with_repos + association :save_to_platform, :factory => :platform_with_repos association :arch build_for_platform {|bl| bl.save_to_platform} project_version "1.0" diff --git a/spec/models/cancan_spec.rb b/spec/models/cancan_spec.rb index d2317f33b..652d77834 100644 --- a/spec/models/cancan_spec.rb +++ b/spec/models/cancan_spec.rb @@ -94,7 +94,9 @@ describe CanCan do end end - it { @ability.should be_able_to(:show, User) } + it "shoud be able to show user profile" do + @ability.should be_able_to(:show, User) + end it "shoud be able to read another user object" do admin_create From 52f5e01575141638a4ce788eb2c61d7c7efd7e80 Mon Sep 17 00:00:00 2001 From: Pavel Chipiga Date: Sun, 6 May 2012 00:43:04 +0300 Subject: [PATCH 5/8] Fix build list controller bugs. Fix JS which controls checkboxes. Fix translations. Fix and refactor views. Refs #428 --- app/assets/javascripts/extra/build_list.js | 10 +++++----- app/controllers/projects/build_lists_controller.rb | 4 ++-- app/views/projects/build_lists/new.html.haml | 12 ++++-------- config/locales/models/build_list.en.yml | 10 ++++------ config/locales/models/build_list.ru.yml | 10 ++++------ db/schema.rb | 7 ++++--- 6 files changed, 23 insertions(+), 30 deletions(-) diff --git a/app/assets/javascripts/extra/build_list.js b/app/assets/javascripts/extra/build_list.js index 96cc24836..ef50c2b2d 100644 --- a/app/assets/javascripts/extra/build_list.js +++ b/app/assets/javascripts/extra/build_list.js @@ -1,5 +1,5 @@ $(document).ready(function() { - $('#build_list_pl_id').change(function() { + $('#build_list_save_to_platform_id').change(function() { var platform_id = $(this).val(); var base_platforms = $('.all_platforms input[type=checkbox].build_bpl_ids'); @@ -15,7 +15,7 @@ $(document).ready(function() { $(this).attr('checked', 'checked').removeAttr('disabled').trigger('change'); $(this).parent().find('.offset25 input[type="checkbox"]').removeAttr('disabled'); - var rep_name = $('#build_list_pl_id option[value="' + $(this).val() + '"]').text().match(/[\w-]+\/([\w-]+)/)[1]; + var rep_name = $('#build_list_save_to_platform_id option[value="' + $(this).val() + '"]').text().match(/[\w-]+\/([\w-]+)/)[1]; if (rep_name != 'main') { $(this).parent().find('.offset25 input[type="checkbox"][rep_name="' + rep_name + '"]').attr('checked', 'checked'); } @@ -33,7 +33,7 @@ $(document).ready(function() { setBranchSelected(); }); - $('#build_list_pl_id').trigger('change'); + $('#build_list_save_to_platform_id').trigger('change'); $('.offset25 label').click(function() { setPlChecked($(this).prev()[0], !$(this).prev().attr('checked')); @@ -58,10 +58,10 @@ function setPlChecked(pointer, checked) { } function setBranchSelected() { - var pl_id = $('#build_list_pl_id').val(); + var pl_id = $('#build_list_save_to_platform_id').val(); // Checks if selected platform is main or not: if ( $('.all_platforms').find('input[type="checkbox"][value=' + pl_id + '].build_bpl_ids').size() > 0 ) { - var pl_name = $('#build_list_pl_id option[value="' + pl_id + '"]').text().match(/([\w-]+)\/[\w-]+/)[1]; + var pl_name = $('#build_list_save_to_platform_id option[value="' + pl_id + '"]').text().match(/([\w-]+)\/[\w-]+/)[1]; var branch_pl_opt = $('#build_list_project_version option[value="latest_' + pl_name + '"]'); // If there is branch we need - set it selected: if ( branch_pl_opt.size() > 0 ) { diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index f90402ae9..55cd119e0 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -40,7 +40,7 @@ class Projects::BuildListsController < Projects::BaseController def create notices, errors = [], [] - @platform = Platform.find params[:build_list][:pl_id] + @platform = Platform.find params[:build_list][:save_to_platform_id] params[:build_list][:auto_publish] = false if @platform.released Arch.where(:id => params[:arches]).each do |arch| Platform.main.where(:id => params[:build_for_platforms]).each do |build_for_platform| @@ -49,7 +49,7 @@ class Projects::BuildListsController < Projects::BaseController @build_list.build_for_platform = build_for_platform; @build_list.arch = arch; @build_list.user = current_user @build_list.include_repos = @build_list.include_repos.select {|ir| @build_list.build_for_platform.repository_ids.include? ir.to_i} @build_list.priority = current_user.build_priority # User builds more priority than mass rebuild with zero priority - flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :build_for_platform => build_for_platform.name, :save_to_platform => @build_list.save_to_platform} + flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :build_for_platform => build_for_platform.name} if @build_list.save notices << t("flash.build_list.saved", flash_options) else diff --git a/app/views/projects/build_lists/new.html.haml b/app/views/projects/build_lists/new.html.haml index 22f38e5cf..10024025a 100644 --- a/app/views/projects/build_lists/new.html.haml +++ b/app/views/projects/build_lists/new.html.haml @@ -1,17 +1,16 @@ -set_meta_tags :title => [title_object(@project), t('layout.build_lists.new_header')] = form_for [@project, @build_list], :html => { :class => :form, :method => :post } do |f| %section.left - %h3= t("activerecord.attributes.build_list.build_for_platofrm") + %h3= t("activerecord.attributes.build_list.build_for_platform") .all_platforms - Platform.main.each do |pl| - if pl.repository_ids.size > 0 .both = check_box_tag "build_for_platforms[]", pl.id, (params[:build_for_platforms]||[]).include?(pl.id.to_s), :class => 'build_bpl_ids', :id => "bpls_#{pl.id}", :'data-released' => pl.released ? 1 : 0 = label_tag "bpls_#{pl.id}", pl.name - .offset25{:style => 'padding-left: 25px'} - = render 'include_repos', :platform => pl + .offset25{:style => 'padding-left: 25px'}= render 'include_repos', :platform => pl %section.right - %h3= t("activerecord.attributes.build_list.pl") + %h3= t("activerecord.attributes.build_list.save_to_platform") .lineForm= f.select :save_to_platform_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.platform.id]} %h3= t("activerecord.attributes.build_list.project_version") - if controller.action_name == 'new' @@ -21,10 +20,7 @@ %h3= t("activerecord.attributes.build_list.arch") - Arch.recent.each do |arch| .both - - if controller.action_name == 'new' - = check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s), :id => "arches_#{arch.id}", :checked => 'checked' - - else - = check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s), :id => "arches_#{arch.id}" + = check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s) || controller.action_name == 'new', :id => "arches_#{arch.id}" = label_tag "arches_#{arch.id}", arch.name %h3= t("activerecord.attributes.build_list.update_type") .lineForm= f.select :update_type, BuildList::UPDATE_TYPES diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 2bc81b4e5..10c97a048 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -18,10 +18,8 @@ en: additional_repos: Additional repositories include_repos: Included repositories created_at: Created on - pl: Repository for package storage - pl_id: Repository for package storage - bpl: Platform - bpl_id: Platform + save_to_platform: Repository for package storage + build_for_platform: Platform update_type: Update type build_requires: Build with all the required packages auto_publish: Automated publising @@ -111,8 +109,8 @@ en: flash: build_list: - saved: Build list for project version '%{project_version}', platform '%{bpl}' and architecture '%{arch}' has been created successfully - save_error: Build list for project version '%{project_version}', platform '%{bpl}' and architecture '%{arch}' could not been created + saved: Build list for project version '%{project_version}', platform '%{build_for_platform}' and architecture '%{arch}' has been created successfully + save_error: Build list for project version '%{project_version}', platform '%{build_for_platform}' and architecture '%{arch}' could not been created no_project_version_selected: Select any version of the project no_project_version_found: Project version '%{project_version}' not found no_arch_or_platform_selected: At least one of architecture of platform must selected diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 91010938c..999d44f5d 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -18,10 +18,8 @@ ru: additional_repos: Дополнительные репозитории include_repos: Подключаемые репозитории created_at: Создан - pl: Репозиторий для сохранения пакетов - pl_id: Репозиторий для сохранения пакетов - bpl: Платформа - bpl_id: Платформа + save_to_platform: Репозиторий для сохранения пакетов + build_for_platform: Платформа update_type: Критичность обновления build_requires: Пересборка с зависимостями auto_publish: Автоматическая публикация @@ -110,8 +108,8 @@ ru: flash: build_list: - saved: Билд лист для версии '%{project_version}', платформы '%{bpl}' и архитектуры '%{arch}' создан успешно - save_error: Не удалось сохранить билд лист для версии '%{project_version}', платформы '%{bpl}' и архитектуры '%{arch}' + saved: Билд лист для версии '%{project_version}', платформы '%{build_for_platform}' и архитектуры '%{arch}' создан успешно + save_error: Не удалось сохранить билд лист для версии '%{project_version}', платформы '%{build_for_platform}' и архитектуры '%{arch}' no_project_version_selected: Выберите какую-нибудь версию no_project_version_found: Выбранная версия '%{project_version}' не найдена no_arch_or_platform_selected: Выберите хотя бы одну архитектуру и платформу diff --git a/db/schema.rb b/db/schema.rb index b0f8d66a6..5e397546f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -205,7 +205,7 @@ ActiveRecord::Schema.define(:version => 20120505101650) do t.string "owner_type" t.string "visibility", :default => "open", :null => false t.string "platform_type", :default => "main", :null => false - t.string "distrib_type" + t.string "distrib_type", :null => false end add_index "platforms", ["name"], :name => "index_platforms_on_name", :unique => true, :case_sensitive => false @@ -276,11 +276,11 @@ ActiveRecord::Schema.define(:version => 20120505101650) 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_rpm", :default => true t.integer "average_build_time", :default => 0, :null => false @@ -302,6 +302,7 @@ ActiveRecord::Schema.define(:version => 20120505101650) do end add_index "register_requests", ["email"], :name => "index_register_requests_on_email", :unique => true, :case_sensitive => false + add_index "register_requests", ["token"], :name => "index_register_requests_on_token", :unique => true, :case_sensitive => false create_table "relations", :force => true do |t| t.integer "actor_id" @@ -350,13 +351,13 @@ ActiveRecord::Schema.define(:version => 20120505101650) do t.string "email", :default => "", :null => false t.string "encrypted_password", :limit => 128, :default => "", :null => false t.string "reset_password_token" - t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.datetime "created_at" t.datetime "updated_at" t.string "uname" t.string "role" t.string "language", :default => "en" + t.datetime "reset_password_sent_at" t.integer "own_projects_count", :default => 0, :null => false t.text "professional_experience" t.string "site" From f8d32495b8253701b5e119cacf5d887a25375aa7 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Thu, 10 May 2012 19:15:50 +0400 Subject: [PATCH 6/8] [issue #428] Added title. Changed BuildListsController#update --- .../projects/build_lists_controller.rb | 15 +++++++-------- app/helpers/application_helper.rb | 1 + app/views/advisories/advisories/show.html.haml | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 55cd119e0..76098dc45 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -73,15 +73,14 @@ class Projects::BuildListsController < Projects::BaseController end def update - # King Arthur, we are under attack! - if ( !@build_list.can_publish? || cannot?(:publish, @build_list) ) && params[:publish].present? or - ( !@build_list.can_reject_publish? || cannot?(:reject_publish, @build_list) ) && params[:reject_publish].present? - redirect_to :forbidden and return + if params[:publish].present? and can?(:publish, @build_list) + publish + elsif params[:reject_publish].present? and can?(:reject_publish) + reject_publish + else + # King Arthur, we are under attack! + redirect_to :forbidden and return end - #raise - publish if params[:publish].present? - reject_publish if params[:reject_publish].present? - #raise end def cancel diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e429b3b53..f46427676 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -22,6 +22,7 @@ module ApplicationHelper end def title_object object + return object.advisory_id if object.class == Advisory name = object.class == Group ? object.uname : object.name object_name = t "activerecord.models.#{object.class.name.downcase}" case object.class.name diff --git a/app/views/advisories/advisories/show.html.haml b/app/views/advisories/advisories/show.html.haml index 5aba87462..99ea5e348 100644 --- a/app/views/advisories/advisories/show.html.haml +++ b/app/views/advisories/advisories/show.html.haml @@ -1,4 +1,4 @@ --#set_meta_tags :title => [title_object(@build_list.project), t('activerecord.models.build_list')] +- set_meta_tags :title => [title_object(@advisory), t('activerecord.models.advisory')] - render :partial => 'submenu' %h3= "#{t("activerecord.models.advisory")} #{@advisory.advisory_id}".html_safe @@ -18,7 +18,7 @@ .leftlist= "#{t("layout.advisories.affected_versions")}:".html_safe .rightlist - @advisory.platforms.each do |platform| - = link_to platform_printed_name(platform), platform_path(platform) + = link_to platfrom_printed_name(platform), platform_path(platform) %br .both From 9a0f582a16d07910071c76fca51aec11e6788a13 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Thu, 10 May 2012 19:30:41 +0400 Subject: [PATCH 7/8] [issue #428] Fixed typo in PlatformsHelper --- app/helpers/platforms_helper.rb | 6 +++--- app/views/advisories/advisories/_list_item.html.haml | 2 +- app/views/advisories/advisories/show.html.haml | 2 +- app/views/platforms/base/_submenu.html.haml | 2 +- app/views/platforms/platforms/_list.html.haml | 4 ++-- app/views/projects/build_lists/show.html.haml | 2 -- spec/models/platform_spec.rb | 2 +- 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/helpers/platforms_helper.rb b/app/helpers/platforms_helper.rb index fffc69c94..4ad7df6ac 100644 --- a/app/helpers/platforms_helper.rb +++ b/app/helpers/platforms_helper.rb @@ -4,10 +4,10 @@ module PlatformsHelper return "" unless platform return platform.released ? '/update' : '/release' end - - def platfrom_printed_name(platform) + + def platform_printed_name(platform) return "" unless platform platform.released? ? "#{platform.name} #{I18n.t("layout.platforms.released_suffix")}" : platform.name end - + end diff --git a/app/views/advisories/advisories/_list_item.html.haml b/app/views/advisories/advisories/_list_item.html.haml index 671b43854..21486904f 100644 --- a/app/views/advisories/advisories/_list_item.html.haml +++ b/app/views/advisories/advisories/_list_item.html.haml @@ -2,6 +2,6 @@ %td= link_to advisory.advisory_id, advisory_path(advisory) %td - advisory.platforms.each do |platform| - = link_to platfrom_printed_name(platform), platform_path(platform) + = link_to platform_printed_name(platform), platform_path(platform) %br %td= truncate(advisory.description, :length => 50) diff --git a/app/views/advisories/advisories/show.html.haml b/app/views/advisories/advisories/show.html.haml index 99ea5e348..483ba81a9 100644 --- a/app/views/advisories/advisories/show.html.haml +++ b/app/views/advisories/advisories/show.html.haml @@ -18,7 +18,7 @@ .leftlist= "#{t("layout.advisories.affected_versions")}:".html_safe .rightlist - @advisory.platforms.each do |platform| - = link_to platfrom_printed_name(platform), platform_path(platform) + = link_to platform_printed_name(platform), platform_path(platform) %br .both diff --git a/app/views/platforms/base/_submenu.html.haml b/app/views/platforms/base/_submenu.html.haml index 002546ebf..072971af2 100644 --- a/app/views/platforms/base/_submenu.html.haml +++ b/app/views/platforms/base/_submenu.html.haml @@ -1,5 +1,5 @@ - content_for :submenu do - act = action_name.to_sym; contr = controller_name.to_sym - .left= platfrom_printed_name(@platform) + .left= platform_printed_name(@platform) %nav %ul diff --git a/app/views/platforms/platforms/_list.html.haml b/app/views/platforms/platforms/_list.html.haml index b146945a7..1ac3c3353 100644 --- a/app/views/platforms/platforms/_list.html.haml +++ b/app/views/platforms/platforms/_list.html.haml @@ -6,5 +6,5 @@ %tbody - @platforms.each do |platform| %tr{:class => cycle("odd", "even")} - %td= link_to platfrom_printed_name(platform), platform_path(platform) - %td= platform.distrib_type \ No newline at end of file + %td= link_to platform_printed_name(platform), platform_path(platform) + %td= platform.distrib_type diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 2c0ea1baf..b98aed63b 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -78,8 +78,6 @@ = f.fields_for @build_list.build_advisory do |f| = render :partial => 'advisories/advisories/form', :locals => {:f => f} - =# link_to t("layout.publish"), publish_build_list_path(@build_list), :method => "put", :confirm => t("layout.confirm"), :class => "button tmargin10" if @build_list.can_publish? and can?(:publish, @build_list) - =# link_to t("layout.reject_publish"), reject_publish_build_list_path(@build_list), :method => "put", :confirm => t("layout.confirm"), :class => "button tmargin10" if @build_list.can_reject_publish? and can?(:reject_publish, @build_list) = submit_tag t("layout.publish"), :confirm => t("layout.confirm"), :name => 'publish' if @build_list.can_publish? and can?(:publish, @build_list) = submit_tag t("layout.reject_publish"), :confirm => t("layout.confirm"), :name => 'reject_publish' if @build_list.can_reject_publish? and can?(:reject_publish, @build_list) diff --git a/spec/models/platform_spec.rb b/spec/models/platform_spec.rb index bb780e03f..d8487ee1a 100644 --- a/spec/models/platform_spec.rb +++ b/spec/models/platform_spec.rb @@ -18,7 +18,7 @@ describe Platform do it { should validate_presence_of(:name)} it { should validate_uniqueness_of(:name).case_insensitive } - it { should validate_format_of(:name).with('Basic_platfrom-name-1234') } + it { should validate_format_of(:name).with('Basic_platform-name-1234') } it { should validate_format_of(:name).not_with('.!') } it { should validate_presence_of(:description) } it { should validate_presence_of(:distrib_type) } From 5320fc2d3e8b83dc24f6d58a74de772a9272d9bf Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Thu, 10 May 2012 21:17:59 +0400 Subject: [PATCH 8/8] [issue #428] AdvisoriesController moved from its scope --- app/controllers/advisories/base_controller.rb | 3 --- app/controllers/{advisories => }/advisories_controller.rb | 2 +- app/views/advisories/{advisories => }/_form.html.haml | 0 app/views/advisories/{advisories => }/_list.html.haml | 0 app/views/advisories/{advisories => }/_list_item.html.haml | 0 app/views/advisories/{base => }/_submenu.html.haml | 0 app/views/advisories/{advisories => }/index.html.haml | 0 app/views/advisories/{advisories => }/show.html.haml | 0 config/routes.rb | 4 +--- 9 files changed, 2 insertions(+), 7 deletions(-) delete mode 100644 app/controllers/advisories/base_controller.rb rename app/controllers/{advisories => }/advisories_controller.rb (84%) rename app/views/advisories/{advisories => }/_form.html.haml (100%) rename app/views/advisories/{advisories => }/_list.html.haml (100%) rename app/views/advisories/{advisories => }/_list_item.html.haml (100%) rename app/views/advisories/{base => }/_submenu.html.haml (100%) rename app/views/advisories/{advisories => }/index.html.haml (100%) rename app/views/advisories/{advisories => }/show.html.haml (100%) diff --git a/app/controllers/advisories/base_controller.rb b/app/controllers/advisories/base_controller.rb deleted file mode 100644 index 25d327da1..000000000 --- a/app/controllers/advisories/base_controller.rb +++ /dev/null @@ -1,3 +0,0 @@ -# -*- encoding : utf-8 -*- -class Advisories::BaseController < ApplicationController -end diff --git a/app/controllers/advisories/advisories_controller.rb b/app/controllers/advisories_controller.rb similarity index 84% rename from app/controllers/advisories/advisories_controller.rb rename to app/controllers/advisories_controller.rb index 068b44e8a..447a6bb5a 100644 --- a/app/controllers/advisories/advisories_controller.rb +++ b/app/controllers/advisories_controller.rb @@ -1,5 +1,5 @@ # -*- encoding : utf-8 -*- -class Advisories::AdvisoriesController < Advisories::BaseController +class AdvisoriesController < ApplicationController before_filter :authenticate_user! before_filter :find_advisory, :only => [:show] load_and_authorize_resource diff --git a/app/views/advisories/advisories/_form.html.haml b/app/views/advisories/_form.html.haml similarity index 100% rename from app/views/advisories/advisories/_form.html.haml rename to app/views/advisories/_form.html.haml diff --git a/app/views/advisories/advisories/_list.html.haml b/app/views/advisories/_list.html.haml similarity index 100% rename from app/views/advisories/advisories/_list.html.haml rename to app/views/advisories/_list.html.haml diff --git a/app/views/advisories/advisories/_list_item.html.haml b/app/views/advisories/_list_item.html.haml similarity index 100% rename from app/views/advisories/advisories/_list_item.html.haml rename to app/views/advisories/_list_item.html.haml diff --git a/app/views/advisories/base/_submenu.html.haml b/app/views/advisories/_submenu.html.haml similarity index 100% rename from app/views/advisories/base/_submenu.html.haml rename to app/views/advisories/_submenu.html.haml diff --git a/app/views/advisories/advisories/index.html.haml b/app/views/advisories/index.html.haml similarity index 100% rename from app/views/advisories/advisories/index.html.haml rename to app/views/advisories/index.html.haml diff --git a/app/views/advisories/advisories/show.html.haml b/app/views/advisories/show.html.haml similarity index 100% rename from app/views/advisories/advisories/show.html.haml rename to app/views/advisories/show.html.haml diff --git a/config/routes.rb b/config/routes.rb index d6d1c3dff..bf0507f5e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -34,9 +34,7 @@ Rosa::Application.routes.draw do resources :event_logs, :only => :index end - scope :module => 'advisories' do - resources :advisories, :only => [:index, :show] - end + resources :advisories, :only => [:index, :show] scope :module => 'platforms' do resources :platforms do