From 31d9f547438c51d3a1c42b1bcc003de221b05d8f Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 17 Apr 2012 13:37:09 +0400 Subject: [PATCH 1/6] [refs #223] Move project version to right column --- app/views/build_lists/new.html.haml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/build_lists/new.html.haml b/app/views/build_lists/new.html.haml index f3beb7290..6ec2c8024 100644 --- a/app/views/build_lists/new.html.haml +++ b/app/views/build_lists/new.html.haml @@ -1,11 +1,6 @@ -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.project_version") - - if controller.action_name == 'new' - .lineForm= f.select :project_version, @project.versions_for_group_select, :selected => "latest_" + @project.default_branch - - else - .lineForm= f.select :project_version, @project.versions_for_group_select %h3= t("activerecord.attributes.build_list.bpl") .all_platforms - Platform.main.each do |pl| @@ -16,6 +11,13 @@ .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]} + %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 + - else + .lineForm= f.select :project_version, @project.versions_for_group_select %h3= t("activerecord.attributes.build_list.arch") - Arch.recent.each do |arch| .both @@ -24,8 +26,6 @@ - else = check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s), :id => "arches_#{arch.id}" = label_tag "arches_#{arch.id}", arch.name - %h3= t("activerecord.attributes.build_list.pl") - .lineForm= f.select :pl_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.platform.id]} %h3= t("activerecord.attributes.build_list.update_type") .lineForm= f.select :update_type, BuildList::UPDATE_TYPES %h3= t("activerecord.attributes.build_list.preferences") From 2716c196357946e9e9676825ec7b959d7695630d Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 17 Apr 2012 16:18:03 +0600 Subject: [PATCH 2/6] [refs #385] add anonymous access to project archive --- app/controllers/git/base_controller.rb | 2 +- app/controllers/git/trees_controller.rb | 14 ++++++++++++++ app/controllers/projects_controller.rb | 13 ------------- app/models/ability.rb | 6 +++--- config/routes.rb | 2 +- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/app/controllers/git/base_controller.rb b/app/controllers/git/base_controller.rb index c9d33ba2c..08e9def92 100644 --- a/app/controllers/git/base_controller.rb +++ b/app/controllers/git/base_controller.rb @@ -1,7 +1,7 @@ # -*- encoding : utf-8 -*- class Git::BaseController < ApplicationController before_filter :authenticate_user! - skip_before_filter :authenticate_user!, :only => [:show, :index, :blame, :raw] if APP_CONFIG['anonymous_access'] + skip_before_filter :authenticate_user!, :only => [:show, :index, :blame, :raw, :archive] if APP_CONFIG['anonymous_access'] load_and_authorize_resource :project before_filter :find_git_repository diff --git a/app/controllers/git/trees_controller.rb b/app/controllers/git/trees_controller.rb index 47cc15392..c60650ae7 100644 --- a/app/controllers/git/trees_controller.rb +++ b/app/controllers/git/trees_controller.rb @@ -15,4 +15,18 @@ class Git::TreesController < Git::BaseController @tree = @tree / @path if @path render :template => "git/trees/show" end + + def archive + treeish = params[:treeish].presence || @project.default_branch + format = params[:format] || 'tar' + commit = @project.git_repository.log(treeish, nil, :max_count => 1).first + name = "#{@project.owner.uname}-#{@project.name}#{@project.tags.include?(treeish) ? "-#{treeish}" : ''}-#{commit.id[0..19]}" + fullname = "#{name}.#{format == 'tar' ? 'tar.gz' : 'zip'}" + file = Tempfile.new fullname, 'tmp' + system("cd #{@project.path}; git archive --format=#{format} --prefix=#{name}/ #{treeish} #{format == 'tar' ? ' | gzip -9' : ''} > #{file.path}") + file.close + send_file file.path, :disposition => 'attachment', :type => "application/#{format == 'tar' ? 'x-tar-gz' : 'zip'}", + :filename => fullname + end + end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 9df8768ad..8f9a949ad 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -86,19 +86,6 @@ class ProjectsController < ApplicationController redirect_to projects_path end - def archive - treeish = params[:treeish].presence || @project.default_branch - format = params[:format] || 'tar' - commit = @project.git_repository.log(treeish, nil, :max_count => 1).first - name = "#{@project.owner.uname}-#{@project.name}#{@project.tags.include?(treeish) ? "-#{treeish}" : ''}-#{commit.id[0..19]}" - fullname = "#{name}.#{format == 'tar' ? 'tar.gz' : 'zip'}" - file = Tempfile.new fullname, 'tmp' - system("cd #{@project.path}; git archive --format=#{format} --prefix=#{name}/ #{treeish} #{format == 'tar' ? ' | gzip -9' : ''} > #{file.path}") - file.close - send_file file.path, :disposition => 'attachment', :type => "application/#{format == 'tar' ? 'x-tar-gz' : 'zip'}", - :filename => fullname - end - protected def prepare_list(projects) diff --git a/app/models/ability.rb b/app/models/ability.rb index 17eadf3bc..7513485f4 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -14,6 +14,7 @@ class Ability # Shared rights between guests and registered users can :show, Project, :visibility => 'open' + can :archive, Project, :visibility => 'open' can :read, Issue, :project => {:visibility => 'open'} can :search, BuildList can :read, BuildList, :project => {:visibility => 'open'} @@ -51,8 +52,8 @@ class Ability can :create, Project can :read, Project, :visibility => 'open' - can :read, Project, :owner_type => 'User', :owner_id => user.id - can :read, Project, :owner_type => 'Group', :owner_id => user.group_ids + can [:read, :archive], Project, :owner_type => 'User', :owner_id => user.id + can [:read, :archive], Project, :owner_type => 'Group', :owner_id => user.group_ids can([:read, :membered], Project, read_relations_for('projects')) {|project| local_reader? project} can(:write, Project) {|project| local_writer? project} # for grack can([:update, :sections, :manage_collaborators], Project) {|project| local_admin? project} @@ -61,7 +62,6 @@ class Ability can(:destroy, Project) {|project| owner? project} can(:destroy, Project) {|project| project.owner_type == 'Group' and project.owner.objects.exists?(:object_type => 'User', :object_id => user.id, :role => 'admin')} can :remove_user, Project - can :archive, Project can [:read, :owned], BuildList, :user_id => user.id can [:read, :related], BuildList, :project => {:owner_type => 'User', :owner_id => user.id} diff --git a/config/routes.rb b/config/routes.rb index 346266c16..288d4a022 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -154,7 +154,7 @@ Rosa::Application.routes.draw do # Raw get '/projects/:project_id/raw/:treeish/*path' => "git/blobs#raw", :defaults => {:treeish => :master}, :as => :raw, :format => false - get '/projects/:id/archive/:format/tree/:treeish' => "projects#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/ + get '/projects/:project_id/archive/:format/tree/:treeish' => "git/trees#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/ # Core callbacks match 'build_lists/publish_build', :to => "build_lists#publish_build" From 05ec6cbac33833651ab634b08675de98611a9ed7 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 17 Apr 2012 16:21:45 +0600 Subject: [PATCH 3/6] [refs #385] removed dublicate ability --- app/models/ability.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index 7513485f4..906681a3b 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -51,7 +51,6 @@ class Ability can :destroy, Group, :owner_id => user.id can :create, Project - can :read, Project, :visibility => 'open' can [:read, :archive], Project, :owner_type => 'User', :owner_id => user.id can [:read, :archive], Project, :owner_type => 'Group', :owner_id => user.group_ids can([:read, :membered], Project, read_relations_for('projects')) {|project| local_reader? project} From f31b243ae98c058fc92c019f8caa6e8e8daf4a0b Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 17 Apr 2012 18:06:04 +0600 Subject: [PATCH 4/6] [refs #385] zip image --- app/assets/images/zip.png | Bin 0 -> 1581 bytes app/assets/stylesheets/design/custom.scss | 7 ++++++- app/views/projects/_repo_block.html.haml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 app/assets/images/zip.png diff --git a/app/assets/images/zip.png b/app/assets/images/zip.png new file mode 100644 index 0000000000000000000000000000000000000000..e846109e8f2af71c04f07182403374e6a122cb26 GIT binary patch literal 1581 zcmV+|2GaS7P)KLZ*U+R`sCEkzKl)gj5&q@hY_5?)@_euSf22N!q0z{yc?Q2YY_Kym8e z5Fvwu2%hQO!{u_psMvL#(bD64NQRTZj^-}DnS22ry9f-;mW=gZvQj}U-ZdMsK&I8^7~DvX`q=iwre+fV0JLOWP&#ogW70ErSwAP`Af;|7QVgR!!neROMg z`n7(a4=-FB=EgvMlK1Ak=Y5|4`+Lth|07tI#nWgsu10_eFaV4I#|{hyD^FS{JSku_ zuKIvsk4rwhC*-HYDe>n_o_q7fE5OKsq2TEa4J^xg?1;va?~KNi)*oulGECEYREznl z_2cz9D;i6l+{j}i^G`3_n6s9OHS2Mz>xLD-pRuB`_GL}SVQ(OB}Qu_?{c zjn!4(eK>D@e)`gypc$=fog166qOs(OfBLODgVDHpvdu0YeWBln;&t+GRBM=wCp2cW zmG4&0=9ktXkH*!#K%~#_dOh6Vg)G_tICSd!RVHt}x|{I{m0g2DF8+FlOl}!~_uqJh z!L14a$)z&m2@Tz_jvN>Yo)V(5q~efm^SkudqFfz4RIzOJsq8qEM#U7VD;5PCLiHIgiU} z=iU7;0Z^$Mj3qQuxhl_eyXo<|5GFJA6Y64NSWOoYZ32>LOYd0qu zpHNo?s!L_Y6IseN9o;Z-Ic0W+0=Fb!B)G{Pw#(wahp8O(hQY05j=5}wJt03Hm%QQQ z*)UA5C$c2cC3M5YG%W&M?QB!L03*U=rmi$}bG}%q;d01K&Sfc-YDl6Dhb*$a*UfWV z+^n~mRIbWcLZet|(9linvdF-eE_B1B%`Va2WZT2#|w9HJp&_omwCNp&f7+%Ph zA`eqJ1VJF!XidWzjjI5J2NWMLT&^|_HxX_2chI-VgSuFt*3j7+@UT> li > a:hover { text-decoration: none; - background-color: #D6E4E1; + background-color: #DCECFA; } .dropdown-menu { min-width: 0; +} + +.dropdown.open .dropdown-toggle { + background: none repeat scroll 0 0; } \ No newline at end of file diff --git a/app/views/projects/_repo_block.html.haml b/app/views/projects/_repo_block.html.haml index 00bbc416c..2a7cca771 100644 --- a/app/views/projects/_repo_block.html.haml +++ b/app/views/projects/_repo_block.html.haml @@ -2,7 +2,7 @@ %ul.nav.zip %li#menu-archive.dropdown %a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#menu-archive"} - ZIP + =image_tag 'zip.png', :alt => 'ZIP' %b.caret %ul.dropdown-menu %li=link_to "tar.gz", archive_path(project.id, 'tar', @treeish) From 644b95d5bd5fb5bed42aa98e8dd4dea79a5cfac5 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 17 Apr 2012 19:52:52 +0600 Subject: [PATCH 5/6] Fuuu! Revert "[refs #385] removed dublicate ability" This reverts commit 72de5731722f0a5b7110983ecb97cba1beda3056. --- app/models/ability.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/ability.rb b/app/models/ability.rb index 906681a3b..7513485f4 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -51,6 +51,7 @@ class Ability can :destroy, Group, :owner_id => user.id can :create, Project + can :read, Project, :visibility => 'open' can [:read, :archive], Project, :owner_type => 'User', :owner_id => user.id can [:read, :archive], Project, :owner_type => 'Group', :owner_id => user.group_ids can([:read, :membered], Project, read_relations_for('projects')) {|project| local_reader? project} From dcdea4b8d39ea781199611b3ce42de6f8ccf25d4 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Tue, 17 Apr 2012 17:56:44 +0400 Subject: [PATCH 6/6] [Refs #404] Remove downloads statistics functional (db and tests) --- db/migrate/20120417133722_remove_downloads.rb | 17 +++++++++++++++++ db/schema.rb | 12 +----------- spec/controllers/downloads_controller_spec.rb | 6 ------ spec/models/download_spec.rb | 6 ------ 4 files changed, 18 insertions(+), 23 deletions(-) create mode 100644 db/migrate/20120417133722_remove_downloads.rb delete mode 100644 spec/controllers/downloads_controller_spec.rb delete mode 100644 spec/models/download_spec.rb diff --git a/db/migrate/20120417133722_remove_downloads.rb b/db/migrate/20120417133722_remove_downloads.rb new file mode 100644 index 000000000..40c07f4d9 --- /dev/null +++ b/db/migrate/20120417133722_remove_downloads.rb @@ -0,0 +1,17 @@ +class RemoveDownloads < ActiveRecord::Migration + def up + drop_table :downloads + end + + def down + create_table "downloads", :force => true do |t| + t.string "name", :null => false + t.string "version" + t.string "distro" + t.string "platform" + t.integer "counter", :default => 0 + t.datetime "created_at" + t.datetime "updated_at" + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 8065f16ee..4fa816b83 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120413160722) do +ActiveRecord::Schema.define(:version => 20120417133722) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -109,16 +109,6 @@ ActiveRecord::Schema.define(:version => 20120413160722) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - create_table "downloads", :force => true do |t| - t.string "name", :null => false - t.string "version" - t.string "distro" - t.string "platform" - t.integer "counter", :default => 0 - t.datetime "created_at" - t.datetime "updated_at" - end - create_table "event_logs", :force => true do |t| t.integer "user_id" t.string "user_name" diff --git a/spec/controllers/downloads_controller_spec.rb b/spec/controllers/downloads_controller_spec.rb deleted file mode 100644 index ee69bcadc..000000000 --- a/spec/controllers/downloads_controller_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -*- encoding : utf-8 -*- -require 'spec_helper' - -describe DownloadsController do - -end diff --git a/spec/models/download_spec.rb b/spec/models/download_spec.rb deleted file mode 100644 index b1856dc57..000000000 --- a/spec/models/download_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -*- encoding : utf-8 -*- -require 'spec_helper' - -describe Download do - pending "add some examples to (or delete) #{__FILE__}" -end