diff --git a/Gemfile b/Gemfile index a11e9337c..f4bcc710b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'http://rubygems.org' -gem 'rails', '3.2.2' #, :git => 'git://github.com/rails/rails.git' +gem 'rails', '3.2.3' #, :git => 'git://github.com/rails/rails.git' gem 'pg', '~> 0.13.2' # gem 'silent-postgres', :git => 'git://github.com/dolzenko/silent-postgres.git' #'~> 0.1.1' @@ -13,7 +13,7 @@ gem 'omniauth-openid', '~> 1.0.1' gem 'cancan', '~> 1.6.7' gem 'ancestry', '~> 1.2.5' -gem 'paperclip', '~> 2.7.0' +gem 'paperclip', '~> 3.0.2' gem 'delayed_job_active_record', '~> 0.3.2' gem 'russian', '~> 0.6.0' gem 'highline', '~> 1.6.11' @@ -37,30 +37,30 @@ gem 'wikicloth' gem 'unicorn', '~> 4.2.1', :platforms => [:mri, :rbx] gem 'trinidad', '~> 1.0.2', :platforms => :jruby -gem 'newrelic_rpm', '~> 3.3.2', :platforms => [:mri, :rbx] +gem 'newrelic_rpm', '~> 3.3.3', :platforms => [:mri, :rbx] gem 'whenever', '~> 0.7.3', :require => false -gem 'rails3-jquery-autocomplete', '~> 1.0.6' +gem 'rails3-jquery-autocomplete', '~> 1.0.7' gem 'will_paginate', '~> 3.0.3' gem 'meta-tags', '~> 1.2.5', :require => 'meta_tags' gem "haml-rails", '~> 0.3.4' -gem 'ruby-haml-js' -gem 'rails-backbone' -gem 'jquery-rails', '~> 2.0.1' +gem 'jquery-rails', '~> 2.0.2' +gem 'ruby-haml-js', '~> 0.0.3' +gem 'rails-backbone', '~> 0.7.2' group :assets do gem 'sass-rails', '~> 3.2.5' gem 'coffee-rails', '~> 3.2.2' gem 'compass-rails', '~> 1.0.1' gem 'uglifier', '~> 1.2.4' - gem 'therubyracer', '~> 0.10.0', :platforms => [:mri, :rbx] + gem 'therubyracer', '~> 0.10.1', :platforms => [:mri, :rbx] gem 'therubyrhino', '~> 1.73.1', :platforms => :jruby end group :production do gem "airbrake", '~> 3.0.9' gem 'bluepill', '~> 0.0.60', :require => false - gem 'daemons', '1.1.6' # for DJ + gem 'daemons', '1.1.6' # Try to upgrade 1.1.8 to avoid tons DJ bugs? end group :development do @@ -70,13 +70,14 @@ group :development do gem 'shotgun' # deploy gem 'capistrano', :require => false + gem 'rvm-capistrano', :require => false gem 'cape', :require => false gem 'capistrano_colors', :require => false end group :test do gem 'rspec-rails', '~> 2.9.0', :group => 'development' - gem 'factory_girl_rails', '~> 3.0.0' + gem 'factory_girl_rails', '~> 3.1.0' gem 'rr', '~> 1.0.4' gem 'shoulda' end diff --git a/Gemfile.lock b/Gemfile.lock index 786cb8c3c..4b3b34f2f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -25,32 +25,31 @@ GEM remote: http://rubygems.org/ specs: RedCloth (4.2.9) - RedCloth (4.2.9-java) - actionmailer (3.2.2) - actionpack (= 3.2.2) - mail (~> 2.4.0) - actionpack (3.2.2) - activemodel (= 3.2.2) - activesupport (= 3.2.2) + actionmailer (3.2.3) + actionpack (= 3.2.3) + mail (~> 2.4.4) + actionpack (3.2.3) + activemodel (= 3.2.3) + activesupport (= 3.2.3) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.1) rack (~> 1.4.0) - rack-cache (~> 1.1) + rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.1.2) - activemodel (3.2.2) - activesupport (= 3.2.2) + activemodel (3.2.3) + activesupport (= 3.2.3) builder (~> 3.0.0) - activerecord (3.2.2) - activemodel (= 3.2.2) - activesupport (= 3.2.2) + activerecord (3.2.3) + activemodel (= 3.2.3) + activesupport (= 3.2.3) arel (~> 3.0.2) tzinfo (~> 0.3.29) - activeresource (3.2.2) - activemodel (= 3.2.2) - activesupport (= 3.2.2) - activesupport (3.2.2) + activeresource (3.2.3) + activemodel (= 3.2.3) + activesupport (= 3.2.3) + activesupport (3.2.3) i18n (~> 0.6) multi_json (~> 1.0) airbrake (3.0.9) @@ -62,7 +61,6 @@ GEM activerecord (>= 2.2.2) arel (3.0.2) bcrypt-ruby (3.0.1) - bcrypt-ruby (3.0.1-java) blankslate (2.1.2.4) bluepill (0.0.60) activesupport (>= 3.0.0) @@ -72,7 +70,7 @@ GEM builder (3.0.0) cancan (1.6.7) cape (1.4.0) - capistrano (2.11.2) + capistrano (2.12.0) highline net-scp (>= 1.0.0) net-sftp (>= 2.0.0) @@ -89,7 +87,7 @@ GEM coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.2.0) + coffee-script-source (1.3.1) compass (0.12.1) chunky_png (~> 1.2) fssm (>= 0.2.7) @@ -98,7 +96,7 @@ GEM compass (~> 0.12.0) creole (0.4.2) daemons (1.1.6) - delayed_job (3.0.1) + delayed_job (3.0.2) activesupport (~> 3.0) delayed_job_active_record (0.3.2) activerecord (> 2.1.0) @@ -113,17 +111,16 @@ GEM ejs (1.0.0) erubis (2.7.0) eventmachine (0.12.10) - eventmachine (0.12.10-java) execjs (1.3.0) multi_json (~> 1.0) expression_parser (0.9.0) - factory_girl (3.0.0) + factory_girl (3.1.1) activesupport (>= 3.0.0) - factory_girl_rails (3.0.0) - factory_girl (~> 3.0.0) + factory_girl_rails (3.1.0) + factory_girl (~> 3.1.0) railties (>= 3.0.0) - fssm (0.2.8.1) - github-markup (0.7.1) + fssm (0.2.9) + github-markup (0.7.2) gollum (1.3.1) albino (~> 1.3.2) github-markup (>= 0.4.0, < 1.0.0) @@ -148,12 +145,10 @@ GEM activesupport (>= 3.0.0) blankslate (>= 2.1.2.4) journey (1.0.3) - jquery-rails (2.0.1) + jquery-rails (2.0.2) railties (>= 3.2.0, < 5.0) thor (~> 0.14) - jruby-rack (1.1.4) json (1.6.6) - json (1.6.6-java) kgio (2.7.4) libv8 (3.3.10.4) mail (2.4.4) @@ -172,7 +167,7 @@ GEM meta-tags (1.2.6) actionpack mime-types (1.18) - multi_json (1.2.0) + multi_json (1.3.2) mustache (0.99.4) net-scp (1.0.4) net-ssh (>= 1.99.1) @@ -181,9 +176,8 @@ GEM net-ssh (2.3.0) net-ssh-gateway (1.1.0) net-ssh (>= 1.99.1) - newrelic_rpm (3.3.2.1) + newrelic_rpm (3.3.4) nokogiri (1.5.2) - nokogiri (1.5.2-java) omniauth (1.0.3) hashie (~> 1.2) rack @@ -191,9 +185,10 @@ GEM omniauth (~> 1.0) rack-openid (~> 1.3.1) orm_adapter (0.0.7) - paperclip (2.7.0) - activerecord (>= 2.3.0) - activesupport (>= 2.3.2) + paperclip (3.0.2) + activemodel (>= 3.0.0) + activerecord (>= 3.0.0) + activesupport (>= 3.0.0) cocaine (>= 0.0.2) mime-types pg (0.13.2) @@ -211,25 +206,25 @@ GEM rack rack-test (0.6.1) rack (>= 1.0) - rails (3.2.2) - actionmailer (= 3.2.2) - actionpack (= 3.2.2) - activerecord (= 3.2.2) - activeresource (= 3.2.2) - activesupport (= 3.2.2) + rails (3.2.3) + actionmailer (= 3.2.3) + actionpack (= 3.2.3) + activerecord (= 3.2.3) + activeresource (= 3.2.3) + activesupport (= 3.2.3) bundler (~> 1.0) - railties (= 3.2.2) - rails-backbone (0.7.1) + railties (= 3.2.3) + rails-backbone (0.7.2) coffee-script (~> 2.2.0) ejs (~> 1.0.0) railties (>= 3.1.0) rails3-generators (0.17.4) railties (>= 3.0.0) - rails3-jquery-autocomplete (1.0.6) + rails3-jquery-autocomplete (1.0.7) rails (~> 3.0) - railties (3.2.2) - actionpack (= 3.2.2) - activesupport (= 3.2.2) + railties (3.2.3) + actionpack (= 3.2.3) + activesupport (= 3.2.3) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) @@ -246,7 +241,7 @@ GEM rspec-expectations (~> 2.9.0) rspec-mocks (~> 2.9.0) rspec-core (2.9.0) - rspec-expectations (2.9.0) + rspec-expectations (2.9.1) diff-lcs (~> 1.1.3) rspec-mocks (2.9.0) rspec-rails (2.9.0) @@ -254,15 +249,17 @@ GEM activesupport (>= 3.0) railties (>= 3.0) rspec (~> 2.9.0) - ruby-haml-js (0.0.2) + ruby-haml-js (0.0.3) execjs sprockets (>= 2.0.0) ruby-openid (2.1.8) russian (0.6.0) i18n (>= 0.5.0) + rvm-capistrano (1.1.0) + capistrano (>= 2.0.0) sanitize (2.0.3) nokogiri (>= 1.4.4, < 1.6) - sass (3.1.15) + sass (3.1.16) sass-rails (3.2.5) railties (~> 3.2.0) sass (>= 3.1.10) @@ -285,11 +282,10 @@ GEM hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.5) + sqlite3 (1.3.6) state_machine (1.1.2) - therubyracer (0.10.0) + therubyracer (0.10.1) libv8 (~> 3.3.10) - therubyrhino (1.73.1) thin (1.3.1) daemons (>= 1.0.9) eventmachine (>= 0.12.6) @@ -299,11 +295,7 @@ GEM treetop (1.4.10) polyglot polyglot (>= 0.3.1) - trinidad (1.0.5) - jruby-rack (>= 1.0.2) - trinidad_jars (>= 0.3.0) - trinidad_jars (1.0.2) - tzinfo (0.3.32) + tzinfo (0.3.33) uglifier (1.2.4) execjs (>= 0.3.0) multi_json (>= 1.0.2) @@ -316,13 +308,12 @@ GEM whenever (0.7.3) activesupport (>= 2.3.4) chronic (~> 0.6.3) - wikicloth (0.7.1) + wikicloth (0.8.0) builder expression_parser will_paginate (3.0.3) PLATFORMS - java ruby DEPENDENCIES @@ -342,7 +333,7 @@ DEPENDENCIES delayed_job_active_record (~> 0.3.2) devise (~> 2.0.4) diff-display (~> 0.0.1) - factory_girl_rails (~> 3.0.0) + factory_girl_rails (~> 3.1.0) gollum (= 1.3.1) grack! grit! @@ -350,29 +341,30 @@ DEPENDENCIES highline (~> 1.6.11) hirb jbuilder - jquery-rails (~> 2.0.1) + jquery-rails (~> 2.0.2) mailcatcher meta-tags (~> 1.2.5) - newrelic_rpm (~> 3.3.2) + newrelic_rpm (~> 3.3.3) omniauth (~> 1.0.3) omniauth-openid (~> 1.0.1) - paperclip (~> 2.7.0) + paperclip (~> 3.0.2) pg (~> 0.13.2) - rails (= 3.2.2) - rails-backbone + rails (= 3.2.3) + rails-backbone (~> 0.7.2) rails3-generators - rails3-jquery-autocomplete (~> 1.0.6) + rails3-jquery-autocomplete (~> 1.0.7) rdiscount redcarpet (= 1.17.2) redhillonrails_core! rr (~> 1.0.4) rspec-rails (~> 2.9.0) - ruby-haml-js + ruby-haml-js (~> 0.0.3) russian (~> 0.6.0) + rvm-capistrano sass-rails (~> 3.2.5) shotgun shoulda - therubyracer (~> 0.10.0) + therubyracer (~> 0.10.1) therubyrhino (~> 1.73.1) trinidad (~> 1.0.2) uglifier (~> 1.2.4) diff --git a/app/assets/stylesheets/design/main.scss b/app/assets/stylesheets/design/main.scss index 2a2e18cb1..ba02e8d26 100644 --- a/app/assets/stylesheets/design/main.scss +++ b/app/assets/stylesheets/design/main.scss @@ -72,7 +72,7 @@ header div.right { background: image-url("top-right.png"); height: 46px; width: 14px; - float: right; + float: left; } /* Left part of top menu*/ diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb new file mode 100644 index 000000000..5104813c4 --- /dev/null +++ b/app/controllers/admin/base_controller.rb @@ -0,0 +1,5 @@ +# -*- encoding : utf-8 -*- +class Admin::BaseController < ApplicationController + before_filter :authenticate_user! + load_and_authorize_resource +end diff --git a/app/controllers/event_logs_controller.rb b/app/controllers/admin/event_logs_controller.rb similarity index 53% rename from app/controllers/event_logs_controller.rb rename to app/controllers/admin/event_logs_controller.rb index 1b491ba0a..a58dfcefd 100644 --- a/app/controllers/event_logs_controller.rb +++ b/app/controllers/admin/event_logs_controller.rb @@ -1,8 +1,5 @@ # -*- encoding : utf-8 -*- -class EventLogsController < ApplicationController - before_filter :authenticate_user! - load_and_authorize_resource - +class Admin::EventLogsController < Admin::BaseController def index @event_logs = EventLog.default_order.eager_loading.paginate :page => params[:page] end diff --git a/app/controllers/admin/register_requests_controller.rb b/app/controllers/admin/register_requests_controller.rb new file mode 100644 index 000000000..9da359399 --- /dev/null +++ b/app/controllers/admin/register_requests_controller.rb @@ -0,0 +1,21 @@ +# -*- encoding : utf-8 -*- +class Admin::RegisterRequestsController < Admin::BaseController + def index + @register_requests = @register_requests.send((params[:scope] || 'unprocessed').to_sym).paginate(:page => params[:page]) + end + + def update + RegisterRequest.where(:id => params[:request_ids]).each(¶ms[:update_type].to_sym) if params[:update_type].present? && params[:request_ids].present? + redirect_to :action => :index + end + + def approve + @register_request.approve + redirect_to :action => :index + end + + def reject + @register_request.reject + redirect_to :action => :index + end +end diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index ba3626130..91d5076b8 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,7 +1,6 @@ # -*- encoding : utf-8 -*- -class Admin::UsersController < ApplicationController - before_filter :authenticate_user! - load_and_authorize_resource +class Admin::UsersController < Admin::BaseController + prepend_before_filter :find_user def index @filter = params[:filter] || 'all' @@ -15,7 +14,7 @@ class Admin::UsersController < ApplicationController @user.confirmed_at = Time.now.utc if @user.save flash[:notice] = t('flash.user.saved') - redirect_to users_path + redirect_to admin_users_path else flash[:error] = t('flash.user.save_error') flash[:warning] = @user.errors.full_messages.join('. ') @@ -23,7 +22,7 @@ class Admin::UsersController < ApplicationController end end - def profile + def edit end def update @@ -34,18 +33,18 @@ class Admin::UsersController < ApplicationController @user.save end flash[:notice] = t('flash.user.saved') - redirect_to users_path#edit_user_path(@user) + redirect_to admin_users_path else flash[:error] = t('flash.user.save_error') flash[:warning] = @user.errors.full_messages.join('. ') - render(:action => :profile) + render :action => :edit end end def destroy @user.destroy flash[:notice] = t("flash.user.destroyed") - redirect_to users_path + redirect_to admin_users_path end def list @@ -64,6 +63,12 @@ class Admin::UsersController < ApplicationController @total_user = @users.count @users = @users.order(order) - render :partial =>'users_ajax', :layout => false + render :partial => 'users_ajax', :layout => false + end + + protected + + def find_user + @user = User.find_by_uname!(params[:id]) if params[:id] end end diff --git a/app/controllers/git/base_controller.rb b/app/controllers/git/base_controller.rb deleted file mode 100644 index 08e9def92..000000000 --- a/app/controllers/git/base_controller.rb +++ /dev/null @@ -1,38 +0,0 @@ -# -*- encoding : utf-8 -*- -class Git::BaseController < ApplicationController - before_filter :authenticate_user! - 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 - before_filter :find_tags - before_filter :find_branches - before_filter :set_treeish - before_filter :set_current_tag - before_filter :set_current_branch - - protected - def find_git_repository - @git_repository = @project.git_repository - end - - def find_tags - @tags = @git_repository.tags - end - - def find_branches - @branches = @git_repository.branches - end - - def set_treeish - @treeish = params[:treeish].presence || @project.default_branch - end - - def set_current_tag - @current_tag = @tags.select{|t| t.name == @treeish }.first - end - - def set_current_branch - @current_branch = @branches.select{|b| b.name == @treeish }.first - end -end diff --git a/app/controllers/groups/base_controller.rb b/app/controllers/groups/base_controller.rb new file mode 100644 index 000000000..0db3685be --- /dev/null +++ b/app/controllers/groups/base_controller.rb @@ -0,0 +1,13 @@ +# -*- encoding : utf-8 -*- +class Groups::BaseController < ApplicationController + before_filter :authenticate_user! + before_filter :find_group + + protected + + def find_group + if group_id = params[:uname] || params[:group_id] || params[:id] + @group = Group.find_by_insensitive_uname! group_id + end + end +end diff --git a/app/controllers/groups/members_controller.rb b/app/controllers/groups/members_controller.rb new file mode 100644 index 000000000..4f9d53706 --- /dev/null +++ b/app/controllers/groups/members_controller.rb @@ -0,0 +1,57 @@ +# -*- encoding : utf-8 -*- +class Groups::MembersController < Groups::BaseController + is_related_controller! + belongs_to :group, :finder => 'find_by_insensitive_uname!', :optional => true + + before_filter lambda { authorize! :manage_members, @group } + + def index + end + + def update + params['user'].keys.each do |user_id| + role = params['user'][user_id] + if relation = parent.actors.where(:actor_id => user_id, :actor_type => 'User') #find_by_actor_id_and_actor_type(user_id, 'User') + relation.update_all(:role => role) if parent.owner.id.to_s != user_id + else + relation = parent.actors.build(:actor_id => user_id, :actor_type => 'User', :role => role) + relation.save! + end + end if params['user'] + if parent.save + flash[:notice] = t("flash.members.successfully_changed") + else + flash[:error] = t("flash.members.error_in_changing") + end + redirect_to group_members_path(parent) + end + + def remove + all_user_ids = [] + params['user_remove'].each do |user_id, remove| + all_user_ids << user_id if remove == ["1"] && parent.owner.id.to_s != user_id + end if params['user_remove'] + all_user_ids.each do |user_id| + u = User.find(user_id) + Relation.by_actor(u).by_target(parent).each {|r| r.destroy} + end + redirect_to group_members_path(parent) + end + + def add + if params['user_id'] and !params['user_id'].empty? + @user = User.find_by_uname(params['user_id']) + unless parent.actors.exists? :actor_id => @user.id, :actor_type => 'User' + relation = parent.actors.build(:actor_id => @user.id, :actor_type => 'User', :role => params[:role]) + if relation.save + flash[:notice] = t("flash.members.successfully_added") + else + flash[:error] = t("flash.members.error_in_adding") + end + else + flash[:error] = t("flash.members.already_added") + end + end + redirect_to group_members_path(parent) + end +end diff --git a/app/controllers/groups/profile_controller.rb b/app/controllers/groups/profile_controller.rb new file mode 100644 index 000000000..30b62c795 --- /dev/null +++ b/app/controllers/groups/profile_controller.rb @@ -0,0 +1,55 @@ +# -*- encoding : utf-8 -*- +class Groups::ProfileController < Groups::BaseController + load_and_authorize_resource :class => Group, :instance_name => 'group' + + autocomplete :group, :uname + + def index + @groups = current_user.groups.paginate(:page => params[:group_page]) # accessible_by(current_ability) + @groups = @groups.search(params[:query]) if params[:query].present? + end + + def show + @projects = @group.projects #.paginate(:page => params[:project_page], :per_page => 10) + end + + def new + end + + def edit + end + + def create + @group = Group.new params[:group] + @group.owner = current_user + if @group.save + flash[:notice] = t('flash.group.saved') + redirect_to group_path(@group) + else + flash[:error] = t('flash.group.save_error') + flash[:warning] = @group.errors.full_messages.join('. ') + render :action => :new + end + end + + def update + if @group.update_attributes(params[:group]) + flash[:notice] = t('flash.group.saved') + redirect_to group_path(@group) + else + flash[:error] = t('flash.group.save_error') + render :action => :edit + end + end + + def destroy + @group.destroy + flash[:notice] = t("flash.group.destroyed") + redirect_to groups_path + end + + def remove_user + Relation.by_object(current_user).by_target(@group).destroy_all + redirect_to groups_path + end +end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb deleted file mode 100644 index 50fc63beb..000000000 --- a/app/controllers/groups_controller.rb +++ /dev/null @@ -1,71 +0,0 @@ -# -*- encoding : utf-8 -*- -class GroupsController < ApplicationController - is_related_controller! - - belongs_to :user, :optional => true - - before_filter :authenticate_user! - before_filter :find_group, :only => [:show, :edit, :update, :destroy] - - load_and_authorize_resource :except => :create - authorize_resource :only => :create - autocomplete :group, :uname - - def index - @groups = current_user.groups#accessible_by(current_ability) - - @groups = if params[:query] - @groups.where(["name LIKE ?", "%#{params[:query]}%"]) - else - @groups - end.paginate(:page => params[:group_page]) - end - - def show - @projects = @group.projects.paginate(:page => params[:project_page], :per_page => 10) - end - - def new - @group = Group.new - end - - def edit - end - - def create - @group = Group.new(:description => params[:group][:description]) - @group.owner = current_user - @group.uname = params[:group][:uname] - - if @group.save - flash[:notice] = t('flash.group.saved') - redirect_to group_path(@group) - else - flash[:error] = t('flash.group.save_error') - flash[:warning] = @group.errors.full_messages.join('. ') - render :action => :new - end - end - - def update - if @group.update_attributes(params[:group]) - flash[:notice] = t('flash.group.saved') - redirect_to group_path(@group) - else - flash[:error] = t('flash.group.save_error') - render :action => :edit - end - end - - def destroy - @group.destroy - flash[:notice] = t("flash.group.destroyed") - redirect_to groups_path - end - - protected - - def find_group - @group = Group.find(params[:id]) - end -end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb deleted file mode 100644 index d31b35a50..000000000 --- a/app/controllers/members_controller.rb +++ /dev/null @@ -1,98 +0,0 @@ -# -*- encoding : utf-8 -*- -class MembersController < ApplicationController - before_filter :authenticate_user! - is_related_controller! - - belongs_to :group, :optional => true - -# before_filter :find_target - before_filter :find_users - - def index - redirect_to edit_group_members_path(parent) - end - - def show - end - - def new - end - - def edit - if params[:id] - @user = User.find params[:id] - render :edit_rights and return - end - @group = parent - end - - def create - end - - def update - params['user'].keys.each { |user_id| - role = params['user'][user_id] - - if relation = parent.actors.where(:actor_id => user_id, :actor_type => 'User') #find_by_actor_id_and_actor_type(user_id, 'User') - relation.update_attribute(:role, role) - else - relation = parent.actors.build(:actor_id => user_id, :actor_type => 'User', :role => role) - relation.save! - end - } if params['user'] - - if parent.save - flash[:notice] = t("flash.members.successfully_changed") - else - flash[:error] = t("flash.members.error_in_changing") - end - - redirect_to edit_group_members_path(parent) - end - - def remove - if params[:id] - u = User.find(params[:id]) - Relation.by_actor(u).by_target(parent)[0].destroy - - redirect_to groups_path - else - all_user_ids = [] - - params['user_remove'].keys.each { |user_id| - all_user_ids << user_id if params['user_remove'][user_id] == ["1"] - } if params['user_remove'] - - all_user_ids.each do |user_id| - u = User.find(user_id) - Relation.by_actor(u).by_target(parent).each {|r| r.destroy} - end - - redirect_to edit_group_members_path(parent) - end - end - - def add - if params['user_id'] and !params['user_id'].empty? - @user = User.find_by_uname(params['user_id']) - unless parent.actors.exists? :actor_id => @user.id, :actor_type => 'User' - relation = parent.actors.build(:actor_id => @user.id, :actor_type => 'User', :role => params[:role]) - if relation.save - flash[:notice] = t("flash.members.successfully_added") - else - flash[:error] = t("flash.members.error_in_adding") - end - else - flash[:error] = t("flash.members.already_added") - end - end - redirect_to edit_group_members_path(parent) - end - - protected - - def find_users - @users = parent.members #User.all - end - -end diff --git a/app/controllers/platforms/base_controller.rb b/app/controllers/platforms/base_controller.rb new file mode 100644 index 000000000..96ba67738 --- /dev/null +++ b/app/controllers/platforms/base_controller.rb @@ -0,0 +1,3 @@ +# -*- encoding : utf-8 -*- +class Platforms::BaseController < ApplicationController +end diff --git a/app/controllers/platforms_controller.rb b/app/controllers/platforms/platforms_controller.rb similarity index 98% rename from app/controllers/platforms_controller.rb rename to app/controllers/platforms/platforms_controller.rb index 7ef625831..0afc4b42c 100644 --- a/app/controllers/platforms_controller.rb +++ b/app/controllers/platforms/platforms_controller.rb @@ -1,5 +1,5 @@ # -*- encoding : utf-8 -*- -class PlatformsController < ApplicationController +class Platforms::PlatformsController < Platforms::BaseController before_filter :authenticate_user! load_and_authorize_resource @@ -17,7 +17,6 @@ class PlatformsController < ApplicationController end def show - end def new diff --git a/app/controllers/private_users_controller.rb b/app/controllers/platforms/private_users_controller.rb similarity index 93% rename from app/controllers/private_users_controller.rb rename to app/controllers/platforms/private_users_controller.rb index 0b25d1202..ebd000e50 100644 --- a/app/controllers/private_users_controller.rb +++ b/app/controllers/platforms/private_users_controller.rb @@ -1,5 +1,5 @@ # -*- encoding : utf-8 -*- -class PrivateUsersController < ApplicationController +class Platforms::PrivateUsersController < Platforms::BaseController before_filter :authenticate_user! before_filter :find_platform_and_private_users diff --git a/app/controllers/privates_controller.rb b/app/controllers/platforms/privates_controller.rb similarity index 92% rename from app/controllers/privates_controller.rb rename to app/controllers/platforms/privates_controller.rb index a375d9ce9..c10bb6c51 100644 --- a/app/controllers/privates_controller.rb +++ b/app/controllers/platforms/privates_controller.rb @@ -1,5 +1,5 @@ # -*- encoding : utf-8 -*- -class PrivatesController < ApplicationController +class Platforms::PrivatesController < Platforms::BaseController require 'digest/sha2' before_filter :find_platform diff --git a/app/controllers/product_build_lists_controller.rb b/app/controllers/platforms/product_build_lists_controller.rb similarity index 96% rename from app/controllers/product_build_lists_controller.rb rename to app/controllers/platforms/product_build_lists_controller.rb index 3e1384f4c..daab1ef25 100644 --- a/app/controllers/product_build_lists_controller.rb +++ b/app/controllers/platforms/product_build_lists_controller.rb @@ -1,5 +1,5 @@ # -*- encoding : utf-8 -*- -class ProductBuildListsController < ApplicationController +class Platforms::ProductBuildListsController < Platforms::BaseController before_filter :authenticate_user!, :except => [:status_build] skip_before_filter :authenticate_user!, :only => [:index] if APP_CONFIG['anonymous_access'] load_and_authorize_resource :platform, :only => [:create, :destroy] diff --git a/app/controllers/products_controller.rb b/app/controllers/platforms/products_controller.rb similarity index 95% rename from app/controllers/products_controller.rb rename to app/controllers/platforms/products_controller.rb index 2e428e81e..020866a1c 100644 --- a/app/controllers/products_controller.rb +++ b/app/controllers/platforms/products_controller.rb @@ -1,5 +1,5 @@ # -*- encoding : utf-8 -*- -class ProductsController < ApplicationController +class Platforms::ProductsController < Platforms::BaseController before_filter :authenticate_user! load_and_authorize_resource :platform diff --git a/app/controllers/repositories_controller.rb b/app/controllers/platforms/repositories_controller.rb similarity index 97% rename from app/controllers/repositories_controller.rb rename to app/controllers/platforms/repositories_controller.rb index 3222811d2..d37caf8c6 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/platforms/repositories_controller.rb @@ -1,5 +1,5 @@ # -*- encoding : utf-8 -*- -class RepositoriesController < ApplicationController +class Platforms::RepositoriesController < Platforms::BaseController before_filter :authenticate_user! load_and_authorize_resource :platform diff --git a/app/controllers/projects/base_controller.rb b/app/controllers/projects/base_controller.rb new file mode 100644 index 000000000..c808887f2 --- /dev/null +++ b/app/controllers/projects/base_controller.rb @@ -0,0 +1,10 @@ +# -*- encoding : utf-8 -*- +class Projects::BaseController < ApplicationController + prepend_before_filter :find_project + + protected + + def find_project + @project = Project.find_by_owner_and_name!(params[:owner_name], params[:project_name]) if params[:owner_name] && params[:project_name] + end +end diff --git a/app/controllers/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb similarity index 94% rename from app/controllers/build_lists_controller.rb rename to app/controllers/projects/build_lists_controller.rb index af297ca3b..6e497de1e 100644 --- a/app/controllers/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -1,15 +1,14 @@ # -*- encoding : utf-8 -*- -class BuildListsController < ApplicationController +class Projects::BuildListsController < Projects::BaseController CALLBACK_ACTIONS = [:publish_build, :status_build, :pre_build, :post_build, :circle_build, :new_bbdt] NESTED_ACTIONS = [:search, :index, :new, :create] before_filter :authenticate_user!, :except => CALLBACK_ACTIONS 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, :update] + + before_filter :find_build_list, :only => [:show, :publish, :cancel, :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] load_and_authorize_resource :project, :only => NESTED_ACTIONS load_and_authorize_resource :build_list, :through => :project, :only => NESTED_ACTIONS, :shallow => true @@ -36,12 +35,12 @@ class BuildListsController < ApplicationController end def new - @build_list = BuildList.new + # @build_list = BuildList.new # @build_list already created by CanCan end def create notices, errors = [], [] - # Disable auto_publish if platform released + @platform = Platform.find params[:build_list][:pl_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| @@ -156,14 +155,6 @@ class BuildListsController < ApplicationController protected - def find_project - @project = Project.find_by_id params[:project_id] - end - - def find_platform - @platform = Platform.find params[:build_list][:save_to_platform_id] - end - def find_build_list @build_list = BuildList.find(params[:id]) end diff --git a/app/controllers/collaborators_controller.rb b/app/controllers/projects/collaborators_controller.rb similarity index 70% rename from app/controllers/collaborators_controller.rb rename to app/controllers/projects/collaborators_controller.rb index bc03bbd77..f0432b4fd 100644 --- a/app/controllers/collaborators_controller.rb +++ b/app/controllers/projects/collaborators_controller.rb @@ -1,16 +1,14 @@ # -*- encoding : utf-8 -*- -class CollaboratorsController < ApplicationController +class Projects::CollaboratorsController < Projects::BaseController respond_to :html, :json before_filter :authenticate_user! - - before_filter :find_project - before_filter :find_users - before_filter :find_groups - load_resource :project before_filter :authorize_collaborators + before_filter :find_users + before_filter :find_groups + def index @collaborators = Collaborator.find_by_project(@project) respond_with @collaborators @@ -67,21 +65,17 @@ class CollaboratorsController < ApplicationController protected - def find_project - @project = Project.find params[:project_id] - end + def find_users + @users = @project.collaborators.order('uname')#User.all + @users = @users.without(@project.owner_id) if @project.owner_type == 'User' + end - def find_users - @users = @project.collaborators.order('uname')#User.all - @users = @users.without(@project.owner_id) if @project.owner_type == 'User' - end + def find_groups + @groups = @project.groups.order('uname')#Group.all + @groups = @groups.without(@project.owner_id) if @project.owner_type == 'Group' + end - def find_groups - @groups = @project.groups.order('uname')#Group.all - @groups = @groups.without(@project.owner_id) if @project.owner_type == 'Group' - end - - def authorize_collaborators - authorize! :update, @project - end + def authorize_collaborators + authorize! :update, @project + end end diff --git a/app/controllers/comments_controller.rb b/app/controllers/projects/comments_controller.rb similarity index 95% rename from app/controllers/comments_controller.rb rename to app/controllers/projects/comments_controller.rb index 6d5875178..371365eb9 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/projects/comments_controller.rb @@ -1,5 +1,5 @@ # -*- encoding : utf-8 -*- -class CommentsController < ApplicationController +class Projects::CommentsController < Projects::BaseController before_filter :authenticate_user! load_and_authorize_resource :project before_filter :find_commentable diff --git a/app/controllers/commit_subscribes_controller.rb b/app/controllers/projects/commit_subscribes_controller.rb similarity index 92% rename from app/controllers/commit_subscribes_controller.rb rename to app/controllers/projects/commit_subscribes_controller.rb index 35029b95f..de5b2ac6e 100644 --- a/app/controllers/commit_subscribes_controller.rb +++ b/app/controllers/projects/commit_subscribes_controller.rb @@ -1,7 +1,6 @@ # -*- encoding : utf-8 -*- -class CommitSubscribesController < ApplicationController +class Projects::CommitSubscribesController < Projects::BaseController before_filter :authenticate_user! - load_and_authorize_resource :project before_filter :find_commit diff --git a/app/controllers/projects/git/base_controller.rb b/app/controllers/projects/git/base_controller.rb new file mode 100644 index 000000000..37168d764 --- /dev/null +++ b/app/controllers/projects/git/base_controller.rb @@ -0,0 +1,39 @@ +# -*- encoding : utf-8 -*- +class Projects::Git::BaseController < Projects::BaseController + before_filter :authenticate_user! + 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 + before_filter :find_tags + before_filter :find_branches + before_filter :set_treeish + before_filter :set_current_tag + before_filter :set_current_branch + + protected + + def find_git_repository + @git_repository = @project.git_repository + end + + def find_tags + @tags = @git_repository.tags + end + + def find_branches + @branches = @git_repository.branches + end + + def set_treeish + @treeish = params[:treeish].presence || @project.default_branch + end + + def set_current_tag + @current_tag = @tags.select{|t| t.name == @treeish }.first + end + + def set_current_branch + @current_branch = @branches.select{|b| b.name == @treeish }.first + end +end diff --git a/app/controllers/git/blobs_controller.rb b/app/controllers/projects/git/blobs_controller.rb similarity index 96% rename from app/controllers/git/blobs_controller.rb rename to app/controllers/projects/git/blobs_controller.rb index 4be95c11c..b8abb0799 100644 --- a/app/controllers/git/blobs_controller.rb +++ b/app/controllers/projects/git/blobs_controller.rb @@ -1,5 +1,5 @@ # -*- encoding : utf-8 -*- -class Git::BlobsController < Git::BaseController +class Projects::Git::BlobsController < Projects::Git::BaseController before_filter :find_tree before_filter :find_branch before_filter :set_path_blob diff --git a/app/controllers/git/commits_controller.rb b/app/controllers/projects/git/commits_controller.rb similarity index 94% rename from app/controllers/git/commits_controller.rb rename to app/controllers/projects/git/commits_controller.rb index be34f4ad5..cf9a20021 100644 --- a/app/controllers/git/commits_controller.rb +++ b/app/controllers/projects/git/commits_controller.rb @@ -1,5 +1,5 @@ # -*- encoding : utf-8 -*- -class Git::CommitsController < Git::BaseController +class Projects::Git::CommitsController < Projects::Git::BaseController helper_method :split_commits_by_date def index diff --git a/app/controllers/git/trees_controller.rb b/app/controllers/projects/git/trees_controller.rb similarity index 85% rename from app/controllers/git/trees_controller.rb rename to app/controllers/projects/git/trees_controller.rb index e84079f88..9655ffd4b 100644 --- a/app/controllers/git/trees_controller.rb +++ b/app/controllers/projects/git/trees_controller.rb @@ -1,5 +1,5 @@ # -*- encoding : utf-8 -*- -class Git::TreesController < Git::BaseController +class Projects::Git::TreesController < Projects::Git::BaseController def show redirect_to project_path(@project) and return if params[:treeish] == @project.default_branch and params[:path].blank? @@ -10,10 +10,9 @@ class Git::TreesController < Git::BaseController # @commit = @git_repository.commits(@treeish, 1).first # Raises Grit::Git::GitTimeout @commit = @branch.present? ? @branch.commit() : @git_repository.log(@treeish, @path, :max_count => 1).first - render :template => "git/trees/empty" and return unless @commit + render "empty" and return unless @commit @tree = @tree / @path if @path - render :template => "git/trees/show" end def archive @@ -28,8 +27,6 @@ class Git::TreesController < Git::BaseController 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 + send_file file.path, :disposition => 'attachment', :type => "application/#{format == 'tar' ? 'x-tar-gz' : 'zip'}", :filename => fullname end - end diff --git a/app/controllers/issues_controller.rb b/app/controllers/projects/issues_controller.rb similarity index 88% rename from app/controllers/issues_controller.rb rename to app/controllers/projects/issues_controller.rb index 0ce847f58..b95743bdd 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -1,5 +1,5 @@ # -*- encoding : utf-8 -*- -class IssuesController < ApplicationController +class Projects::IssuesController < Projects::BaseController NON_RESTFUL_ACTION = [:create_label, :update_label, :destroy_label, :search_collaborators] before_filter :authenticate_user! skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access'] @@ -55,11 +55,11 @@ class IssuesController < ApplicationController def update if params[:issue] && status = params[:issue][:status] - action = 'issues/_status' + action = 'status' @issue.set_close(current_user) if status == 'closed' @issue.set_open if status == 'open' status = 200 if @issue.save - render action, :status => (status || 500), :layout => false + render :partial => action, :status => (status || 500), :layout => false elsif params[:issue] @issue.labelings.destroy_all if params[:issue][:labelings_attributes] # FIXME status = 200 if @issue.update_attributes(params[:issue]) @@ -77,12 +77,12 @@ class IssuesController < ApplicationController end def create_label - status = @project.labels.create(:name => params[:name], :color => params[:color]) ? 200 : 500 + status = @project.labels.create!(:name => params[:name], :color => params[:color]) ? 200 : 500 index(status) end def update_label - status = @label.update_attributes( :name => params[:name], :color => params[:color]) ? 200 : 500 + status = @label.update_attributes(:name => params[:name], :color => params[:color]) ? 200 : 500 index(status) end @@ -96,7 +96,7 @@ class IssuesController < ApplicationController users = User.joins(:groups => :projects).where(:projects => {:id => @project.id}).where("users.uname ILIKE ?", search) users2 = @project.collaborators.where("users.uname ILIKE ?", search) @users = (users + users2).uniq.sort {|x,y| x.uname <=> y.uname}.first(10) - render 'issues/_search_collaborators', :layout => false + render :partial => 'search_collaborators', :layout => false end private diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects/projects_controller.rb similarity index 95% rename from app/controllers/projects_controller.rb rename to app/controllers/projects/projects_controller.rb index 8f9a949ad..37d6648cd 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects/projects_controller.rb @@ -1,5 +1,5 @@ # -*- encoding : utf-8 -*- -class ProjectsController < ApplicationController +class Projects::ProjectsController < Projects::BaseController before_filter :authenticate_user! load_and_authorize_resource @@ -57,6 +57,7 @@ class ProjectsController < ApplicationController end def fork + authorize! :fork, @project # TODO WTF ? owner = (Group.find params[:group] if params[:group].present?) || current_user authorize! :update, owner if owner.class == Group if forked = @project.fork(owner) and forked.valid? @@ -72,11 +73,11 @@ class ProjectsController < ApplicationController if request.post? if @project.update_attributes(params[:project]) flash[:notice] = t('flash.project.saved') + redirect_to sections_project_path(@project) else @project.save flash[:error] = t('flash.project.save_error') end - render :action => :sections end end diff --git a/app/controllers/subscribes_controller.rb b/app/controllers/projects/subscribes_controller.rb similarity index 91% rename from app/controllers/subscribes_controller.rb rename to app/controllers/projects/subscribes_controller.rb index ddf208c64..0c4c285f3 100644 --- a/app/controllers/subscribes_controller.rb +++ b/app/controllers/projects/subscribes_controller.rb @@ -1,5 +1,5 @@ # -*- encoding : utf-8 -*- -class SubscribesController < ApplicationController +class Projects::SubscribesController < Projects::BaseController before_filter :authenticate_user! load_and_authorize_resource :project diff --git a/app/controllers/wiki_controller.rb b/app/controllers/projects/wiki_controller.rb similarity index 99% rename from app/controllers/wiki_controller.rb rename to app/controllers/projects/wiki_controller.rb index 9a5149b5f..c56d73dc9 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/projects/wiki_controller.rb @@ -2,7 +2,7 @@ #require 'lib/gollum' require 'cgi' -class WikiController < ApplicationController +class Projects::WikiController < Projects::BaseController WIKI_OPTIONS = {} before_filter :authenticate_user! diff --git a/app/controllers/register_requests_controller.rb b/app/controllers/register_requests_controller.rb deleted file mode 100644 index 85c915a52..000000000 --- a/app/controllers/register_requests_controller.rb +++ /dev/null @@ -1,52 +0,0 @@ -# -*- encoding : utf-8 -*- -class RegisterRequestsController < ApplicationController - load_and_authorize_resource - - before_filter :find_register_request, :only => [:approve, :reject] - - def index - @register_requests = @register_requests.send((params[:scope] || 'unprocessed').to_sym).paginate(:page => params[:page]) - end - - def new -# render :layout => 'sessions' - redirect_to '/invite.html' - end - - def show_message - end - - def create - RegisterRequest.create(params[:register_request]) - redirect_to '/thanks.html' #show_message_register_requests_path - end - - def update - if params[:update_type].present? and params[:request_ids].present? - updates = RegisterRequest.where(:id => params[:request_ids]) - case params[:update_type] - when 'approve' # see approve method - updates.each {|req| req.update_attributes(:approved => true, :rejected => false)} - when 'reject' # see reject method - updates.each {|req| req.update_attributes(:approved => false, :rejected => true)} - end - end - redirect_to :action => :index - end - - def approve - @register_request.update_attributes(:approved => true, :rejected => false) - redirect_to :action => :index - end - - def reject - @register_request.update_attributes(:approved => false, :rejected => true) - redirect_to :action => :index - end - - protected - - def find_register_request - @register_request = RegisterRequest.find(params[:register_request_id]) - end -end diff --git a/app/controllers/settings/notifiers_controller.rb b/app/controllers/settings/notifiers_controller.rb deleted file mode 100644 index b52d8f525..000000000 --- a/app/controllers/settings/notifiers_controller.rb +++ /dev/null @@ -1,21 +0,0 @@ -# -*- encoding : utf-8 -*- -class Settings::NotifiersController < ApplicationController - before_filter :authenticate_user! - - load_and_authorize_resource :user - load_and_authorize_resource :class => Settings::Notifier, :through => :user, :singleton => true, :shallow => true - - def show - end - - def update - if @notifier.update_attributes(params[:settings_notifier]) - flash[:notice] = I18n.t("flash.settings.saved") - redirect_to user_settings_notifier_path(@user) - else - flash[:notice] = I18n.t("flash.settings.save_error") - redirect_to user_settings_notifier_path(@user) - end - end - -end diff --git a/app/controllers/users/base_controller.rb b/app/controllers/users/base_controller.rb new file mode 100644 index 000000000..e0231bb20 --- /dev/null +++ b/app/controllers/users/base_controller.rb @@ -0,0 +1,13 @@ +# -*- encoding : utf-8 -*- +class Users::BaseController < ApplicationController + before_filter :authenticate_user! + before_filter :find_user + + protected + + def find_user + if user_id = params[:uname] || params[:user_id] || params[:id] + @user = User.find_by_insensitive_uname! user_id + end + end +end diff --git a/app/controllers/users/profile_controller.rb b/app/controllers/users/profile_controller.rb new file mode 100644 index 000000000..1e7c18869 --- /dev/null +++ b/app/controllers/users/profile_controller.rb @@ -0,0 +1,10 @@ +# -*- encoding : utf-8 -*- +class Users::ProfileController < Users::BaseController + autocomplete :user, :uname + + def show + @groups = @user.groups.uniq + @platforms = @user.platforms.paginate(:page => params[:platform_page], :per_page => 10) + @projects = @user.projects.paginate(:page => params[:project_page], :per_page => 10) + end +end diff --git a/app/controllers/users/register_requests_controller.rb b/app/controllers/users/register_requests_controller.rb new file mode 100644 index 000000000..5772334d3 --- /dev/null +++ b/app/controllers/users/register_requests_controller.rb @@ -0,0 +1,11 @@ +# -*- encoding : utf-8 -*- +class Users::RegisterRequestsController < ApplicationController + def new + redirect_to '/invite.html' + end + + def create + RegisterRequest.create(params[:register_request]) + redirect_to '/thanks.html' + end +end diff --git a/app/controllers/users/settings_controller.rb b/app/controllers/users/settings_controller.rb new file mode 100644 index 000000000..cae985b96 --- /dev/null +++ b/app/controllers/users/settings_controller.rb @@ -0,0 +1,55 @@ +# -*- encoding : utf-8 -*- +class Users::SettingsController < Users::BaseController + before_filter :set_current_user + + def profile + if request.put? + send_confirmation = params[:user][:email] != @user.email + if @user.update_without_password(params[:user]) + if @user.avatar && params[:delete_avatar] == '1' + @user.avatar = nil + @user.save + end + if send_confirmation + @user.confirmed_at, @user.confirmation_sent_at = nil + @user.send_confirmation_instructions + end + flash[:notice] = t('flash.user.saved') + redirect_to profile_settings_path + else + flash[:error] = t('flash.user.save_error') + flash[:warning] = @user.errors.full_messages.join('. ') + end + end + end + + def private + if request.put? + if @user.update_with_password(params[:user]) + flash[:notice] = t('flash.user.saved') + redirect_to private_settings_path + else + flash[:error] = t('flash.user.save_error') + flash[:warning] = @user.errors.full_messages.join('. ') + render(:action => :private) + end + end + end + + def notifiers + if request.put? + if @user.notifier.update_attributes(params[:settings_notifier]) + flash[:notice] = I18n.t("flash.settings.saved") + redirect_to notifiers_settings_path + else + flash[:error] = I18n.t("flash.settings.save_error") + end + end + end + + protected + + def set_current_user + @user = current_user + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb deleted file mode 100644 index 285101e6e..000000000 --- a/app/controllers/users_controller.rb +++ /dev/null @@ -1,57 +0,0 @@ -# -*- encoding : utf-8 -*- -class UsersController < ApplicationController - before_filter :authenticate_user! - - load_and_authorize_resource :only => :show - before_filter :set_current_user, :only => [:profile, :update, :private] - autocomplete :user, :uname - - def show - @groups = @user.groups.uniq - @platforms = @user.platforms.paginate(:page => params[:platform_page], :per_page => 10) - @projects = @user.projects.paginate(:page => params[:project_page], :per_page => 10) - end - - def profile - end - - def update - send_confirmation = params[:user][:email] != @user.email - if @user.update_without_password(params[:user]) - if @user.avatar && params[:delete_avatar] == '1' - @user.avatar = nil - @user.save - end - if send_confirmation - @user.confirmed_at, @user.confirmation_sent_at = nil - @user.send_confirmation_instructions - end - flash[:notice] = t('flash.user.saved') - redirect_to edit_profile_path - else - flash[:error] = t('flash.user.save_error') - flash[:warning] = @user.errors.full_messages.join('. ') - render(:action => :profile) - end - end - - def private - if request.put? - if @user.update_with_password(params[:user]) - flash[:notice] = t('flash.user.saved') - redirect_to user_private_settings_path(@user) - else - flash[:error] = t('flash.user.save_error') - flash[:warning] = @user.errors.full_messages.join('. ') - render(:action => :private) - end - end - end - - protected - - def set_current_user - @user = current_user - end - -end diff --git a/app/helpers/activity_feeds_helper.rb b/app/helpers/activity_feeds_helper.rb index 0498ab8c9..2161a7582 100644 --- a/app/helpers/activity_feeds_helper.rb +++ b/app/helpers/activity_feeds_helper.rb @@ -1,7 +1,7 @@ # -*- encoding : utf-8 -*- module ActivityFeedsHelper def render_activity_feed(activity_feed) - render :partial => activity_feed.partial, :locals => activity_feed.data.merge(:activity_feed => activity_feed) + render activity_feed.partial, activity_feed.data.merge(:activity_feed => activity_feed) end def get_feed_title_from_content(content) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0cd2f8927..d22a381b0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2,15 +2,15 @@ module ApplicationHelper def layout_class case - when params[:controller] == 'issues' && params[:action] == 'new' + when controller_name == 'issues' && action_name == 'new' 'right nopadding' - when params[:controller] == 'build_lists' && params[:action] == 'index' + when controller_name == 'build_lists' && action_name == 'index' 'right slim' - when params[:controller] == 'build_lists' && ['new', 'create'].include?(params[:action]) + when controller_name == 'build_lists' && ['new', 'create'].include?(action_name) nil - when params[:controller] == 'platforms' && params[:action] == 'show' + when controller_name == 'platforms' && action_name == 'show' 'right bigpadding' - when params[:controller] == 'platforms' && params[:action] == 'clone' + when controller_name == 'platforms' && action_name == 'clone' 'right middlepadding' else content_for?(:sidebar) ? 'right' : 'all' diff --git a/app/helpers/settings/notifiers_helper.rb b/app/helpers/settings/notifiers_helper.rb deleted file mode 100644 index 218ea67f6..000000000 --- a/app/helpers/settings/notifiers_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -# -*- encoding : utf-8 -*- -module Settings::NotifiersHelper -end diff --git a/app/helpers/subscribes_helper.rb b/app/helpers/subscribes_helper.rb deleted file mode 100644 index dbf4053de..000000000 --- a/app/helpers/subscribes_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -# -*- encoding : utf-8 -*- -module SubscribesHelper -end diff --git a/app/models/ability.rb b/app/models/ability.rb index 5ac6d6309..4e3b61edb 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -23,12 +23,11 @@ class Ability can [:publish_build, :status_build, :pre_build, :post_build, :circle_build, :new_bbdt], BuildList if user.guest? # Guest rights - can [:create, :show_message], RegisterRequest + # can [:new, :create], RegisterRequest else # Registered user rights if user.admin? can :manage, :all # Protection - cannot :create, RegisterRequest cannot :approve, RegisterRequest, :approved => true cannot :reject, RegisterRequest, :rejected => true cannot [:destroy, :create], Subscribe @@ -40,15 +39,13 @@ class Ability if user.user? can [:show, :autocomplete_user_uname], User - can [:profile, :update, :private], User, :id => user.id - - can [:show, :update], Settings::Notifier, :user_id => user.id can [:read, :create, :autocomplete_group_uname], Group can [:update, :manage_members], Group do |group| group.actors.exists?(:actor_type => 'User', :actor_id => user.id, :role => 'admin') # or group.owner_id = user.id end can :destroy, Group, :owner_id => user.id + can :remove_user, Group can :create, Project can :read, Project, :visibility => 'open' @@ -58,7 +55,7 @@ class Ability can(:write, Project) {|project| local_writer? project} # for grack can([:update, :sections, :manage_collaborators], Project) {|project| local_admin? project} can(:fork, Project) {|project| can? :read, project} - can(:fork_to_group, Project) {|project| project.owner_type == 'Group' and can? :update, project.owner} + can(:fork, Project) {|project| project.owner_type == 'Group' and can? :update, project.owner} can(:destroy, Project) {|project| owner? project} 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 @@ -118,13 +115,10 @@ class Ability # Shared cannot rights for all users (registered, admin) cannot :destroy, Platform, :platform_type => 'personal' cannot [:create, :destroy, :add_project, :remove_project], Repository, :platform => {:platform_type => 'personal'} - cannot :fork, Project, :owner_id => user.id, :owner_type => user.class.to_s cannot :destroy, Issue cannot [:members, :add_member, :remove_member, :remove_members], Platform, :platform_type => 'personal' -# cannot :read, Product, :platform => {:platform_type => 'personal'} -# cannot(:read, Product, read_relations_for('products', 'platforms')) {|product| product.platform.platform_type == 'personal'} cannot [:create, :update, :destroy, :clone], Product, :platform => {:platform_type => 'personal'} cannot [:clone, :build_all], Platform, :platform_type => 'personal' diff --git a/app/models/group.rb b/app/models/group.rb index 0f34d2c6c..c09af034f 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -2,9 +2,9 @@ class Group < ActiveRecord::Base belongs_to :owner, :class_name => 'User' - has_many :relations, :as => :actor, :dependent => :destroy - has_many :actors, :as => :target, :class_name => 'Relation' - has_many :targets, :as => :actor, :class_name => 'Relation' + has_many :relations, :as => :actor, :dependent => :destroy, :dependent => :destroy + has_many :actors, :as => :target, :class_name => 'Relation', :dependent => :destroy + has_many :targets, :as => :actor, :class_name => 'Relation', :dependent => :destroy has_many :members, :through => :actors, :source => :actor, :source_type => 'User', :autosave => true has_many :projects, :through => :targets, :source => :target, :source_type => 'Project', :autosave => true @@ -13,22 +13,21 @@ class Group < ActiveRecord::Base has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy validates :owner, :presence => true - validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ } - validate { errors.add(:uname, :taken) if User.where('uname LIKE ?', uname).present? } + validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => {:with => /^[a-z0-9_]+$/}, :reserved_name => true + validate { errors.add(:uname, :taken) if User.by_uname(uname).present? } scope :opened, where('1=1') scope :by_owner, lambda {|owner| where(:owner_id => owner.id)} scope :by_admin, lambda {|admin| joins(:actors).where(:'relations.role' => 'admin', :'relations.actor_id' => admin.id, :'relations.actor_type' => 'User')} - include Modules::Models::ActsLikeMember - - attr_accessible :description - attr_readonly :own_projects_count + attr_accessible :uname, :description + attr_readonly :uname delegate :email, :to => :owner after_create :add_owner_to_members + include Modules::Models::ActsLikeMember include Modules::Models::PersonalRepository # include Modules::Models::Owner @@ -43,7 +42,6 @@ class Group < ActiveRecord::Base protected def add_owner_to_members - Relation.create_with_role(self.owner, self, 'admin') - # members << self.owner if !members.exists?(:id => self.owner.id) + Relation.create_with_role(self.owner, self, 'admin') # members << self.owner if !members.exists?(:id => self.owner.id) end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 628970e35..51a5ebac8 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -9,8 +9,8 @@ class Issue < ActiveRecord::Base has_many :comments, :as => :commentable, :dependent => :destroy has_many :subscribes, :as => :subscribeable, :dependent => :destroy + has_many :labelings, :dependent => :destroy has_many :labels, :through => :labelings, :uniq => true - has_many :labelings validates :title, :body, :project_id, :presence => true diff --git a/app/models/label.rb b/app/models/label.rb index e5fe686f2..fe4ad5b22 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -4,7 +4,7 @@ class Label < ActiveRecord::Base has_many :issues, :through => :labelings belongs_to :project - validates :name, :uniqueness => { :scope => :project_id} + validates :name, :uniqueness => {:scope => :project_id} validates :name, :color, :presence => true validates :color, :format => { :with => /\A([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\z/, :message => I18n.t('layout.issues.invalid_labels')} diff --git a/app/models/platform.rb b/app/models/platform.rb index 56254c23e..4cf0de66a 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -38,9 +38,7 @@ class Platform < ActiveRecord::Base scope :main, where(:platform_type => 'main') scope :personal, where(:platform_type => 'personal') - attr_accessible :owner, :visibility, :description, :released #, :owner_id, :owner_type - - attr_accessible :name, :distrib_type, :parent_platform_id, :platform_type + attr_accessible :name, :distrib_type, :parent_platform_id, :platform_type, :owner, :visibility, :description, :released attr_readonly :name, :distrib_type, :parent_platform_id, :platform_type include Modules::Models::Owner @@ -102,7 +100,8 @@ class Platform < ActiveRecord::Base def base_clone(attrs = {}) # :description, :name, :owner clone.tap do |c| - c.attributes = attrs # attrs.each {|k,v| c.send("#{k}=", v)} + # c.attributes = attrs # + attrs.each {|k,v| c.send("#{k}=", v)} c.updated_at = nil; c.created_at = nil # :id = nil c.parent = self end diff --git a/app/models/product.rb b/app/models/product.rb index 71b0cbde7..80d4945e4 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -15,8 +15,7 @@ class Product < ActiveRecord::Base scope :recent, order("name ASC") - attr_accessible :name, :counter, :ks, :menu, :tar, :cron_tab, :use_cron - attr_accessible :description, :build_script, :delete_tar + attr_accessible :name, :counter, :ks, :menu, :tar, :cron_tab, :use_cron, :description, :build_script, :delete_tar attr_readonly :platform_id def delete_tar diff --git a/app/models/project.rb b/app/models/project.rb index 109a20fe9..3b34263c0 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -6,6 +6,7 @@ class Project < ActiveRecord::Base belongs_to :owner, :polymorphic => true, :counter_cache => :own_projects_count has_many :issues, :dependent => :destroy + has_many :labels, :dependent => :destroy has_many :build_lists, :dependent => :destroy has_many :project_imports, :dependent => :destroy @@ -15,7 +16,6 @@ class Project < ActiveRecord::Base has_many :relations, :as => :target, :dependent => :destroy has_many :collaborators, :through => :relations, :source => :actor, :source_type => 'User' has_many :groups, :through => :relations, :source => :actor, :source_type => 'Group' - has_many :labels has_many :advisories @@ -53,6 +53,21 @@ class Project < ActiveRecord::Base include Modules::Models::Owner + def to_param + name + end + + def self.find_by_owner_and_name(owner_name, project_name) + owner = User.find_by_uname(owner_name) || Group.find_by_uname(owner_name) || User.by_uname(owner_name).first || Group.by_uname(owner_name).first and + scoped = where(:owner_id => owner.id, :owner_type => owner.class) and + scoped.find_by_name(project_name) || scoped.by_name(project_name).first + # owner.projects.find_by_name(project_name) || owner.projects.by_name(project_name).first # TODO force this work? + end + + def self.find_by_owner_and_name!(owner_name, project_name) + find_by_owner_and_name(owner_name, project_name) or raise ActiveRecord::RecordNotFound + end + def build_for(platform, user, arch = 'i586', priority = 0) # Select main and project platform repository(contrib, non-free and etc) # If main does not exist, will connect only project platform repository @@ -60,7 +75,6 @@ class Project < ActiveRecord::Base build_reps = [platform.repositories.find_by_name('main')] build_reps += platform.repositories.select {|rep| self.repository_ids.include? rep.id} build_ids = build_reps.compact.map(&:id).uniq - arch = Arch.find_by_name(arch) if arch.acts_like?(:string) build_lists.create do |bl| bl.save_to_platform = platform @@ -259,7 +273,7 @@ class Project < ActiveRecord::Base def create_wiki if has_wiki && !FileTest.exist?(wiki_path) Grit::Repo.init_bare(wiki_path) - wiki = Gollum::Wiki.new(wiki_path, {:base_path => Rails.application.routes.url_helpers.project_wiki_index_path(self)}) + wiki = Gollum::Wiki.new(wiki_path, {:base_path => Rails.application.routes.url_helpers.project_wiki_index_path(owner, self)}) wiki.write_page('Home', :markdown, I18n.t("wiki.seed.welcome_content"), {:name => owner.name, :email => owner.email, :message => 'Initial commit'}) end diff --git a/app/models/register_request.rb b/app/models/register_request.rb index f84771a10..972dc1029 100644 --- a/app/models/register_request.rb +++ b/app/models/register_request.rb @@ -11,6 +11,14 @@ class RegisterRequest < ActiveRecord::Base validates :email, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i } + def approve + update_attributes(:approved => true, :rejected => false) + end + + def reject + update_attributes(:approved => false, :rejected => true) + end + protected def generate_token diff --git a/app/models/repository.rb b/app/models/repository.rb index 87cd1dedb..5318b93ba 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -13,7 +13,7 @@ class Repository < ActiveRecord::Base before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]} before_destroy :xml_rpc_destroy, :unless => lambda {Thread.current[:skip]} - attr_accessible :name, :description + attr_accessible :name, :description attr_readonly :name, :platform_id def base_clone(attrs = {}) diff --git a/app/models/settings.rb b/app/models/settings.rb deleted file mode 100644 index fee53706e..000000000 --- a/app/models/settings.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -*- encoding : utf-8 -*- -module Settings - def self.table_name_prefix - 'settings_' - end -end diff --git a/app/models/settings/notifier.rb b/app/models/settings_notifier.rb similarity index 66% rename from app/models/settings/notifier.rb rename to app/models/settings_notifier.rb index 034117b26..e01c09c0b 100644 --- a/app/models/settings/notifier.rb +++ b/app/models/settings_notifier.rb @@ -1,5 +1,5 @@ # -*- encoding : utf-8 -*- -class Settings::Notifier < ActiveRecord::Base +class SettingsNotifier < ActiveRecord::Base belongs_to :user validates :user_id, :presence => true diff --git a/app/models/user.rb b/app/models/user.rb index 8ddbbaad7..19771bdd5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -15,7 +15,7 @@ class User < ActiveRecord::Base } validates_inclusion_of :avatar_file_size, :in => (0..MAX_AVATAR_SIZE), :allow_nil => true - has_one :notifier, :class_name => 'Settings::Notifier', :dependent => :destroy #:notifier + has_one :notifier, :class_name => 'SettingsNotifier', :dependent => :destroy #:notifier has_many :activity_feeds, :dependent => :destroy @@ -35,16 +35,14 @@ class User < ActiveRecord::Base has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group', :dependent => :destroy has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy - include Modules::Models::PersonalRepository - - validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => { :with => /^[a-z0-9_]+$/ } - validate { errors.add(:uname, :taken) if Group.where('uname LIKE ?', uname).present? } + validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => {:with => /^[a-z0-9_]+$/}, :reserved_name => true + validate { errors.add(:uname, :taken) if Group.by_uname(uname).present? } validates :role, :inclusion => {:in => ROLES}, :allow_blank => true validates :language, :inclusion => {:in => LANGUAGES}, :allow_blank => true attr_accessible :email, :password, :password_confirmation, :current_password, :remember_me, :login, :name, :uname, :language, :site, :company, :professional_experience, :location, :avatar - attr_readonly :uname, :own_projects_count + attr_readonly :uname attr_accessor :login scope :opened, where('1=1') @@ -52,11 +50,12 @@ class User < ActiveRecord::Base scope :admin, where(:role => 'admin') scope :real, where(:role => ['', nil]) - include Modules::Models::ActsLikeMember - after_create lambda { self.create_notifier } before_create :ensure_authentication_token + include Modules::Models::PersonalRepository + include Modules::Models::ActsLikeMember + def admin? role == 'admin' end @@ -70,13 +69,17 @@ class User < ActiveRecord::Base end def access_locked? - role == 'banned' + role == 'banned' end def fullname return "#{uname} (#{name})" end + def user_appeal + name.presence || uname + end + class << self def find_for_database_authentication(warden_conditions) conditions = warden_conditions.dup @@ -126,14 +129,4 @@ class User < ActiveRecord::Base false end end - - def user_appeal - name.blank? ? uname : name - end - - private - - def create_settings_notifier - self.create_notifier - end end diff --git a/app/views/activity_feeds/_sidebar.html.haml b/app/views/activity_feeds/_sidebar.html.haml index d22e733fc..baf06577f 100644 --- a/app/views/activity_feeds/_sidebar.html.haml +++ b/app/views/activity_feeds/_sidebar.html.haml @@ -18,7 +18,7 @@ %td = link_to t("layout.activity_feed.all_my_projects"), projects_path .block - - midnight = Date.today + - midnight = Time.now.utc.to_date %h3= t("layout.activity_feed.my_builds_by_day") %table{:cellpadding => "0", :cellspacing => "0"} %tbody diff --git a/app/views/activity_feeds/partials/_build_list_notification.haml b/app/views/activity_feeds/partials/_build_list_notification.haml index 71cc37532..c7cb4ce97 100644 --- a/app/views/activity_feeds/partials/_build_list_notification.haml +++ b/app/views/activity_feeds/partials/_build_list_notification.haml @@ -4,7 +4,7 @@ .text %span = raw t('notifications.bodies.build_task', :task_num => task_num, :task_link => build_list_path(build_list_id)) - = raw t('notifications.bodies.project', :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_id)) ) + = raw t('notifications.bodies.project', :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) ) - message, error = case status - when BuildList::BUILD_PENDING - ['pending', nil] diff --git a/app/views/activity_feeds/partials/_git_delete_branch_notification.haml b/app/views/activity_feeds/partials/_git_delete_branch_notification.haml index 1b5ff12f0..07eb376d9 100644 --- a/app/views/activity_feeds/partials/_git_delete_branch_notification.haml +++ b/app/views/activity_feeds/partials/_git_delete_branch_notification.haml @@ -2,7 +2,7 @@ .text %span = t('notifications.bodies.delete_branch', :branch_name => branch_name) - = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_id)) ) + = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) ) .both %span.date= activity_feed.created_at .both diff --git a/app/views/activity_feeds/partials/_git_new_push_notification.haml b/app/views/activity_feeds/partials/_git_new_push_notification.haml index 6d5488015..9c6f23edc 100644 --- a/app/views/activity_feeds/partials/_git_new_push_notification.haml +++ b/app/views/activity_feeds/partials/_git_new_push_notification.haml @@ -5,12 +5,12 @@ .text %span = raw t("notifications.bodies.#{change_type}_branch", {:branch_name => branch_name, :user_link => defined?(user_name) ? link_to(user_name, user_path(user_id)) : user_email}) - = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_id)) ) + = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) ) .both %span.date= activity_feed.created_at .both %span.subject - last_commits.each do |commit| - = link_to shortest_hash_id(commit[0]), commit_path(project_id, commit[0]) + = link_to shortest_hash_id(commit[0]), commit_path(project_owner, project_name, commit[0]) = commit[1] %br diff --git a/app/views/activity_feeds/partials/_issue_assign_notification.haml b/app/views/activity_feeds/partials/_issue_assign_notification.haml index 89b44c1fb..cf9df13d1 100644 --- a/app/views/activity_feeds/partials/_issue_assign_notification.haml +++ b/app/views/activity_feeds/partials/_issue_assign_notification.haml @@ -1,8 +1,8 @@ .top .text %span - = raw t("notifications.bodies.issue_assign_notification", { :issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id))}) - = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_id)) ) + = raw t("notifications.bodies.issue_assign_notification", { :issue_link => link_to(issue_title, project_issue_path(project_owner, project_name, issue_serial_id))}) + = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) ) .both %span.date= activity_feed.created_at .both diff --git a/app/views/activity_feeds/partials/_new_comment_commit_notification.haml b/app/views/activity_feeds/partials/_new_comment_commit_notification.haml index fc55dca15..003ffd448 100644 --- a/app/views/activity_feeds/partials/_new_comment_commit_notification.haml +++ b/app/views/activity_feeds/partials/_new_comment_commit_notification.haml @@ -4,8 +4,8 @@ .text %span = raw t("notifications.bodies.new_comment_notification.title", :user_link => link_to(user_name, user_path(user_id)) ) - = raw t("notifications.bodies.new_comment_notification.commit_content", {:commit_link => link_to(commit_message, commit_path(project_id, commit_id) + "#comment##{comment_id}")}) - = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_id)) ) + = raw t("notifications.bodies.new_comment_notification.commit_content", {:commit_link => link_to(commit_message, commit_path(project_owner, project_name, commit_id) + "#comment##{comment_id}")}) + = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) ) .both %span.date= activity_feed.created_at .both diff --git a/app/views/activity_feeds/partials/_new_comment_notification.haml b/app/views/activity_feeds/partials/_new_comment_notification.haml index 1f85c39e2..567aae9a3 100644 --- a/app/views/activity_feeds/partials/_new_comment_notification.haml +++ b/app/views/activity_feeds/partials/_new_comment_notification.haml @@ -4,8 +4,8 @@ .text %span = raw t("notifications.bodies.new_comment_notification.title", {:user_link => link_to(user_name, user_path(user_id))}) - = raw t("notifications.bodies.new_comment_notification.content", {:issue_link => link_to(issue_title, project_issue_path(project_id, issue_serial_id) + "#comment##{comment_id}")}) - = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_id)) ) + = raw t("notifications.bodies.new_comment_notification.content", {:issue_link => link_to(issue_title, project_issue_path(project_owner, project_name, issue_serial_id) + "#comment##{comment_id}")}) + = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) ) .both %span.date= activity_feed.created_at .both diff --git a/app/views/activity_feeds/partials/_new_issue_notification.haml b/app/views/activity_feeds/partials/_new_issue_notification.haml index dc82e2961..1d9e1ca06 100644 --- a/app/views/activity_feeds/partials/_new_issue_notification.haml +++ b/app/views/activity_feeds/partials/_new_issue_notification.haml @@ -3,8 +3,8 @@ = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar') .text %span - = raw t("notifications.bodies.new_issue_notification", { :user_link => link_to(user_name, user_path(user_id)), :issue_link => project_issue_path(project_id, issue_serial_id)}) - = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_id)) ) + = raw t("notifications.bodies.new_issue_notification", { :user_link => link_to(user_name, user_path(user_id)), :issue_link => project_issue_path(project_owner, project_name, issue_serial_id)}) + = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) ) .both %span.date= activity_feed.created_at .both diff --git a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml index 69b61f326..d21a3abd9 100644 --- a/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml +++ b/app/views/activity_feeds/partials/_wiki_new_commit_notification.haml @@ -3,8 +3,8 @@ = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar') .text %span - = raw t("notifications.bodies.wiki_new_commit_notification", {:user_link => user_name, :history_link => link_to("wiki", history_project_wiki_index_path(project_id))}) - = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_id)) ) + = raw t("notifications.bodies.wiki_new_commit_notification", {:user_link => user_name, :history_link => link_to("wiki", history_project_wiki_index_path(project_owner, project_name))}) + = raw t("notifications.bodies.project", :project_link => link_to("#{project_owner}/#{project_name}", project_path(project_owner, project_name)) ) .both %span.date= activity_feed.created_at .both diff --git a/app/views/admin/_submenu.html.haml b/app/views/admin/_submenu.html.haml deleted file mode 100644 index 015b19c98..000000000 --- a/app/views/admin/_submenu.html.haml +++ /dev/null @@ -1,3 +0,0 @@ -- content_for :submenu do - %nav - = render :partial => 'layouts/menu/top', :locals => {:which_menu => 'admins_menu'} diff --git a/app/views/admin/base/_submenu.html.haml b/app/views/admin/base/_submenu.html.haml new file mode 100644 index 000000000..bed7e8f02 --- /dev/null +++ b/app/views/admin/base/_submenu.html.haml @@ -0,0 +1,2 @@ +- content_for :submenu do + %nav= render 'layouts/menu/top', :which_menu => 'admins_menu' \ No newline at end of file diff --git a/app/views/event_logs/_description.html.haml b/app/views/admin/event_logs/_description.html.haml similarity index 100% rename from app/views/event_logs/_description.html.haml rename to app/views/admin/event_logs/_description.html.haml diff --git a/app/views/event_logs/_event_log.html.haml b/app/views/admin/event_logs/_event_log.html.haml similarity index 100% rename from app/views/event_logs/_event_log.html.haml rename to app/views/admin/event_logs/_event_log.html.haml diff --git a/app/views/admin/event_logs/index.html.haml b/app/views/admin/event_logs/index.html.haml new file mode 100644 index 000000000..66057901e --- /dev/null +++ b/app/views/admin/event_logs/index.html.haml @@ -0,0 +1,14 @@ +%h3.fix= title t("layout.event_logs.list_header") + +%table#datatable.tablesorter.list-users + %tr + %th.first= t("activerecord.attributes.event_log.kind") + %th= t("activerecord.attributes.event_log.created_at") + %th= t("activerecord.attributes.event_log.user") + %th= t("activerecord.attributes.event_log.ip") + %th= t("activerecord.attributes.event_log.protocol") + %th.last= t("activerecord.attributes.event_log.description") + = render @event_logs += will_paginate + += render 'submenu' diff --git a/app/views/admin/register_requests/index.html.haml b/app/views/admin/register_requests/index.html.haml new file mode 100644 index 000000000..a562479a3 --- /dev/null +++ b/app/views/admin/register_requests/index.html.haml @@ -0,0 +1,55 @@ +%div{:style => 'float: right; margin: 20px'} + = link_to t("layout.register_request.approved"), admin_register_requests_path(:scope => :approved) + \| + = link_to t("layout.register_request.rejected"), admin_register_requests_path(:scope => :rejected) +%h2.title= title t("layout.register_request.list_header") += form_tag admin_register_requests_path, :method => :put, :class => 'update_form' do + = hidden_field_tag 'update_type' + %table.tablesorter + %tr + %th   + %th= t("activerecord.attributes.register_request.name") + %th= t("activerecord.attributes.register_request.email") + %th= t("activerecord.attributes.register_request.interest") + %th= t("activerecord.attributes.register_request.more") + %th= t("activerecord.attributes.register_request.created_at") + %th + - @register_requests.each do |request| + %tr{:class => cycle("odd", "even")} + %td= check_box_tag 'request_ids[]', request.id + %td= request.name + - @user = User.find_by_email(request.email) if request.approved + %td= link_to_if @user, request.email, @user + %td= request.interest + %td= request.more + %td= request.created_at + %td + = link_to t("layout.approve"), approve_admin_register_request_path(request) if can? :approve, request + | + = link_to t("layout.reject"), reject_admin_register_request_path(request) if can? :reject, request + + .actions + %input#approve_registration{:type => 'button', :value => "Approve Selected"} + %input#reject_registration{:type => 'button', :value => "Reject Selected"} + += will_paginate @register_requests + +:javascript + $(function() { + var $form = $('form.update_form') + var change_update_type = function (type) { + $('input#update_type').val(type); + }; + $('#approve_registration').live('click', function(e) { + //set update_type to 'approve' + change_update_type('approve'); + $form.submit(); + }); + $('#reject_registration').live('click', function(e) { + //set update_type to 'reject' + change_update_type('reject'); + $form.submit(); + }); + }); + += render 'submenu' diff --git a/app/views/admin/users/_sidebar.html.haml b/app/views/admin/users/_sidebar.html.haml index 2a8d51566..a915d0e6e 100644 --- a/app/views/admin/users/_sidebar.html.haml +++ b/app/views/admin/users/_sidebar.html.haml @@ -1,7 +1,7 @@ - content_for :sidebar do .bordered - if can? :create, User.new - = link_to t("layout.users.new"), new_user_path, :class => 'button' + = link_to t("layout.users.new"), new_admin_user_path, :class => 'button' %h3= t("layout.users.filter_header") %table - t('layout.users.users_filter').each_key do |base| diff --git a/app/views/admin/users/_users_ajax.js.erb b/app/views/admin/users/_users_ajax.js.erb index 433991b04..76db767ec 100644 --- a/app/views/admin/users/_users_ajax.js.erb +++ b/app/views/admin/users/_users_ajax.js.erb @@ -9,9 +9,9 @@ "<%= user.uname %>", "<%= user.email %>", "'><%= user.role %>", - "<%= j raw [(link_to t('layout.show'), user_path(user) if can? :read, user), - (link_to t('layout.edit'), edit_user_path(user) if can? :edit, user), - (link_to t('layout.delete'), delete_user_path(user), :method => :delete, :confirm => t('layout.users.confirm_delete') if can? :destroy, user) + "<%= j raw [(link_to t('layout.show'), user if can? :read, user), + (link_to t('layout.edit'), edit_admin_user_path(user) if can? :edit, user), + (link_to t('layout.delete'), admin_user_path(user), :method => :delete, :confirm => t('layout.users.confirm_delete') if can? :destroy, user) ].compact.join(' | ') %>" ]<%= user == @users.last ? '' : ',' %> <% end %> diff --git a/app/views/admin/users/edit.html.haml b/app/views/admin/users/edit.html.haml new file mode 100644 index 000000000..7a591b180 --- /dev/null +++ b/app/views/admin/users/edit.html.haml @@ -0,0 +1,10 @@ +.block + .content + %h2.title= title t("layout.users.edit_header") + .inner + = form_for @user, :url => admin_user_path(@user), :html => {:class => :form} do |f| + = render "users/base/form", :f => f + +- content_for :sidebar do + .bordered.nopadding += render 'submenu' diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml index b7ae19533..3bf70d3cd 100644 --- a/app/views/admin/users/index.html.haml +++ b/app/views/admin/users/index.html.haml @@ -23,8 +23,8 @@ %tbody %br -= render :partial => 'admin/users/sidebar' -= render 'admin/submenu' += render 'sidebar' += render 'submenu' :javascript $('#users_filter[type="radio"]').live('change', function(){ diff --git a/app/views/admin/users/new.html.haml b/app/views/admin/users/new.html.haml index 89cda022d..9fd4a4f9f 100644 --- a/app/views/admin/users/new.html.haml +++ b/app/views/admin/users/new.html.haml @@ -2,10 +2,9 @@ .content %h2.title= title t("layout.users.new_header") .inner - = form_for @user, :url => create_user_path, :html => { :class => :form } do |f| - = render :partial => "users/form", :locals => {:f => f} + = form_for @user, :url => admin_users_path, :html => {:class => :form} do |f| + = render "users/base/form", :f => f - content_for :sidebar do .bordered.nopadding - -= render 'admin/submenu' += render 'submenu' diff --git a/app/views/admin/users/profile.html.haml b/app/views/admin/users/profile.html.haml deleted file mode 100644 index 1c0fcf7ea..000000000 --- a/app/views/admin/users/profile.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -%h3.fix.bpadding10= title @user.uname - -= form_for @user, :url => update_user_path(@user), :html => { :class => :form } do |f| - = render :partial => "users/form", :locals => {:f => f} - -.notify - %p= t('layout.users.public_data_edit_warning') -.notify - %p= t('layout.users.avatar_notice') - -:javascript - $('article .right').addClass('middlepadding'); - -= render 'admin/submenu' -- content_for :sidebar do - .bordered.nopadding diff --git a/app/views/devise/confirmations/new.html.haml b/app/views/devise/confirmations/new.html.haml index 5933d7e57..4331a6dee 100644 --- a/app/views/devise/confirmations/new.html.haml +++ b/app/views/devise/confirmations/new.html.haml @@ -20,4 +20,4 @@ = image_tag("choose.png", :alt => t("devise.confirmations.send")) = t("devise.confirmations.send") %span.text_button_padding - = render :partial => "devise/shared/links" \ No newline at end of file + = render "devise/shared/links" \ No newline at end of file diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/devise/registrations/edit.html.haml index c60558d4c..ce7f42306 100644 --- a/app/views/devise/registrations/edit.html.haml +++ b/app/views/devise/registrations/edit.html.haml @@ -1,7 +1,7 @@ %h3.fix.bpadding10= @user.uname = form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => "form" }) do |f| - = render :partial => "users/form", :locals => {:f => f} + = render "users/form", :f => f .notify %p= t('layout.users.public_data_edit_warning') diff --git a/app/views/devise/unlocks/new.html.haml b/app/views/devise/unlocks/new.html.haml index afb0daa81..15a031a7c 100644 --- a/app/views/devise/unlocks/new.html.haml +++ b/app/views/devise/unlocks/new.html.haml @@ -6,4 +6,4 @@ %br/ = f.text_field :email %p= f.submit "Resend unlock instructions" -= render :partial => "devise/shared/links" += render "devise/shared/links" diff --git a/app/views/event_logs/index.html.haml b/app/views/event_logs/index.html.haml deleted file mode 100644 index aba26befe..000000000 --- a/app/views/event_logs/index.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -.block - .secondary-navigation - %ul.wat-cf - %li.first.active= link_to t("layout.event_logs.list"), event_logs_path - .content - %h2.title - = title t("layout.event_logs.list_header") - .inner - %table.table - %tr - %th.first= t("activerecord.attributes.event_log.kind") - %th= t("activerecord.attributes.event_log.created_at") - %th= t("activerecord.attributes.event_log.user") - %th= t("activerecord.attributes.event_log.ip") - %th= t("activerecord.attributes.event_log.protocol") - %th.last= t("activerecord.attributes.event_log.description") - = render @event_logs - .actions-bar.wat-cf - .actions= will_paginate - -= render 'admin/submenu' diff --git a/app/views/git/commits/index.html.haml b/app/views/git/commits/index.html.haml deleted file mode 100644 index 3797be46f..000000000 --- a/app/views/git/commits/index.html.haml +++ /dev/null @@ -1,6 +0,0 @@ --set_meta_tags :title => [title_object(@project), "#{t '.title'} #{t('at') if @branch} #{@branch.try :name}"] -= render :partial => 'projects/submenu' -= render :partial => 'projects/repo_block', :locals => {:project => @project} - -= render :partial => 'git/commits/commits', :object => @commits -= render 'git/commits/paginate' if @render_paginate diff --git a/app/views/groups/_form.html.haml b/app/views/groups/_form.html.haml deleted file mode 100644 index 62463254f..000000000 --- a/app/views/groups/_form.html.haml +++ /dev/null @@ -1,19 +0,0 @@ -- act = controller.action_name.to_sym -- if [:new, :create].include? act - .leftlist - = f.label :uname, t("activerecord.attributes.group.uname"), :class => :label - .rightlist.nomargin - = f.text_field :uname - .both -%br -.leftlist - = f.label :description, t("activerecord.attributes.group.description"), :class => :label -.rightlist.nomargin - = f.text_area :description -.both -%br -.leftlist - \  -.rightlist - = submit_tag t("layout.save") -.both diff --git a/app/views/groups/_sidebar.html.haml b/app/views/groups/base/_sidebar.html.haml similarity index 54% rename from app/views/groups/_sidebar.html.haml rename to app/views/groups/base/_sidebar.html.haml index abe3e44b0..0cf0595b0 100644 --- a/app/views/groups/_sidebar.html.haml +++ b/app/views/groups/base/_sidebar.html.haml @@ -6,8 +6,8 @@ .admin-preferences %ul - if can? :edit, @group - %li{:class => (act == :edit && contr == :groups) ? 'active' : ''} + %li{:class => (act == :edit && contr == :profile) ? 'active' : ''} = link_to t("layout.groups.edit"), edit_group_path(@group) - if can? :manage_members, @group - %li{:class => (act == :edit && contr == :members) ? 'active' : ''} - = link_to t("layout.groups.edit_members"), edit_group_members_path(@group) + %li{:class => (act == :index && contr == :members) ? 'active' : ''} + = link_to t("layout.groups.edit_members"), group_members_path(@group) diff --git a/app/views/groups/edit.html.haml b/app/views/groups/edit.html.haml deleted file mode 100644 index 9ade14a3a..000000000 --- a/app/views/groups/edit.html.haml +++ /dev/null @@ -1,18 +0,0 @@ --set_meta_tags :title => [title_object(@group), t('layout.groups.edit')] -= form_for @group, :html => { :class => :form, :multipart => true } do |f| - = render :partial => "form", :locals => {:f => f} - -.hr -.groups-profile - = image_tag('code.png') -.groups-profile - = link_to t("layout.groups.public_profile"), @group -.both -.hr -.leftside - = t("layout.groups.delete_warning") -.rightside - = link_to t("layout.delete"), group_path(@group), :method => :delete, :confirm => t("layout.groups.confirm_delete"), :class => 'button' if can? :destroy, @group -.both - -- content_for :sidebar, render('sidebar') diff --git a/app/views/members/edit.html.haml b/app/views/groups/members/index.html.haml similarity index 53% rename from app/views/members/edit.html.haml rename to app/views/groups/members/index.html.haml index db09dab07..0fb2ab5f0 100644 --- a/app/views/members/edit.html.haml +++ b/app/views/groups/members/index.html.haml @@ -6,35 +6,28 @@ %tr %th \  - %th - = t("layout.collaborators.members") - %th{:colspan => "3"} - = t("layout.collaborators.roles") + %th= t("layout.collaborators.members") + %th{:colspan => "3"}= t("layout.collaborators.roles") %tbody - - @users.each do |user| + - (parent.members - [parent.owner]).each do |user| %tr %td - %span#niceCheckbox1.niceCheck-main - = check_box_tag "user_remove[#{user.id}][]" + %span#niceCheckbox1.niceCheck-main= check_box_tag "user_remove[#{user.id}][]" %td - .img - = image_tag avatar_url(user) + .img= image_tag avatar_url(user) .forimg= link_to user.name, user_path(user) - Relation::ROLES.each_with_index do |role, i| %td - .radio - = radio_button_tag "user[#{user.id}]", role, ((parent.actors.exists? :actor_id => user.id, :actor_type => 'User', :role => role) ? :checked : nil), :class => 'niceRadio' + .radio= radio_button_tag "user[#{user.id}]", role, ((parent.actors.exists? :actor_id => user.id, :actor_type => 'User', :role => role) ? :checked : nil), :class => 'niceRadio' .forradio= t("layout.collaborators.role_names.#{ role }") = link_to_function t("layout.delete"), "deleteAdminMember();", :class => 'button' .both .hr.top = form_tag add_group_members_path(parent) do - .admin-search - = autocomplete_field_tag 'user_id', params[:user_id], autocomplete_user_uname_users_path#, :id_element => '#member_id_field' + .admin-search= autocomplete_field_tag 'user_id', params[:user_id], autocomplete_user_uname_users_path#, :id_element => '#member_id_field' .admin-role - .lineForm - = select_tag 'role', options_for_collaborators_roles_select + .lineForm= select_tag 'role', options_for_collaborators_roles_select .both %br = submit_tag t("layout.add"), :class => 'button' @@ -43,4 +36,4 @@ .both = link_to_function t("layout.save"), "saveAdminMember();", :class => 'button' -- content_for :sidebar, render('groups/sidebar') +- content_for :sidebar, render('sidebar') diff --git a/app/views/groups/profile/_form.html.haml b/app/views/groups/profile/_form.html.haml new file mode 100644 index 000000000..f30cb0ab4 --- /dev/null +++ b/app/views/groups/profile/_form.html.haml @@ -0,0 +1,14 @@ +- act = controller.action_name.to_sym +- if [:new, :create].include? act + .leftlist= f.label :uname, t("activerecord.attributes.group.uname"), :class => :label + .rightlist.nomargin= f.text_field :uname + .both +%br +.leftlist= f.label :description, t("activerecord.attributes.group.description"), :class => :label +.rightlist.nomargin= f.text_area :description +.both +%br +.leftlist + \  +.rightlist= submit_tag t("layout.save") +.both diff --git a/app/views/groups/profile/edit.html.haml b/app/views/groups/profile/edit.html.haml new file mode 100644 index 000000000..e4846961f --- /dev/null +++ b/app/views/groups/profile/edit.html.haml @@ -0,0 +1,15 @@ +-set_meta_tags :title => [title_object(@group), t('layout.groups.edit')] += form_for @group, :url => profile_group_path(@group) do |f| + = render "form", :f => f + +.hr +.groups-profile= image_tag('code.png') +.groups-profile= link_to t("layout.groups.public_profile"), @group +.both +.hr +.leftside= t("layout.groups.delete_warning") +.rightside + = link_to t("layout.delete"), profile_group_path(@group), :method => :delete, :confirm => t("layout.groups.confirm_delete"), :class => 'button' if can? :destroy, @group +.both + +- content_for :sidebar, render('sidebar') diff --git a/app/views/groups/index.html.haml b/app/views/groups/profile/index.html.haml similarity index 77% rename from app/views/groups/index.html.haml rename to app/views/groups/profile/index.html.haml index e0514172a..ab3b12855 100644 --- a/app/views/groups/index.html.haml +++ b/app/views/groups/profile/index.html.haml @@ -12,4 +12,4 @@ %td= link_to group.name, group_path(group) %td.td2= group.description %td.td5 - = link_to image_tag('x.png'), remove_group_member_path(group, current_user), :method => :delete unless group.owner_id == current_user.id + = link_to image_tag('x.png'), remove_user_group_path(group), :method => :delete unless group.owner_id == current_user.id diff --git a/app/views/groups/new.html.haml b/app/views/groups/profile/new.html.haml similarity index 52% rename from app/views/groups/new.html.haml rename to app/views/groups/profile/new.html.haml index 462b23a5a..077c32394 100644 --- a/app/views/groups/new.html.haml +++ b/app/views/groups/profile/new.html.haml @@ -1,6 +1,6 @@ %h3.bpadding10= title t("layout.groups.new_header") -= form_for @group, :url => groups_path do |f| - = render :partial => "form", :locals => {:f => f} += form_for @group do |f| + = render "form", :f => f :javascript $('article .all').addClass('bigpadding'); diff --git a/app/views/groups/show.html.haml b/app/views/groups/profile/show.html.haml similarity index 90% rename from app/views/groups/show.html.haml rename to app/views/groups/profile/show.html.haml index 0f6527404..8525cffe3 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/profile/show.html.haml @@ -5,7 +5,7 @@ %p= @group.description %h4= t("layout.groups.projects_list") + ":" %p - - @group.projects.each do |project| + - @projects.each do |project| = link_to project.name, project %br %br diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index c4b4a01fe..642d9b82e 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -19,7 +19,7 @@ .middle %menu .logo= link_to image_tag('logo-mini.png', :alt => 'logo'), root_path - = render :partial => 'layouts/menu/top', :locals => {:which_menu => 'top_menu'} + = render 'layouts/menu/top', :which_menu => 'top_menu' .information = render 'search/form' - if current_user @@ -34,7 +34,7 @@ .droplist-wrap #droplist.droplist .a= link_to current_user.uname, current_user - .a= link_to t('layout.settings.label'), edit_profile_path + .a= link_to t('layout.settings.label'), profile_settings_path .a= link_to t('layout.logout'), destroy_user_session_path, :method => :delete - else .user diff --git a/app/views/layouts/menu/_top.html.haml b/app/views/layouts/menu/_top.html.haml index 182505e75..552c34fa0 100644 --- a/app/views/layouts/menu/_top.html.haml +++ b/app/views/layouts/menu/_top.html.haml @@ -1,6 +1,7 @@ +- namespace = which_menu == 'admins_menu' ? 'admin_' : '' %ul - (collection = t which_menu).each do |base, title| - if can? :index, base.to_s.classify.constantize - %li= link_to title, send(:"#{base}_path"), :class => controller_name == base.to_s ? 'active' : '' + %li= link_to title, send(:"#{namespace}#{base}_path"), :class => params[:controller].include?(base.to_s) ? 'active' : '' - if current_user.try(:admin?) and which_menu == 'top_menu' - %li= link_to t('admins_menu_header'), users_path, :class => t('admins_menu').has_key?(controller_name.to_sym) ? 'active' : '' + %li= link_to t('admins_menu_header'), admin_users_path, :class => t('admins_menu').has_key?(controller_name.to_sym) ? 'active' : '' diff --git a/app/views/layouts/sessions.html.haml b/app/views/layouts/sessions.html.haml index 2d75d1707..dec6eecf5 100644 --- a/app/views/layouts/sessions.html.haml +++ b/app/views/layouts/sessions.html.haml @@ -13,7 +13,7 @@ = display_meta_tags :site => APP_CONFIG['project_name'], :reverse => true, :separator => '-' %body - -# render :partial => "layouts/flashes" + -# render "layouts/flashes" = yield = render 'layouts/counters' unless current_user.try(:admin?) diff --git a/app/views/pages/tos.html.haml b/app/views/pages/tos.html.haml index 1291633e2..46bd71c76 100644 --- a/app/views/pages/tos.html.haml +++ b/app/views/pages/tos.html.haml @@ -1,4 +1,4 @@ -- render :partial => 'tos_sidebar' +- render 'tos_sidebar' .tos %a{:name => '#'} diff --git a/app/views/platforms/_sidebar.html.haml b/app/views/platforms/base/_sidebar.html.haml similarity index 89% rename from app/views/platforms/_sidebar.html.haml rename to app/views/platforms/base/_sidebar.html.haml index 8813540d4..f7d587fa5 100644 --- a/app/views/platforms/_sidebar.html.haml +++ b/app/views/platforms/base/_sidebar.html.haml @@ -22,8 +22,3 @@ -#- if current_user.owner_of? @platform or current_user.admin? %li{:class => (act == :index && contr == :private_users) ? 'active' : ''} = link_to t("layout.platforms.private_users"), platform_private_users_path(@platform) --#.block.notice - %h3= t("layout.groups.members") - .content - - @platform.members.uniq.each do |member| - %p= link_to member.name + "", user_path(member) diff --git a/app/views/platforms/_submenu.html.haml b/app/views/platforms/base/_submenu.html.haml similarity index 100% rename from app/views/platforms/_submenu.html.haml rename to app/views/platforms/base/_submenu.html.haml diff --git a/app/views/platforms/edit.html.haml b/app/views/platforms/edit.html.haml deleted file mode 100644 index ba64a2fac..000000000 --- a/app/views/platforms/edit.html.haml +++ /dev/null @@ -1,13 +0,0 @@ --set_meta_tags :title => [title_object(@platform), t('layout.platforms.edit')] -= render :partial => 'submenu' -= render :partial => 'sidebar' - -= form_for @platform, :url => platform_path(@platform), :html => { :class => :form } do |f| - = render :partial => "form", :locals => {:f => f} - -- if can? :destroy, @platform - .hr - .leftside - = t("layout.platforms.delete_warning") - .rightside - = link_to t("layout.delete"), platform_path(@platform), :method => :delete, :confirm => t("layout.platforms.confirm_delete"), :class => 'button' \ No newline at end of file diff --git a/app/views/platforms/new.html.haml b/app/views/platforms/new.html.haml deleted file mode 100644 index a88430eba..000000000 --- a/app/views/platforms/new.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -%h3= title t("layout.platforms.new_header") - -= form_for :platform, :url => platforms_path, :html => { :class => :form } do |f| - = render :partial => "form", :locals => {:f => f} - --#.block - .secondary-navigation - %ul.wat-cf - %li.first= link_to "#{t("layout.platforms.list")}", platforms_path - %li.active= link_to "#{t("layout.platforms.new")}", new_platform_path - .content - %h2.title - = t("layout.platforms.new_header") - .inner - = form_for :platform, :url => platforms_path, :html => { :class => :form } do |f| - = render :partial => "form", :locals => {:f => f} diff --git a/app/views/platforms/_connection_info.html.haml b/app/views/platforms/platforms/_connection_info.html.haml similarity index 100% rename from app/views/platforms/_connection_info.html.haml rename to app/views/platforms/platforms/_connection_info.html.haml diff --git a/app/views/platforms/_form.html.haml b/app/views/platforms/platforms/_form.html.haml similarity index 100% rename from app/views/platforms/_form.html.haml rename to app/views/platforms/platforms/_form.html.haml diff --git a/app/views/platforms/_list.html.haml b/app/views/platforms/platforms/_list.html.haml similarity index 69% rename from app/views/platforms/_list.html.haml rename to app/views/platforms/platforms/_list.html.haml index 5579856a8..b146945a7 100644 --- a/app/views/platforms/_list.html.haml +++ b/app/views/platforms/platforms/_list.html.haml @@ -6,7 +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 + %td= link_to platfrom_printed_name(platform), platform_path(platform) + %td= platform.distrib_type \ No newline at end of file diff --git a/app/views/platforms/clone.html.haml b/app/views/platforms/platforms/clone.html.haml similarity index 88% rename from app/views/platforms/clone.html.haml rename to app/views/platforms/platforms/clone.html.haml index dcbb6dd7b..e72f71a65 100644 --- a/app/views/platforms/clone.html.haml +++ b/app/views/platforms/platforms/clone.html.haml @@ -1,6 +1,6 @@ -set_meta_tags :title => [title_object(@platform), t('layout.platforms.clone_header')] -= render :partial => 'submenu' -= render :partial => 'sidebar' += render 'submenu' += render 'sidebar' = form_for @cloned, :url => make_clone_platform_path(@platform), :html => { :class => :form } do |f| .leftlist= f.label :name, :class => :label diff --git a/app/views/platforms/platforms/edit.html.haml b/app/views/platforms/platforms/edit.html.haml new file mode 100644 index 000000000..a397e71d1 --- /dev/null +++ b/app/views/platforms/platforms/edit.html.haml @@ -0,0 +1,11 @@ +-set_meta_tags :title => [title_object(@platform), t('layout.platforms.edit')] += render 'submenu' += render 'sidebar' + += form_for @platform, :url => platform_path(@platform), :html => { :class => :form } do |f| + = render "form", :f => f + +- if can? :destroy, @platform + .hr + .leftside= t("layout.platforms.delete_warning") + .rightside= link_to t("layout.delete"), platform_path(@platform), :method => :delete, :confirm => t("layout.platforms.confirm_delete"), :class => 'button' diff --git a/app/views/platforms/index.html.haml b/app/views/platforms/platforms/index.html.haml similarity index 75% rename from app/views/platforms/index.html.haml rename to app/views/platforms/platforms/index.html.haml index 9d3b95c9a..e8e000676 100644 --- a/app/views/platforms/index.html.haml +++ b/app/views/platforms/platforms/index.html.haml @@ -1,4 +1,4 @@ -set_meta_tags :title => t('layout.platforms.list_header') = link_to t("layout.platforms.new"), new_platform_path, :class => 'button' if can? :create, Platform -= render :partial => 'platforms/list', :object => @platforms += render 'list', :object => @platforms = will_paginate @platforms diff --git a/app/views/platforms/members.html.haml b/app/views/platforms/platforms/members.html.haml similarity index 96% rename from app/views/platforms/members.html.haml rename to app/views/platforms/platforms/members.html.haml index 65eaff72d..5133f220f 100644 --- a/app/views/platforms/members.html.haml +++ b/app/views/platforms/platforms/members.html.haml @@ -1,6 +1,6 @@ -set_meta_tags :title => [title_object(@platform), t('layout.platforms.members')] -= render :partial => 'submenu' -= render :partial => 'sidebar' += render 'submenu' += render 'sidebar' = form_tag remove_members_platform_path(@platform), :id => 'members_form', :method => :post do %table.tablesorter{:cellpadding => "0", :cellspacing => "0"} diff --git a/app/views/platforms/platforms/new.html.haml b/app/views/platforms/platforms/new.html.haml new file mode 100644 index 000000000..5f9dc3767 --- /dev/null +++ b/app/views/platforms/platforms/new.html.haml @@ -0,0 +1,4 @@ +%h3= title t("layout.platforms.new_header") + += form_for :platform, :url => platforms_path, :html => { :class => :form } do |f| + = render "form", :f => f diff --git a/app/views/platforms/show.html.haml b/app/views/platforms/platforms/show.html.haml similarity index 86% rename from app/views/platforms/show.html.haml rename to app/views/platforms/platforms/show.html.haml index 7deb4e467..3066eef08 100644 --- a/app/views/platforms/show.html.haml +++ b/app/views/platforms/platforms/show.html.haml @@ -1,6 +1,6 @@ -set_meta_tags :title => title_object(@platform) -= render :partial => 'submenu' -= render :partial => 'sidebar' += render 'submenu' += render 'sidebar' %h3.fix= "#{t("layout.platforms.about")} #{@platform.name}" @@ -34,5 +34,4 @@ = link_to t("layout.platforms.build_all"), build_all_platform_path(@platform), :confirm => I18n.t("layout.confirm"), :method => :post, :class => "button left_floated" = link_to I18n.t("layout.platforms.clone"), clone_platform_path(@platform), :class => "button left_floated" if can? :clone, @platform -- if @platform.platform_type == 'personal' and @platform.visibility == 'open' - = render :partial => 'connection_info' \ No newline at end of file += render 'connection_info' if @platform.platform_type == 'personal' and @platform.visibility == 'open' diff --git a/app/views/private_users/index.html.haml b/app/views/platforms/private_users/index.html.haml similarity index 100% rename from app/views/private_users/index.html.haml rename to app/views/platforms/private_users/index.html.haml diff --git a/app/views/product_build_lists/_filter.html.haml b/app/views/platforms/product_build_lists/_filter.html.haml similarity index 100% rename from app/views/product_build_lists/_filter.html.haml rename to app/views/platforms/product_build_lists/_filter.html.haml diff --git a/app/views/product_build_lists/_product_build_list.html.haml b/app/views/platforms/product_build_lists/_product_build_list.html.haml similarity index 100% rename from app/views/product_build_lists/_product_build_list.html.haml rename to app/views/platforms/product_build_lists/_product_build_list.html.haml diff --git a/app/views/product_build_lists/index.html.haml b/app/views/platforms/product_build_lists/index.html.haml similarity index 79% rename from app/views/product_build_lists/index.html.haml rename to app/views/platforms/product_build_lists/index.html.haml index cbf0f4e9a..7103bcfe9 100644 --- a/app/views/product_build_lists/index.html.haml +++ b/app/views/platforms/product_build_lists/index.html.haml @@ -1,5 +1,4 @@ -set_meta_tags :title => t('.title') -/ #myTable %table.tablesorter{:cellpadding => "0", :cellspacing => "0"} %thead %tr @@ -10,10 +9,10 @@ -#%th.lpadding16= t("activerecord.attributes.product_build_list.user") %th= t("layout.product_build_lists.action") %th.lpadding16= t("activerecord.attributes.product_build_list.notified_at") - %tbody= render @product_build_lists + %tbody= render :partial => 'platforms/product_build_lists/product_build_list', :collection => @product_build_lists .both = will_paginate @product_build_lists -= render 'product_build_lists/filter' -= render 'build_lists/submenu' += render 'filter' += render 'projects/build_lists/submenu' diff --git a/app/views/products/_crontab.html.haml b/app/views/platforms/products/_crontab.html.haml similarity index 100% rename from app/views/products/_crontab.html.haml rename to app/views/platforms/products/_crontab.html.haml diff --git a/app/views/products/_form.html.haml b/app/views/platforms/products/_form.html.haml similarity index 96% rename from app/views/products/_form.html.haml rename to app/views/platforms/products/_form.html.haml index 02c1024af..ea8f33886 100644 --- a/app/views/products/_form.html.haml +++ b/app/views/platforms/products/_form.html.haml @@ -35,7 +35,7 @@ .rightlist= f.check_box :delete_tar .both -= render :partial => "products/crontab", :locals => { :form => f } += render "crontab", :form => f .both .button_block diff --git a/app/views/products/_list.html.haml b/app/views/platforms/products/_list.html.haml similarity index 100% rename from app/views/products/_list.html.haml rename to app/views/platforms/products/_list.html.haml diff --git a/app/views/products/edit.html.haml b/app/views/platforms/products/edit.html.haml similarity index 67% rename from app/views/products/edit.html.haml rename to app/views/platforms/products/edit.html.haml index 526ce659c..90cc286c7 100644 --- a/app/views/products/edit.html.haml +++ b/app/views/platforms/products/edit.html.haml @@ -1,6 +1,6 @@ -set_meta_tags :title => [title_object(@product), t('title_editing')] -= render :partial => 'platforms/submenu' -= render :partial => 'platforms/sidebar' += render 'submenu' += render 'sidebar' %h3 = t("layout.products.edit_header") @@ -8,5 +8,5 @@ %br = form_for [@platform, @product], :html => { :class => :form, :multipart => true } do |f| - = render :partial => "form", :locals => {:f => f} + = render "form", :f => f diff --git a/app/views/products/index.html.haml b/app/views/platforms/products/index.html.haml similarity index 57% rename from app/views/products/index.html.haml rename to app/views/platforms/products/index.html.haml index 4a3c30741..a2788c4f4 100644 --- a/app/views/products/index.html.haml +++ b/app/views/platforms/products/index.html.haml @@ -1,7 +1,7 @@ -set_meta_tags :title => [title_object(@platform), t('layout.products.list_header')] -= render :partial => 'platforms/submenu' if params[:platform_id] -= render :partial => 'platforms/sidebar' if params[:platform_id] += render 'submenu' if params[:platform_id] += render 'sidebar' if params[:platform_id] = link_to t("layout.products.new"), new_platform_product_path(@platform), :class => 'button' if can? :create, @platform.products.build -= render :partial => 'list', :object => @products += render 'list', :object => @products = will_paginate @products diff --git a/app/views/products/new.html.haml b/app/views/platforms/products/new.html.haml similarity index 55% rename from app/views/products/new.html.haml rename to app/views/platforms/products/new.html.haml index 929b68c8b..5ed82d8ac 100644 --- a/app/views/products/new.html.haml +++ b/app/views/platforms/products/new.html.haml @@ -1,7 +1,6 @@ -set_meta_tags :title => [title_object(@platform), t('layout.products.new')] -= render :partial => 'platforms/submenu' -= render :partial => 'platforms/sidebar' += render 'submenu' += render 'sidebar' = form_for [@platform, @product], :html => { :class => :form, :multipart => true } do |f| - = render :partial => "form", :locals => {:f => f} - + = render "form", :f => f diff --git a/app/views/products/show.html.haml b/app/views/platforms/products/show.html.haml similarity index 88% rename from app/views/products/show.html.haml rename to app/views/platforms/products/show.html.haml index 4615db826..b53981594 100644 --- a/app/views/products/show.html.haml +++ b/app/views/platforms/products/show.html.haml @@ -1,6 +1,6 @@ -set_meta_tags :title => title_object(@product) -= render :partial => 'platforms/submenu' -= render :partial => 'platforms/sidebar' += render 'submenu' += render 'sidebar' %h3 #{t("layout.products.about")} #{@product.name} @@ -25,4 +25,4 @@ %th= t("layout.product_build_lists.product") %th= t("layout.product_build_lists.action") %th= t("activerecord.attributes.product_build_list.notified_at") - %tbody= render @product.product_build_lists.default_order + %tbody= render :partial => 'platforms/product_build_lists/product_build_list', :collection => @product.product_build_lists.default_order diff --git a/app/views/repositories/_form.html.haml b/app/views/platforms/repositories/_form.html.haml similarity index 80% rename from app/views/repositories/_form.html.haml rename to app/views/platforms/repositories/_form.html.haml index 81adfa1d3..2539464d6 100644 --- a/app/views/repositories/_form.html.haml +++ b/app/views/platforms/repositories/_form.html.haml @@ -8,8 +8,5 @@ .button_block = submit_tag t("layout.save") - -#%input.button{:type => "submit", :class => "button"} - -#= image_tag("choose.png", :alt => t("layout.save")) - -#= t("layout.clone") %span.text_button_padding= t("layout.or") = link_to t("layout.cancel"), @repository.new_record? ? platform_repositories_path(@platform) : platform_repository_path(@platform, @repository), :class => "button" diff --git a/app/views/repositories/_list.html.haml b/app/views/platforms/repositories/_list.html.haml similarity index 57% rename from app/views/repositories/_list.html.haml rename to app/views/platforms/repositories/_list.html.haml index f1df53f26..69ef431d5 100644 --- a/app/views/repositories/_list.html.haml +++ b/app/views/platforms/repositories/_list.html.haml @@ -14,14 +14,4 @@ %td.buttons - if can? :destroy, repository = link_to platform_repository_path(@platform, repository), :method => :delete, :confirm => t("layout.repositories.confirm_delete") do - %span.delete   --#%table.table - %tr - %th.first= t("activerecord.attributes.repository.name") - %th.last   - - @repositories.each do |repository| - %tr{:class => cycle("odd", "even")} - %td - = link_to repository.name, repository_path(repository) - %td.last - #{link_to t("layout.show"), repository_path(repository)} | #{link_to t("layout.delete"), repository_path(repository), :method => :delete, :confirm => t("layout.repositories.confirm_delete")} + %span.delete   \ No newline at end of file diff --git a/app/views/repositories/_proj_ajax.js.erb b/app/views/platforms/repositories/_proj_ajax.js.erb similarity index 100% rename from app/views/repositories/_proj_ajax.js.erb rename to app/views/platforms/repositories/_proj_ajax.js.erb diff --git a/app/views/repositories/_proj_list.html.haml b/app/views/platforms/repositories/_proj_list.html.haml similarity index 100% rename from app/views/repositories/_proj_list.html.haml rename to app/views/platforms/repositories/_proj_list.html.haml diff --git a/app/views/repositories/_project.html.haml b/app/views/platforms/repositories/_project.html.haml similarity index 100% rename from app/views/repositories/_project.html.haml rename to app/views/platforms/repositories/_project.html.haml diff --git a/app/views/repositories/_project.js.erb b/app/views/platforms/repositories/_project.js.erb similarity index 100% rename from app/views/repositories/_project.js.erb rename to app/views/platforms/repositories/_project.js.erb diff --git a/app/views/platforms/repositories/index.html.haml b/app/views/platforms/repositories/index.html.haml new file mode 100644 index 000000000..bdadba3ac --- /dev/null +++ b/app/views/platforms/repositories/index.html.haml @@ -0,0 +1,6 @@ +-set_meta_tags :title => [title_object(@platform), t('layout.repositories.list_header')] += render 'submenu' if params[:platform_id] += render 'sidebar' if params[:platform_id] += link_to t("layout.repositories.new"), new_platform_repository_path(@platform), :class => 'button' if can? :create, @platform.repositories.build += render 'list', :object => @repositories += will_paginate @repositories diff --git a/app/views/repositories/new.html.haml b/app/views/platforms/repositories/new.html.haml similarity index 63% rename from app/views/repositories/new.html.haml rename to app/views/platforms/repositories/new.html.haml index c17741890..72740cbb4 100644 --- a/app/views/repositories/new.html.haml +++ b/app/views/platforms/repositories/new.html.haml @@ -1,8 +1,8 @@ -set_meta_tags :title => [title_object(@platform), t('layout.repositories.new')] -= render :partial => 'platforms/submenu' -= render :partial => 'platforms/sidebar' += render 'submenu' += render 'sidebar' %h3= t("layout.repositories.new_header") = form_for :repository, :url => platform_repositories_path(@platform), :html => { :class => :form } do |f| - = render :partial => "form", :locals => {:f => f} + = render "form", :f => f diff --git a/app/views/platforms/repositories/projects_list.html.haml b/app/views/platforms/repositories/projects_list.html.haml new file mode 100644 index 000000000..26de0610c --- /dev/null +++ b/app/views/platforms/repositories/projects_list.html.haml @@ -0,0 +1,6 @@ += render 'submenu' += render 'sidebar' + +%h3= raw "#{t("layout.repositories.add_project_to")}: #{link_to @repository.name, platform_repository_path(@platform, @repository)}" + += render 'proj_list', :object => @projects diff --git a/app/views/repositories/show.html.haml b/app/views/platforms/repositories/show.html.haml similarity index 75% rename from app/views/repositories/show.html.haml rename to app/views/platforms/repositories/show.html.haml index b14f663cd..dedcb69e6 100644 --- a/app/views/repositories/show.html.haml +++ b/app/views/platforms/repositories/show.html.haml @@ -1,6 +1,6 @@ -set_meta_tags :title => title_object(@repository) -= render :partial => 'platforms/submenu' -= render :partial => 'platforms/sidebar' += render 'submenu' += render 'sidebar' %h3.fix= "#{t("layout.repositories.about")}: #{@repository.name}" @@ -12,4 +12,4 @@ - if can? :add_project, @repository = link_to t("layout.projects.add"), add_project_platform_repository_path(@platform, @repository), :class => 'button' -= render :partial => 'proj_list' \ No newline at end of file += render 'proj_list' \ No newline at end of file diff --git a/app/views/projects/_branch_select.html.haml b/app/views/projects/base/_branch_select.html.haml similarity index 100% rename from app/views/projects/_branch_select.html.haml rename to app/views/projects/base/_branch_select.html.haml diff --git a/app/views/projects/_show.html.haml b/app/views/projects/base/_layout.html.haml similarity index 59% rename from app/views/projects/_show.html.haml rename to app/views/projects/base/_layout.html.haml index e9606b920..f21b69b05 100644 --- a/app/views/projects/_show.html.haml +++ b/app/views/projects/base/_layout.html.haml @@ -1,5 +1,5 @@ -= render :partial => 'projects/submenu' -= render :partial => 'projects/repo_block', :locals => {:project => @project} += render 'submenu' += render 'repo_block', :project => @project .description %h3= t("layout.projects.about_subheader") @@ -9,7 +9,7 @@ %h3= t("layout.projects.last_commit") - GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch, :project => @project) do |presenter| - = render :partial => 'shared/feed_message', :locals => {:presenter => presenter, :item_no => 1} + = render 'shared/feed_message', :presenter => presenter, :item_no => 1 .both diff --git a/app/views/projects/_repo_block.html.haml b/app/views/projects/base/_repo_block.html.haml similarity index 82% rename from app/views/projects/_repo_block.html.haml rename to app/views/projects/base/_repo_block.html.haml index 6d0b3ffe0..0870762d5 100644 --- a/app/views/projects/_repo_block.html.haml +++ b/app/views/projects/base/_repo_block.html.haml @@ -6,13 +6,13 @@ =image_tag 'zip.png', :alt => 'ZIP' %b.caret %ul.dropdown-menu - %li=link_to "tar.gz", archive_path(project.id, 'tar', @treeish) - %li=link_to "zip", archive_path(project.id, 'zip', @treeish) + %li=link_to "tar.gz", archive_path(project, 'tar', @treeish) + %li=link_to "zip", archive_path(project, 'zip', @treeish) = text_field_tag :url, git_repo_url(project.git_repo_name), :class => 'name', :spellcheck => 'false', :readonly => true .git_help ? .role= can?(:write, project) ? t("layout.read_write_access") : t("layout.read_access") - = render :partial => 'projects/branch_select', :locals => {:project => project} + = render 'branch_select', :project => project #git_help_data %p= t("layout.projects.git_help.cloning") + ":" %p diff --git a/app/views/projects/_sidebar.html.haml b/app/views/projects/base/_sidebar.html.haml similarity index 100% rename from app/views/projects/_sidebar.html.haml rename to app/views/projects/base/_sidebar.html.haml diff --git a/app/views/projects/_submenu.html.haml b/app/views/projects/base/_submenu.html.haml similarity index 100% rename from app/views/projects/_submenu.html.haml rename to app/views/projects/base/_submenu.html.haml diff --git a/app/views/build_lists/_build_list.html.haml b/app/views/projects/build_lists/_build_list.html.haml similarity index 100% rename from app/views/build_lists/_build_list.html.haml rename to app/views/projects/build_lists/_build_list.html.haml diff --git a/app/views/build_lists/_filter.html.haml b/app/views/projects/build_lists/_filter.html.haml similarity index 100% rename from app/views/build_lists/_filter.html.haml rename to app/views/projects/build_lists/_filter.html.haml diff --git a/app/views/build_lists/_include_repos.html.haml b/app/views/projects/build_lists/_include_repos.html.haml similarity index 100% rename from app/views/build_lists/_include_repos.html.haml rename to app/views/projects/build_lists/_include_repos.html.haml diff --git a/app/views/build_lists/_platform_build_list.html.haml b/app/views/projects/build_lists/_platform_build_list.html.haml similarity index 100% rename from app/views/build_lists/_platform_build_list.html.haml rename to app/views/projects/build_lists/_platform_build_list.html.haml diff --git a/app/views/build_lists/_submenu.html.haml b/app/views/projects/build_lists/_submenu.html.haml similarity index 65% rename from app/views/build_lists/_submenu.html.haml rename to app/views/projects/build_lists/_submenu.html.haml index ec22631d9..50673084d 100644 --- a/app/views/build_lists/_submenu.html.haml +++ b/app/views/projects/build_lists/_submenu.html.haml @@ -7,5 +7,5 @@ .left %nav %ul - %li= link_to t('layout.projects.list_header'), build_lists_path, :class => (params[:controller] == 'build_lists' ? 'active' : nil) - %li= link_to t('layout.products.list_header'), product_build_lists_path, :class => (params[:controller] == 'product_build_lists' ? 'active' : nil) + %li= link_to t('layout.projects.list_header'), build_lists_path, :class => (controller_name == 'build_lists' ? 'active' : nil) + %li= link_to t('layout.products.list_header'), product_build_lists_path, :class => (controller_name == 'product_build_lists' ? 'active' : nil) diff --git a/app/views/build_lists/index.html.haml b/app/views/projects/build_lists/index.html.haml similarity index 78% rename from app/views/build_lists/index.html.haml rename to app/views/projects/build_lists/index.html.haml index 72c1482b9..8642bee90 100644 --- a/app/views/build_lists/index.html.haml +++ b/app/views/projects/build_lists/index.html.haml @@ -11,10 +11,10 @@ %th.lpadding16= t("activerecord.attributes.build_list.user") %th= t("layout.build_lists.action") %th.lpadding16= t("activerecord.attributes.build_list.updated_at") - %tbody= render @build_lists + %tbody= render :partial => 'projects/build_lists/build_list', :collection => @build_lists .both = will_paginate @build_lists -= render 'build_lists/filter' -= render @project ? 'projects/submenu' : 'build_lists/submenu' += render 'filter' += render @project ? 'projects/base/submenu' : 'projects/build_lists/submenu' diff --git a/app/views/build_lists/new.html.haml b/app/views/projects/build_lists/new.html.haml similarity index 98% rename from app/views/build_lists/new.html.haml rename to app/views/projects/build_lists/new.html.haml index cec71e29b..22f38e5cf 100644 --- a/app/views/build_lists/new.html.haml +++ b/app/views/projects/build_lists/new.html.haml @@ -38,4 +38,4 @@ %br = f.submit t("layout.projects.build_button") -= render 'projects/submenu' += render 'projects/base/submenu' diff --git a/app/views/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml similarity index 99% rename from app/views/build_lists/show.html.haml rename to app/views/projects/build_lists/show.html.haml index ebce1bd73..2078803f4 100644 --- a/app/views/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -107,4 +107,4 @@ :javascript $('article .all').addClass('bigpadding'); -= render 'build_lists/submenu' += render 'submenu' diff --git a/app/views/collaborators/_collaborator.json.jbuilder b/app/views/projects/collaborators/_collaborator.json.jbuilder similarity index 100% rename from app/views/collaborators/_collaborator.json.jbuilder rename to app/views/projects/collaborators/_collaborator.json.jbuilder diff --git a/app/views/collaborators/_collaborators.json.jbuilder b/app/views/projects/collaborators/_collaborators.json.jbuilder similarity index 100% rename from app/views/collaborators/_collaborators.json.jbuilder rename to app/views/projects/collaborators/_collaborators.json.jbuilder diff --git a/app/views/collaborators/add.html.haml b/app/views/projects/collaborators/add.html.haml similarity index 100% rename from app/views/collaborators/add.html.haml rename to app/views/projects/collaborators/add.html.haml diff --git a/app/views/collaborators/edit.html.haml b/app/views/projects/collaborators/edit.html.haml similarity index 97% rename from app/views/collaborators/edit.html.haml rename to app/views/projects/collaborators/edit.html.haml index 70f620314..0db3aa7dd 100644 --- a/app/views/collaborators/edit.html.haml +++ b/app/views/projects/collaborators/edit.html.haml @@ -1,6 +1,6 @@ -set_meta_tags :title => [title_object(@project), t('layout.projects.members')] -= render :partial => 'projects/sidebar' -= render :partial => 'projects/submenu' += render 'sidebar' += render 'submenu' %a{:name => 'users'} %h3= t("layout.users.list_header") diff --git a/app/views/collaborators/index.html.haml b/app/views/projects/collaborators/index.html.haml similarity index 83% rename from app/views/collaborators/index.html.haml rename to app/views/projects/collaborators/index.html.haml index 09785b483..7b9a468ae 100644 --- a/app/views/collaborators/index.html.haml +++ b/app/views/projects/collaborators/index.html.haml @@ -1,6 +1,6 @@ -set_meta_tags :title => [title_object(@project), t('layout.projects.members')] -= render :partial => 'projects/sidebar' -= render :partial => 'projects/submenu' += render 'sidebar' += render 'submenu' %a{:name => 'users'} %h3= t("layout.users.list_header") @@ -39,6 +39,6 @@ :javascript $(function() { - Rosa.bootstrapedData.collaborators = #{ render :partial => 'collaborators.json.jbuilder', :locals => {:collaborators => @collaborators } }; + Rosa.bootstrapedData.collaborators = #{ render 'collaborators.json.jbuilder', :collaborators => @collaborators }; r = new Rosa.Routers.CollaboratorsRouter(); }); diff --git a/app/views/collaborators/index.json.jbuilder b/app/views/projects/collaborators/index.json.jbuilder similarity index 100% rename from app/views/collaborators/index.json.jbuilder rename to app/views/projects/collaborators/index.json.jbuilder diff --git a/app/views/comments/_add.html.haml b/app/views/projects/comments/_add.html.haml similarity index 95% rename from app/views/comments/_add.html.haml rename to app/views/projects/comments/_add.html.haml index b31b0be40..e78fe2ac3 100644 --- a/app/views/comments/_add.html.haml +++ b/app/views/projects/comments/_add.html.haml @@ -10,7 +10,7 @@ - subscribe_path = is_subscribed ? unsubscribe_commit_path(project, commentable) : subscribe_commit_path(project, commentable) = form_for :comment, :url => new_path, :method => :post, :html => { :class => :form } do |f| - = render :partial => "comments/form", :locals => {:f => f} + = render "projects/comments/form", :f => f .comment-left = t("layout.comments.notifications_are") %span.bold diff --git a/app/views/comments/_form.html.haml b/app/views/projects/comments/_form.html.haml similarity index 100% rename from app/views/comments/_form.html.haml rename to app/views/projects/comments/_form.html.haml diff --git a/app/views/comments/_list.html.haml b/app/views/projects/comments/_list.html.haml similarity index 70% rename from app/views/comments/_list.html.haml rename to app/views/projects/comments/_list.html.haml index 1ba6b69ad..acbead95f 100644 --- a/app/views/comments/_list.html.haml +++ b/app/views/projects/comments/_list.html.haml @@ -3,4 +3,4 @@ %h3= t("layout.comments.comments_header") - list.each do |comment| - CommentPresenter.present(comment, :project => project, :commentable => commentable) do |presenter| - = render :partial => 'shared/feed_message', :locals => {:presenter => presenter} \ No newline at end of file + = render 'shared/feed_message', :presenter => presenter \ No newline at end of file diff --git a/app/views/comments/edit.html.haml b/app/views/projects/comments/edit.html.haml similarity index 88% rename from app/views/comments/edit.html.haml rename to app/views/projects/comments/edit.html.haml index fff5309ef..a27158367 100644 --- a/app/views/comments/edit.html.haml +++ b/app/views/projects/comments/edit.html.haml @@ -8,4 +8,4 @@ = t("layout.comments.edit_header") .inner = form_for @comment, :url => project_commentable_comment_path(@project, @commentable, @comment), :html => {:class => :form} do |f| - = render :partial => "form", :locals => {:f => f} + = render "form", :f => f diff --git a/app/views/git/shared/_choose_fork.html.haml b/app/views/projects/git/base/_choose_fork.html.haml similarity index 92% rename from app/views/git/shared/_choose_fork.html.haml rename to app/views/projects/git/base/_choose_fork.html.haml index e80785982..8bffb0d33 100644 --- a/app/views/git/shared/_choose_fork.html.haml +++ b/app/views/projects/git/base/_choose_fork.html.haml @@ -2,7 +2,7 @@ - is_group = owner.class == Group ? "(#{t 'activerecord.models.group'})" : '' %p.center =t 'layout.projects.already_exists' - =link_to "#{owner.uname}/#{@project.name} #{is_group}", project_path(owner.projects.by_name(@project.name).first.id) + =link_to "#{owner.uname}/#{@project.name} #{is_group}", project_path(owner.projects.by_name(@project.name).first) - else = form_for @project, :url => fork_project_path(@project), :html => { :class => :form, :multipart => true, :method => :post } do |f| = hidden_field_tag :group, owner.id if owner.class == Group diff --git a/app/views/git/shared/_fork.html.haml b/app/views/projects/git/base/_fork.html.haml similarity index 73% rename from app/views/git/shared/_fork.html.haml rename to app/views/projects/git/base/_fork.html.haml index d982149f9..ccb928bff 100644 --- a/app/views/git/shared/_fork.html.haml +++ b/app/views/projects/git/base/_fork.html.haml @@ -4,8 +4,8 @@ .modal-header %a.close{"data-dismiss" => "modal"} × %h3=t 'layout.projects.fork_modal_header' - .modal-footer=render :partial => 'git/shared/choose_fork', :locals => {:owner => current_user} + .modal-footer=render 'choose_fork', :owner => current_user - Group.can_own_project(current_user).each do |group| - .modal-footer=render :partial => 'git/shared/choose_fork', :locals => {:owner => group} + .modal-footer=render 'choose_fork', :owner => group - if can? :create, @project.build_lists.new .r{:style => "display: block"}= link_to t('layout.projects.new_build_list'), new_project_build_list_path(@project), :class => 'button' diff --git a/app/views/git/shared/_whereami.html.haml b/app/views/projects/git/base/_whereami.html.haml similarity index 100% rename from app/views/git/shared/_whereami.html.haml rename to app/views/projects/git/base/_whereami.html.haml diff --git a/app/views/git/blobs/_blame_table.html.haml b/app/views/projects/git/blobs/_blame_table.html.haml similarity index 100% rename from app/views/git/blobs/_blame_table.html.haml rename to app/views/projects/git/blobs/_blame_table.html.haml diff --git a/app/views/git/blobs/_editor.html.haml b/app/views/projects/git/blobs/_editor.html.haml similarity index 88% rename from app/views/git/blobs/_editor.html.haml rename to app/views/projects/git/blobs/_editor.html.haml index a02d5e229..874945aee 100644 --- a/app/views/git/blobs/_editor.html.haml +++ b/app/views/projects/git/blobs/_editor.html.haml @@ -1,7 +1,7 @@ %h3= t("layout.projects.files_in_project") .files - .l= render :partial => 'git/shared/whereami' - = render :partial => 'git/shared/fork' + .l= render 'whereami' + = render 'fork' .both = form_tag blob_path(@project, @treeish, @path), :name => 'blob-editor', :method => :put do diff --git a/app/views/git/blobs/_show.html.haml b/app/views/projects/git/blobs/_show.html.haml similarity index 92% rename from app/views/git/blobs/_show.html.haml rename to app/views/projects/git/blobs/_show.html.haml index b1bc94d66..f867189fd 100644 --- a/app/views/git/blobs/_show.html.haml +++ b/app/views/projects/git/blobs/_show.html.haml @@ -1,7 +1,7 @@ %h3= t("layout.projects.files_in_project") .files - .l= render :partial => 'git/shared/whereami' - = render :partial => 'git/shared/fork' + .l= render 'whereami' + = render 'fork' .both - render_way = choose_render_way(@blob) diff --git a/app/views/git/blobs/_top.html.haml b/app/views/projects/git/blobs/_top.html.haml similarity index 100% rename from app/views/git/blobs/_top.html.haml rename to app/views/projects/git/blobs/_top.html.haml diff --git a/app/views/git/blobs/blame.html.haml b/app/views/projects/git/blobs/blame.html.haml similarity index 70% rename from app/views/git/blobs/blame.html.haml rename to app/views/projects/git/blobs/blame.html.haml index 11f4fbf01..81fef4b00 100644 --- a/app/views/git/blobs/blame.html.haml +++ b/app/views/projects/git/blobs/blame.html.haml @@ -1,6 +1,6 @@ -set_meta_tags :title => "#{title_object @project} #{t('at') if @branch} #{@branch.try :name}" -= render :partial => 'projects/submenu' -= render :partial => 'projects/repo_block', :locals => {:project => @project} += render 'submenu' += render 'repo_block', :project => @project .description %h3= t("layout.projects.about_subheader") @@ -10,14 +10,14 @@ %h3= t("layout.projects.last_commit") - GitPresenters::CommitAsMessagePresenter.present(@commit, :branch => @branch, :project => @project) do |presenter| - = render :partial => 'shared/feed_message', :locals => {:presenter => presenter, :item_no => 1} + = render 'shared/feed_message', :presenter => presenter, :item_no => 1 .both #repo-wrapper %h3= t("layout.projects.files_in_project") .files - .l= render :partial => 'git/shared/whereami' + .l= render 'whereami' .both - render_way = choose_render_way(@blob) diff --git a/app/views/git/blobs/edit.html.haml b/app/views/projects/git/blobs/edit.html.haml similarity index 67% rename from app/views/git/blobs/edit.html.haml rename to app/views/projects/git/blobs/edit.html.haml index 95904d56d..ac520f0b3 100644 --- a/app/views/git/blobs/edit.html.haml +++ b/app/views/projects/git/blobs/edit.html.haml @@ -1,2 +1,2 @@ -set_meta_tags :title => [title_object(@project), "#{t :title_editing} #{@project.name}/#{@path} #{t('at') if @branch} #{@branch.try :name}"] -= render :partial => "git/blobs/editor", :layout => 'projects/show' += render :partial => "editor", :layout => 'layout' diff --git a/app/views/git/blobs/show.html.haml b/app/views/projects/git/blobs/show.html.haml similarity index 64% rename from app/views/git/blobs/show.html.haml rename to app/views/projects/git/blobs/show.html.haml index b28e87cf5..6b116dccb 100644 --- a/app/views/git/blobs/show.html.haml +++ b/app/views/projects/git/blobs/show.html.haml @@ -1,2 +1,2 @@ -set_meta_tags :title => [title_object(@project), "#{@project.name}/#{@path} #{t('at') if @branch} #{@branch.try :name}"] -= render :partial => "git/blobs/show", :layout => 'projects/show' += render :partial => "show", :layout => 'layout' diff --git a/app/views/git/commits/_commit_diff.html.haml b/app/views/projects/git/commits/_commit_diff.html.haml similarity index 100% rename from app/views/git/commits/_commit_diff.html.haml rename to app/views/projects/git/commits/_commit_diff.html.haml diff --git a/app/views/git/commits/_commits.html.haml b/app/views/projects/git/commits/_commits.html.haml similarity index 82% rename from app/views/git/commits/_commits.html.haml rename to app/views/projects/git/commits/_commits.html.haml index 27aa401d5..9651c7060 100644 --- a/app/views/git/commits/_commits.html.haml +++ b/app/views/projects/git/commits/_commits.html.haml @@ -13,6 +13,6 @@ .messages - commits.each_with_index do |commit| - GitPresenters::CommitAsMessagePresenter.present(commit, :branch => @branch, :project => @project) do |presenter| - = render :partial => 'shared/feed_message', :locals => {:presenter => presenter, :item_no => counter} + = render 'shared/feed_message', :presenter => presenter, :item_no => counter - counter += 1 .both \ No newline at end of file diff --git a/app/views/git/commits/_paginate.html.haml b/app/views/projects/git/commits/_paginate.html.haml similarity index 100% rename from app/views/git/commits/_paginate.html.haml rename to app/views/projects/git/commits/_paginate.html.haml diff --git a/app/views/git/commits/_show.html.haml b/app/views/projects/git/commits/_show.html.haml similarity index 88% rename from app/views/git/commits/_show.html.haml rename to app/views/projects/git/commits/_show.html.haml index 76ab77715..9e6e6a30c 100644 --- a/app/views/git/commits/_show.html.haml +++ b/app/views/projects/git/commits/_show.html.haml @@ -14,6 +14,6 @@ -begin = render_commit_stats(stats) - = render :partial => 'git/commits/commit_diff', :collection => @commit.diffs + = render :partial => 'commit_diff', :collection => @commit.diffs - rescue Grit::Git::GitTimeout %p= t 'layout.git.repositories.commit_diff_too_big' diff --git a/app/views/projects/git/commits/index.html.haml b/app/views/projects/git/commits/index.html.haml new file mode 100644 index 000000000..f3f9cca11 --- /dev/null +++ b/app/views/projects/git/commits/index.html.haml @@ -0,0 +1,6 @@ +-set_meta_tags :title => [title_object(@project), "#{t '.title'} #{t('at') if @branch} #{@branch.try :name}"] += render 'submenu' += render 'repo_block', :project => @project + += render :partial => 'commits', :object => @commits += render 'paginate' if @render_paginate diff --git a/app/views/git/commits/show.html.haml b/app/views/projects/git/commits/show.html.haml similarity index 61% rename from app/views/git/commits/show.html.haml rename to app/views/projects/git/commits/show.html.haml index 9329e7eb0..2fc7f5282 100644 --- a/app/views/git/commits/show.html.haml +++ b/app/views/projects/git/commits/show.html.haml @@ -1,5 +1,5 @@ -set_meta_tags :title => [title_object(@project), shortest_hash_id(@commit.id), @commit.message] -= render :partial => 'projects/submenu' += render 'submenu' .description %h3= t("layout.projects.about_subheader") @@ -14,7 +14,7 @@ .both #repo-wrapper - = render :partial => 'show' + = render 'show' - = render :partial => "comments/list", :locals => {:list => Comment.for_commit(@commit), :project => @project, :commentable => @commit} - = render :partial => "comments/add", :locals => {:project => @project, :commentable => @commit} if current_user + = render "projects/comments/list", :list => Comment.for_commit(@commit), :project => @project, :commentable => @commit + = render "projects/comments/add", :project => @project, :commentable => @commit if current_user diff --git a/app/views/git/trees/_show.html.haml b/app/views/projects/git/trees/_show.html.haml similarity index 90% rename from app/views/git/trees/_show.html.haml rename to app/views/projects/git/trees/_show.html.haml index ccd21be34..2bf2868aa 100644 --- a/app/views/git/trees/_show.html.haml +++ b/app/views/projects/git/trees/_show.html.haml @@ -1,7 +1,7 @@ %h3= t("layout.projects.files_in_project") .files - .l= render :partial => 'git/shared/whereami' - = render :partial => 'git/shared/fork' + .l= render 'whereami' + = render 'fork' .both %table#myTable.tablesorter.project{:cellpadding => "0", :cellspacing => "0"} diff --git a/app/views/git/trees/empty.html.haml b/app/views/projects/git/trees/empty.html.haml similarity index 79% rename from app/views/git/trees/empty.html.haml rename to app/views/projects/git/trees/empty.html.haml index 0bbfb90fa..2f1ff6733 100644 --- a/app/views/git/trees/empty.html.haml +++ b/app/views/projects/git/trees/empty.html.haml @@ -1,6 +1,6 @@ -set_meta_tags :title => title_object(@project) -= render :partial => 'projects/submenu' -= render :partial => 'projects/repo_block', :locals => {:project => @project} += render 'submenu' += render 'repo_block', :project => @project .description %h3= t("layout.projects.about_subheader") @@ -13,7 +13,7 @@ %h3= t("layout.projects.files_in_project") .files - .l= render :partial => 'git/shared/whereami' + .l= render 'whereami' .both %table#myTable.tablesorter.project{:cellpadding => "0", :cellspacing => "0"} diff --git a/app/views/git/trees/show.html.haml b/app/views/projects/git/trees/show.html.haml similarity index 59% rename from app/views/git/trees/show.html.haml rename to app/views/projects/git/trees/show.html.haml index 738e2f39b..f1dccbe2f 100644 --- a/app/views/git/trees/show.html.haml +++ b/app/views/projects/git/trees/show.html.haml @@ -1,2 +1,2 @@ -set_meta_tags :title => "#{title_object @project} #{t('at') if @branch} #{@branch.try :name}" -= render :partial => "git/trees/show", :layout => 'projects/show' += render :partial => "show", :layout => 'layout' diff --git a/app/views/issues/_colors_chooser.html.haml b/app/views/projects/issues/_colors_chooser.html.haml similarity index 100% rename from app/views/issues/_colors_chooser.html.haml rename to app/views/projects/issues/_colors_chooser.html.haml diff --git a/app/views/issues/_form.html.haml b/app/views/projects/issues/_form.html.haml similarity index 100% rename from app/views/issues/_form.html.haml rename to app/views/projects/issues/_form.html.haml diff --git a/app/views/issues/_index_sidebar.html.haml b/app/views/projects/issues/_index_sidebar.html.haml similarity index 97% rename from app/views/issues/_index_sidebar.html.haml rename to app/views/projects/issues/_index_sidebar.html.haml index 8147da126..d1ccfc387 100644 --- a/app/views/issues/_index_sidebar.html.haml +++ b/app/views/projects/issues/_index_sidebar.html.haml @@ -19,4 +19,4 @@ .bordered.nopadding %h3.bmargin10=t('layout.issues.new') = link_to t("layout.add"), new_project_issue_path(@project), :class => 'button' - =render :partial => 'labels' + =render 'labels' diff --git a/app/views/issues/_issue.html.haml b/app/views/projects/issues/_issue.html.haml similarity index 92% rename from app/views/issues/_issue.html.haml rename to app/views/projects/issues/_issue.html.haml index 36cfa22c1..5f0c13ec4 100644 --- a/app/views/issues/_issue.html.haml +++ b/app/views/projects/issues/_issue.html.haml @@ -3,7 +3,7 @@ %span{:style => "display: none;"}=issue.serial_id %td.td1=issue.serial_id %td - %a{:href => project_issue_path(@project.id, issue.serial_id)} + %a{:href => project_issue_path(@project, issue)} %div.issue_title=issue.title .smalltext =issue.created_at.to_s(:long) diff --git a/app/views/issues/_labels.html.haml b/app/views/projects/issues/_labels.html.haml similarity index 94% rename from app/views/issues/_labels.html.haml rename to app/views/projects/issues/_labels.html.haml index bd7536170..81effb206 100644 --- a/app/views/issues/_labels.html.haml +++ b/app/views/projects/issues/_labels.html.haml @@ -26,7 +26,7 @@ .edit_label_form{:style => 'display:none'} =form_tag project_issues_update_label_path(@project, label.id), :id => 'update_label', :method => :post do %input.gray{:name => 'name', :type => "text", :value => label.name} - =render :partial => 'issues/colors_chooser', :locals => {:current_color => label.color} + =render 'colors_chooser', :current_color => label.color .lefter %a{:href => "#custom_color-#{label.name}", :id => "custom_color-#{label.name}", :class => 'custom_color'}=t('layout.issues.label_custom_color') =text_field_tag :color, label.color, :id => 'label_color', :class => 'gray', :style => 'display:none', :maxlength => 6 @@ -36,7 +36,7 @@ =form_tag create_label_project_issues_path(@project), :id => 'new_label', :method => :post do =tracker_search_field(:name, t('layout.issues.new_label')) - =render :partial => 'issues/colors_chooser' + =render 'colors_chooser' .lefter %a{:href => "#custom_color", :id => 'custom_color', :class => 'custom_color'}=t('layout.issues.label_custom_color') =text_field_tag :color, '0054a6', :id => 'label_color', :class => 'gray', :style => 'display:none', :maxlength => 6 diff --git a/app/views/issues/_manage_sidebar.html.haml b/app/views/projects/issues/_manage_sidebar.html.haml similarity index 98% rename from app/views/issues/_manage_sidebar.html.haml rename to app/views/projects/issues/_manage_sidebar.html.haml index 1d0c5a877..7568765e7 100644 --- a/app/views/issues/_manage_sidebar.html.haml +++ b/app/views/projects/issues/_manage_sidebar.html.haml @@ -32,7 +32,7 @@ =form_tag search_collaborators_project_issues_path(@project), :id => 'search_user', :method => :get, :style => @issue.persisted? ? 'display:none' : '' do =tracker_search_field(:search_user, t('layout.issues.search_user')) #manage_issue_users_list - =render 'issues/search_collaborators' + =render 'search_collaborators' =link_to(t('layout.issues.done'), '#', :class => "button tmargin10 update_assignee", :style => 'display:none') if can_manage .block diff --git a/app/views/issues/_search_collaborators.html.haml b/app/views/projects/issues/_search_collaborators.html.haml similarity index 100% rename from app/views/issues/_search_collaborators.html.haml rename to app/views/projects/issues/_search_collaborators.html.haml diff --git a/app/views/issues/_status.html.haml b/app/views/projects/issues/_status.html.haml similarity index 100% rename from app/views/issues/_status.html.haml rename to app/views/projects/issues/_status.html.haml diff --git a/app/views/issues/index.html.haml b/app/views/projects/issues/index.html.haml similarity index 79% rename from app/views/issues/index.html.haml rename to app/views/projects/issues/index.html.haml index 8214fcccd..02c05d53f 100644 --- a/app/views/issues/index.html.haml +++ b/app/views/projects/issues/index.html.haml @@ -1,6 +1,6 @@ -set_meta_tags :title => [title_object(@project), t('.title')] --render :partial => 'projects/submenu' --render :partial => 'issues/index_sidebar' +-render 'submenu' +-render 'index_sidebar' #closed-switcher.blue-switcher =hidden_field_tag :issues_status, @status, :id => 'issues_status' @@ -18,5 +18,5 @@ %th.th1{:colspan => "2"}=t('layout.issues.number') %th{:colspan => "2"}=t('layout.issues.description') %tbody - = render :partial => 'issues/issue', :collection => @issues + = render :partial => 'issue', :collection => @issues = will_paginate @issues \ No newline at end of file diff --git a/app/views/issues/new.html.haml b/app/views/projects/issues/new.html.haml similarity index 63% rename from app/views/issues/new.html.haml rename to app/views/projects/issues/new.html.haml index bac32e3fd..e3c4948e7 100644 --- a/app/views/issues/new.html.haml +++ b/app/views/projects/issues/new.html.haml @@ -1,7 +1,7 @@ -set_meta_tags :title => [title_object(@project), t('layout.issues.create_header')] --render :partial => 'projects/submenu' --render :partial => 'issues/manage_sidebar' +-render 'submenu' +-render 'manage_sidebar' %h3.bpadding10= t("layout.issues.create_header") = form_for :issue, :url => project_issues_path(@project), :html => { :class => 'form issue' } do |f| - = render :partial => "form", :locals => {:f => f} + = render "form", :f => f diff --git a/app/views/issues/show.html.haml b/app/views/projects/issues/show.html.haml similarity index 76% rename from app/views/issues/show.html.haml rename to app/views/projects/issues/show.html.haml index ad678c3ec..141d3cc1a 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/projects/issues/show.html.haml @@ -1,6 +1,6 @@ -set_meta_tags :title => [title_object(@project), @issue.title] --render :partial => 'projects/submenu' --render :partial => 'issues/manage_sidebar' +-render 'submenu' +-render 'manage_sidebar' -content_for :right_nopadding do dummy %h3.issue_title=@issue.title @@ -28,8 +28,8 @@ =f.submit t('layout.update'), :id => 'update_issue_content' =link_to t('layout.issues.cancel_button'), '#', :id => 'cancel_edit_issue_content', :class => 'button' %br -=render :partial => 'issues/status' +=render 'status' -= render :partial => "comments/list", :locals => {:list => @issue.comments, :project => @project, :commentable => @issue} += render "projects/comments/list", :list => @issue.comments, :project => @project, :commentable => @issue %br -= render :partial => "comments/add", :locals => {:project => @project, :commentable => @issue} if current_user += render "projects/comments/add", :project => @project, :commentable => @issue if current_user diff --git a/app/views/projects/_form.html.haml b/app/views/projects/projects/_form.html.haml similarity index 100% rename from app/views/projects/_form.html.haml rename to app/views/projects/projects/_form.html.haml diff --git a/app/views/projects/_project.html.haml b/app/views/projects/projects/_project.html.haml similarity index 100% rename from app/views/projects/_project.html.haml rename to app/views/projects/projects/_project.html.haml diff --git a/app/views/projects/_project.json.jbuilder b/app/views/projects/projects/_project.json.jbuilder similarity index 100% rename from app/views/projects/_project.json.jbuilder rename to app/views/projects/projects/_project.json.jbuilder diff --git a/app/views/projects/edit.html.haml b/app/views/projects/projects/edit.html.haml similarity index 74% rename from app/views/projects/edit.html.haml rename to app/views/projects/projects/edit.html.haml index 6eb287c31..5cdc5af03 100644 --- a/app/views/projects/edit.html.haml +++ b/app/views/projects/projects/edit.html.haml @@ -1,9 +1,9 @@ -set_meta_tags :title => [title_object(@project), t('layout.projects.edit')] -= render :partial => 'projects/submenu' -= render :partial => 'projects/sidebar' += render 'submenu' += render 'sidebar' = form_for @project, :html => { :class => :form, :multipart => true } do |f| - = render :partial => "form", :locals => {:f => f} + = render "form", :f => f .hr .leftside= t("layout.projects.delete_warning") diff --git a/app/views/projects/index.html.haml b/app/views/projects/projects/index.html.haml similarity index 98% rename from app/views/projects/index.html.haml rename to app/views/projects/projects/index.html.haml index 5bc603c90..ed1a4777c 100644 --- a/app/views/projects/index.html.haml +++ b/app/views/projects/projects/index.html.haml @@ -33,7 +33,7 @@ %th{:colspan => 4} - %tbody= render @projects + %tbody= render :partial => 'projects/projects/project', :collection => @projects :javascript $(document).ready(function() { diff --git a/app/views/projects/index.json.jbuilder b/app/views/projects/projects/index.json.jbuilder similarity index 100% rename from app/views/projects/index.json.jbuilder rename to app/views/projects/projects/index.json.jbuilder diff --git a/app/views/projects/new.html.haml b/app/views/projects/projects/new.html.haml similarity index 70% rename from app/views/projects/new.html.haml rename to app/views/projects/projects/new.html.haml index bb5f6cfd6..68a1a0c6f 100644 --- a/app/views/projects/new.html.haml +++ b/app/views/projects/projects/new.html.haml @@ -1,4 +1,4 @@ %h3.bpadding10= title t("layout.projects.new") = form_for @project, :html => { :class => :form, :multipart => true } do |f| - = render :partial => "form", :locals => {:f => f} + = render "form", :f => f diff --git a/app/views/projects/sections.html.haml b/app/views/projects/projects/sections.html.haml similarity index 92% rename from app/views/projects/sections.html.haml rename to app/views/projects/projects/sections.html.haml index dd677970a..6bae42c0f 100644 --- a/app/views/projects/sections.html.haml +++ b/app/views/projects/projects/sections.html.haml @@ -1,6 +1,6 @@ -set_meta_tags :title => [title_object(@project), t('layout.projects.sections')] -= render :partial => 'projects/submenu' -= render :partial => 'projects/sidebar' += render 'submenu' += render 'sidebar' = form_for @project, :url => sections_project_path(@project), :method => :post, :html => { :class => :form, :multipart => true } do |f| .leftside.w25 diff --git a/app/views/wiki/_compare.html.haml b/app/views/projects/wiki/_compare.html.haml similarity index 100% rename from app/views/wiki/_compare.html.haml rename to app/views/projects/wiki/_compare.html.haml diff --git a/app/views/wiki/_diff_data.html.haml b/app/views/projects/wiki/_diff_data.html.haml similarity index 100% rename from app/views/wiki/_diff_data.html.haml rename to app/views/projects/wiki/_diff_data.html.haml diff --git a/app/views/wiki/_editor.html.haml b/app/views/projects/wiki/_editor.html.haml similarity index 100% rename from app/views/wiki/_editor.html.haml rename to app/views/projects/wiki/_editor.html.haml diff --git a/app/views/wiki/_editor_toolbar.html.haml b/app/views/projects/wiki/_editor_toolbar.html.haml similarity index 100% rename from app/views/wiki/_editor_toolbar.html.haml rename to app/views/projects/wiki/_editor_toolbar.html.haml diff --git a/app/views/wiki/_git_access.html.haml b/app/views/projects/wiki/_git_access.html.haml similarity index 100% rename from app/views/wiki/_git_access.html.haml rename to app/views/projects/wiki/_git_access.html.haml diff --git a/app/views/wiki/_git_access_message.en.html.haml b/app/views/projects/wiki/_git_access_message.en.html.haml similarity index 100% rename from app/views/wiki/_git_access_message.en.html.haml rename to app/views/projects/wiki/_git_access_message.en.html.haml diff --git a/app/views/wiki/_git_access_message.ru.html.haml b/app/views/projects/wiki/_git_access_message.ru.html.haml similarity index 100% rename from app/views/wiki/_git_access_message.ru.html.haml rename to app/views/projects/wiki/_git_access_message.ru.html.haml diff --git a/app/views/wiki/_gollum_includes.html.haml b/app/views/projects/wiki/_gollum_includes.html.haml similarity index 100% rename from app/views/wiki/_gollum_includes.html.haml rename to app/views/projects/wiki/_gollum_includes.html.haml diff --git a/app/views/wiki/_history.html.haml b/app/views/projects/wiki/_history.html.haml similarity index 100% rename from app/views/wiki/_history.html.haml rename to app/views/projects/wiki/_history.html.haml diff --git a/app/views/wiki/_navigation.html.haml b/app/views/projects/wiki/_navigation.html.haml similarity index 100% rename from app/views/wiki/_navigation.html.haml rename to app/views/projects/wiki/_navigation.html.haml diff --git a/app/views/wiki/_page.html.haml b/app/views/projects/wiki/_page.html.haml similarity index 100% rename from app/views/wiki/_page.html.haml rename to app/views/projects/wiki/_page.html.haml diff --git a/app/views/wiki/_results.html.haml b/app/views/projects/wiki/_results.html.haml similarity index 100% rename from app/views/wiki/_results.html.haml rename to app/views/projects/wiki/_results.html.haml diff --git a/app/views/wiki/_searchbar.html.haml b/app/views/projects/wiki/_searchbar.html.haml similarity index 100% rename from app/views/wiki/_searchbar.html.haml rename to app/views/projects/wiki/_searchbar.html.haml diff --git a/app/views/wiki/_sidebar.html.haml b/app/views/projects/wiki/_sidebar.html.haml similarity index 100% rename from app/views/wiki/_sidebar.html.haml rename to app/views/projects/wiki/_sidebar.html.haml diff --git a/app/views/wiki/compare.html.haml b/app/views/projects/wiki/compare.html.haml similarity index 94% rename from app/views/wiki/compare.html.haml rename to app/views/projects/wiki/compare.html.haml index 8a6b851ad..7ca80e462 100644 --- a/app/views/wiki/compare.html.haml +++ b/app/views/projects/wiki/compare.html.haml @@ -1,7 +1,7 @@ -set_meta_tags :title => [title_object(@project), t('.title')] = render 'gollum_includes' / = render 'project_short' -= render 'projects/submenu' += render 'submenu' %h3.wiki - if @name diff --git a/app/views/wiki/edit.html.haml b/app/views/projects/wiki/edit.html.haml similarity index 96% rename from app/views/wiki/edit.html.haml rename to app/views/projects/wiki/edit.html.haml index 29bbb6993..a82ee519a 100644 --- a/app/views/wiki/edit.html.haml +++ b/app/views/projects/wiki/edit.html.haml @@ -1,7 +1,7 @@ -set_meta_tags :title => [title_object(@project), "#{t('wiki.editing_page')} #{@page.name}"] = render 'gollum_includes' / = render 'project_short' -= render 'projects/submenu' += render 'submenu' .left %h3 = t("wiki.editing_page") diff --git a/app/views/wiki/git.html.haml b/app/views/projects/wiki/git.html.haml similarity index 91% rename from app/views/wiki/git.html.haml rename to app/views/projects/wiki/git.html.haml index a69968070..2cfc33ad2 100644 --- a/app/views/wiki/git.html.haml +++ b/app/views/projects/wiki/git.html.haml @@ -1,7 +1,7 @@ -set_meta_tags :title => [title_object(@project), t('wiki.git_access')] / = render 'gollum_includes' / = render 'project_short' -= render 'projects/submenu' += render 'submenu' .desription-top .img= image_tag("code.png") diff --git a/app/views/wiki/history.html.haml b/app/views/projects/wiki/history.html.haml similarity index 92% rename from app/views/wiki/history.html.haml rename to app/views/projects/wiki/history.html.haml index 591d4602a..25e517594 100644 --- a/app/views/wiki/history.html.haml +++ b/app/views/projects/wiki/history.html.haml @@ -1,7 +1,7 @@ -set_meta_tags :title => [title_object(@project), t('wiki.wiki_history')] / = render 'gollum_includes' / = render 'project_short' -= render 'projects/submenu' += render 'submenu' .r= link_to t("wiki.compare_revisions"), "javascript:void(0);", :class => "action-compare-revision button width100" .both diff --git a/app/views/wiki/new.html.haml b/app/views/projects/wiki/new.html.haml similarity index 92% rename from app/views/wiki/new.html.haml rename to app/views/projects/wiki/new.html.haml index bf7bba762..a64ef7ef7 100644 --- a/app/views/wiki/new.html.haml +++ b/app/views/projects/wiki/new.html.haml @@ -1,6 +1,6 @@ = render 'gollum_includes' / = render 'project_short' -= render 'projects/submenu' += render 'submenu' %h3.wiki = t("wiki.create_page") diff --git a/app/views/wiki/pages.html.haml b/app/views/projects/wiki/pages.html.haml similarity index 92% rename from app/views/wiki/pages.html.haml rename to app/views/projects/wiki/pages.html.haml index bcf7d5ffd..fff37180c 100644 --- a/app/views/wiki/pages.html.haml +++ b/app/views/projects/wiki/pages.html.haml @@ -1,7 +1,7 @@ -set_meta_tags :title => [title_object(@project), t('wiki.pages')] / = render 'gollum_includes' / = render 'project_short' -= render 'projects/submenu' += render 'submenu' - if can? :write, @project .r= link_to t("wiki.new_page"), '#', :'data-url' => project_wiki_index_path(@project), :id => 'minibutton-new-page', :class => 'button width100' diff --git a/app/views/wiki/search.html.haml b/app/views/projects/wiki/search.html.haml similarity index 94% rename from app/views/wiki/search.html.haml rename to app/views/projects/wiki/search.html.haml index 7d59ae2a6..8a34a77ee 100644 --- a/app/views/wiki/search.html.haml +++ b/app/views/projects/wiki/search.html.haml @@ -1,7 +1,7 @@ -set_meta_tags :title => [title_object(@project), @query, t('wiki.searching.title')] / = render 'gollum_includes' / = render 'project_short' -= render 'projects/submenu' += render 'submenu' - @st_query = capture do %strong= @query diff --git a/app/views/wiki/show.html.haml b/app/views/projects/wiki/show.html.haml similarity index 96% rename from app/views/wiki/show.html.haml rename to app/views/projects/wiki/show.html.haml index 071d2014f..cff28ba8d 100644 --- a/app/views/wiki/show.html.haml +++ b/app/views/projects/wiki/show.html.haml @@ -1,7 +1,7 @@ -set_meta_tags :title => [title_object(@project), @page.name] / = render 'gollum_includes' / = render 'project_short' -= render 'projects/submenu' += render 'submenu' .left %h3 = @page.name diff --git a/app/views/register_requests/index.html.haml b/app/views/register_requests/index.html.haml deleted file mode 100644 index 527f40f59..000000000 --- a/app/views/register_requests/index.html.haml +++ /dev/null @@ -1,65 +0,0 @@ -.block - .secondary-navigation - %ul.wat-cf - %li.first= link_to t("layout.users.list"), users_path - %li= link_to t("layout.users.new"), new_user_path - %li.active= link_to t("layout.users.register_requests"), register_requests_path - .content - %div{:style => 'float: right; margin: 20px'} - = link_to t("layout.register_request.approved"), register_requests_path(:scope => :approved) - \| - = link_to t("layout.register_request.rejected"), register_requests_path(:scope => :rejected) - %h2.title - = title t("layout.register_request.list_header") - .inner - = form_tag register_requests_path, :method => :put, :class => 'update_form' do - = hidden_field_tag 'update_type' - %table.table - %tr - %th   - %th= t("activerecord.attributes.register_request.name") - %th= t("activerecord.attributes.register_request.email") - %th= t("activerecord.attributes.register_request.interest") - %th= t("activerecord.attributes.register_request.more") - %th= t("activerecord.attributes.register_request.created_at") - %th - - @register_requests.each do |request| - %tr{:class => cycle("odd", "even")} - %td= check_box_tag 'request_ids[]', request.id - %td= request.name - - @user = User.find_by_email(request.email) if request.approved - %td= link_to_if @user, request.email, @user - %td= request.interest - %td= request.more - %td= request.created_at - %td - = link_to t("layout.approve"), register_request_approve_path(request) if can? :approve, request - | - = link_to t("layout.reject"), register_request_reject_path(request) if can? :reject, request - .actions-bar.wat-cf - .actions - - - =# button_tag t("layout.register_request.approve_selected"), :class => 'approve_registration' - =# button_tag t("layout.register_request.reject_selected"), :class => 'reject_registration' - .pagination - = will_paginate @register_requests -:javascript - $(function() { - var $form = $('form.update_form') - var change_update_type = function (type) { - $('input#update_type').val(type); - }; - $('#approve_registration').live('click', function(e) { - //set update_type to 'approve' - change_update_type('approve'); - $form.submit(); - }); - $('#reject_registration').live('click', function(e) { - //set update_type to 'reject' - change_update_type('reject'); - $form.submit(); - }); - }); - -= render 'admin/submenu' diff --git a/app/views/repositories/_proj_list1.html.haml b/app/views/repositories/_proj_list1.html.haml deleted file mode 100644 index 0033945f2..000000000 --- a/app/views/repositories/_proj_list1.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -%table#myTable.tablesorter.repo-projects{:cellpadding => "0", :cellspacing => "0"} - %thead - %tr - %th.th1= t("activerecord.attributes.project.name") - %th.th2= t("activerecord.attributes.project.description") - %th.th3= t("layout.remove") - %tbody= render :partial => 'repositories/project', :collection => @projects - --#%table.tablesorter - %tr - %th.first= t("activerecord.attributes.project.name") - %th. - %th.last   - - @projects.each do |project| - %tr{:class => cycle("odd", "even")} - %td - = link_to project.name, project_path(project) - %td.last - = link_to t("layout.show"), project_path(project) - \| - = link_to t("layout.delete"), url_for(:action => :remove_project, :project_id => project.id), :confirm => t("layout.projects.confirm_delete") diff --git a/app/views/repositories/_sidebar.html.haml b/app/views/repositories/_sidebar.html.haml deleted file mode 100644 index d4101628f..000000000 --- a/app/views/repositories/_sidebar.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -.block.notice - %h3= t("layout.platforms.current_platform_header") - .content - / %p= link_to @platform.name, platform_path(@platform) \ No newline at end of file diff --git a/app/views/repositories/index.html.haml b/app/views/repositories/index.html.haml deleted file mode 100644 index 34f5450c5..000000000 --- a/app/views/repositories/index.html.haml +++ /dev/null @@ -1,20 +0,0 @@ --set_meta_tags :title => [title_object(@platform), t('layout.repositories.list_header')] -= render :partial => 'platforms/submenu' if params[:platform_id] -= render :partial => 'platforms/sidebar' if params[:platform_id] -= link_to t("layout.repositories.new"), new_platform_repository_path(@platform), :class => 'button' if can? :create, @platform.repositories.build -= render :partial => 'list', :object => @repositories -= will_paginate @repositories --#.block - .secondary-navigation - %ul.wat-cf - %li.first.active= link_to t("layout.repositories.list"), repositories_path - %li= link_to t("layout.repositories.new"), new_repository_path if can? :create, Platform # TODO repo without platform?? - .content - %h2.title - = t("layout.repositories.list_header") - .inner - = render :partial => 'shared/search_form' - = render :partial => 'list', :object => @repositories - .actions-bar.wat-cf - .actions - = will_paginate @repositories, :param_name => :repository_page diff --git a/app/views/repositories/projects_list.html.haml b/app/views/repositories/projects_list.html.haml deleted file mode 100644 index 2aa8f7170..000000000 --- a/app/views/repositories/projects_list.html.haml +++ /dev/null @@ -1,6 +0,0 @@ -= render :partial => 'platforms/submenu' -= render :partial => 'platforms/sidebar' - -%h3= raw "#{t("layout.repositories.add_project_to")}: #{link_to @repository.name, platform_repository_path(@platform, @repository)}" - -= render :partial => 'proj_list', :object => @projects diff --git a/app/views/settings/notifiers/_form.html.haml b/app/views/settings/notifiers/_form.html.haml deleted file mode 100644 index 0aacc04da..000000000 --- a/app/views/settings/notifiers/_form.html.haml +++ /dev/null @@ -1,52 +0,0 @@ -.leftside.w25 - = f.check_box :can_notify -.leftside - = f.label :can_notify, t('activerecord.attributes.settings.notifier.can_notify') -.both -%h3= t("layout.settings.notifiers.code_header") -.leftside.w25 - = f.check_box :new_comment_commit_owner, :class => 'notify_cbx' -.leftside - = f.label :new_comment_commit_owner, t('activerecord.attributes.settings.notifier.new_comment_commit_owner') -.both -.leftside.w25 - = f.check_box :new_comment_commit_repo_owner, :class => 'notify_cbx' -.leftside - = f.label :new_comment_commit_repo_owner, t('activerecord.attributes.settings.notifier.new_comment_commit_repo_owner') -.both -.leftside.w25 - = f.check_box :new_comment_commit_commentor, :class => 'notify_cbx' -.leftside - = f.label :new_comment_commit_commentor, t('activerecord.attributes.settings.notifier.new_comment_commit_commentor') -.both -%h3= t("layout.settings.notifiers.tracker_header") -.leftside.w25 - = f.check_box :new_comment, :class => 'notify_cbx' -.leftside - = f.label :new_comment, t('activerecord.attributes.settings.notifier.new_comment') -.both -.leftside.w25 - = f.check_box :new_comment_reply, :class => 'notify_cbx' -.leftside - = f.label :new_comment_reply, t('activerecord.attributes.settings.notifier.new_comment_reply') -.both -.leftside.w25 - = f.check_box :new_issue, :class => 'notify_cbx' -.leftside - = f.label :new_issue, t('activerecord.attributes.settings.notifier.new_issue') -.both -.leftside.w25 - = f.check_box :issue_assign, :class => 'notify_cbx' -.leftside - = f.label :issue_assign, t('activerecord.attributes.settings.notifier.issue_assign') -.both - -%br -.leftside.w25 - \  -.leftside.w420 - = submit_tag t("layout.save") -.both - -:javascript - disableNotifierCbx($('#settings_notifier_can_notify')); diff --git a/app/views/settings/notifiers/show.html.haml b/app/views/settings/notifiers/show.html.haml deleted file mode 100644 index 6665aaa51..000000000 --- a/app/views/settings/notifiers/show.html.haml +++ /dev/null @@ -1,21 +0,0 @@ --set_meta_tags :title => t('layout.users.settings_notifier') -%p - = t("layout.settings.notifiers.notice_header", :email => @user.email) - %br - = link_to t("layout.settings.notifiers.change_email_link"), edit_user_path(@user) - %br - %br/ - -= form_for @notifier, :url => user_settings_notifier_path(@user), :html => { :class => :form } do |f| - = render :partial => "form", :locals => {:f => f} - -:javascript - $('article .right').addClass('bigpadding'); - -- content_for :sidebar, render('users/sidebar') - --##block-signup.block --# %h2= title t("layout.settings.notifiers.edit_header") --# .content --# = form_for @notifier, :url => user_settings_notifier_path(@user), :html => { :class => :form } do |f| --# = render :partial => "form", :locals => {:f => f} diff --git a/app/views/users/_filter.html.haml b/app/views/users/_filter.html.haml deleted file mode 100644 index eb1ebd9e2..000000000 --- a/app/views/users/_filter.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -%h2.title= t("layout.users.filter_header") - -= form_for :filter, :url => @action_url, :html => { :method => :get, :class => :form } do |f| - .columns.wat-cf - .column.left - .group - = f.label :status, t("activerecord.attributes.users.email"), :class => :label - = f.text_field :email, :class => :text_field, :value => @email - - .group.navform.wat-cf - %button.button{ :type => "submit" } - = image_tag("choose.png", :alt => "Save") - = t("layout.search.header") - diff --git a/app/views/users/_form.html.haml b/app/views/users/_form.html.haml deleted file mode 100644 index 39fa3ffd8..000000000 --- a/app/views/users/_form.html.haml +++ /dev/null @@ -1,73 +0,0 @@ -- if current_user.admin? - .leftlist - = f.label :role, t("activerecord.attributes.user.role"), :class => :label - .rightlist - = f.select :role, User::ROLES, {}, {:name => 'role'} - - if @user.new_record? - .leftlist - = f.label :uname, t("activerecord.attributes.user.uname") - .rightlist - = f.text_field :uname - .leftlist - = f.label :password, t("activerecord.attributes.user.password") - .rightlist - = f.password_field :password - .both - .leftlist - = f.label :password_confirmation, t("activerecord.attributes.user.password_confirm") - .rightlist - = f.password_field :password_confirmation - .both -.leftlist - = f.label :name, t("activerecord.attributes.user.name") -.rightlist - = f.text_field :name -.both -.leftlist - = f.label :email, t("activerecord.attributes.user.email") -.rightlist - = f.text_field :email -.both -.leftlist - = f.label :site, t("activerecord.attributes.user.site") -.rightlist - = f.text_field :site -.both -.leftlist - = f.label :language, t("activerecord.attributes.user.language") -.rightlist - = f.select :language, User::LANGUAGES_FOR_SELECT -.both -.leftlist - = f.label :company, t("activerecord.attributes.user.company") -.rightlist - = f.text_field :company -.both -.leftlist - = f.label :location, t("activerecord.attributes.user.location") -.rightlist - = f.text_field :location -.both -.leftlist - = f.label :avatar, t("layout.users.avatar_with_size", :max => number_to_human_size(User::MAX_AVATAR_SIZE)) -.rightlist - = image_tag(avatar_url(@user, :medium)) -.leftlist -.rightlist - .check - %span#niceCheckbox1.niceCheck-main - = check_box_tag "delete_avatar", 1, false, :class => 'niceCheckbox1' - .forcheck= t('layout.users.delete_avatar') - .both - = f.file_field :avatar -.both -.leftlist - = f.label :professional_experience, t("activerecord.attributes.user.professional_experience") -.rightlist - = f.text_area :professional_experience -.both -.leftlist - \  -.rightlist - = submit_tag t("layout.save") -.both diff --git a/app/views/users/_sidebar.html.haml b/app/views/users/_sidebar.html.haml deleted file mode 100644 index 9b8259f79..000000000 --- a/app/views/users/_sidebar.html.haml +++ /dev/null @@ -1,15 +0,0 @@ -- act = action_name.to_sym -- contr = controller_name.to_sym - -%aside - .admin-preferences - %ul - - if can? :edit, @user - %li{:class => (act == :profile && :users == contr) ? 'active' : ''} - = link_to t("layout.users.profile"), @user == current_user ? edit_profile_path : edit_user_path(@user) - - if can? :private, @user - %li{:class => (act == :private && contr == :users) ? 'active' : ''} - = link_to t("layout.users.user_private_settings"), user_private_settings_path(@user) - - if can? :show, @user.notifier - %li{:class => (act == :show && contr == :notifiers) ? 'active' : ''} - = link_to t("layout.users.settings_notifier"), user_settings_notifier_path(@user) diff --git a/app/views/users/base/_form.html.haml b/app/views/users/base/_form.html.haml new file mode 100644 index 000000000..d88807a92 --- /dev/null +++ b/app/views/users/base/_form.html.haml @@ -0,0 +1,47 @@ +- if current_user.admin? + .leftlist= f.label :role, t("activerecord.attributes.user.role"), :class => :label + .rightlist= f.select :role, User::ROLES, {}, {:name => 'role'} + - if @user.new_record? + .leftlist= f.label :uname, t("activerecord.attributes.user.uname") + .rightlist= f.text_field :uname + .leftlist= f.label :password, t("activerecord.attributes.user.password") + .rightlist= f.password_field :password + .both + .leftlist= f.label :password_confirmation, t("activerecord.attributes.user.password_confirm") + .rightlist= f.password_field :password_confirmation + .both +.leftlist= f.label :name, t("activerecord.attributes.user.name") +.rightlist= f.text_field :name +.both +.leftlist= f.label :email, t("activerecord.attributes.user.email") +.rightlist= f.text_field :email +.both +.leftlist= f.label :site, t("activerecord.attributes.user.site") +.rightlist= f.text_field :site +.both +.leftlist= f.label :language, t("activerecord.attributes.user.language") +.rightlist= f.select :language, User::LANGUAGES_FOR_SELECT +.both +.leftlist= f.label :company, t("activerecord.attributes.user.company") +.rightlist= f.text_field :company +.both +.leftlist= f.label :location, t("activerecord.attributes.user.location") +.rightlist= f.text_field :location +.both +.leftlist= f.label :avatar, t("layout.users.avatar_with_size", :max => number_to_human_size(User::MAX_AVATAR_SIZE)) +.rightlist= image_tag(avatar_url(@user, :medium)) +.leftlist +.rightlist + .check + %span#niceCheckbox1.niceCheck-main= check_box_tag "delete_avatar", 1, false, :class => 'niceCheckbox1' + .forcheck= t('layout.users.delete_avatar') + .both + = f.file_field :avatar +.both +.leftlist= f.label :professional_experience, t("activerecord.attributes.user.professional_experience") +.rightlist= f.text_area :professional_experience +.both +.leftlist + \  +.rightlist= submit_tag t("layout.save") +.both diff --git a/app/views/users/base/_sidebar.html.haml b/app/views/users/base/_sidebar.html.haml new file mode 100644 index 000000000..6c387a487 --- /dev/null +++ b/app/views/users/base/_sidebar.html.haml @@ -0,0 +1,6 @@ +%aside + .admin-preferences + %ul + %li{:class => action_name == 'profile' ? 'active' : nil}= link_to t("layout.users.profile"), profile_settings_path + %li{:class => action_name == 'private' ? 'active' : nil}= link_to t("layout.users.user_private_settings"), private_settings_path + %li{:class => action_name == 'notifiers' ? 'active' : nil}= link_to t("layout.users.settings_notifier"), notifiers_settings_path \ No newline at end of file diff --git a/app/views/users/private.html.haml b/app/views/users/private.html.haml deleted file mode 100644 index c9f76eec9..000000000 --- a/app/views/users/private.html.haml +++ /dev/null @@ -1,29 +0,0 @@ --set_meta_tags :title => t('layout.users.settings') -%h3.fix.bpadding10= t('layout.users.private_settings_header') - -= form_for(@user, :url => user_private_settings_path(@user), :html => { :method => :put, :class => "form" }) do |f| - .leftlist - = f.label :current_password - .rightlist - = f.password_field :current_password - .both - .leftlist - = f.label :password - .rightlist - = f.password_field :password - .both - .leftlist - = f.label :password_confirmation - .rightlist - = f.password_field :password_confirmation - .both - .leftlist - \  - .rightlist - = submit_tag t('layout.save') - .both - -:javascript - $('article .right').addClass('middlepadding'); - -- content_for :sidebar, render('users/sidebar') diff --git a/app/views/users/show.html.haml b/app/views/users/profile/show.html.haml similarity index 78% rename from app/views/users/show.html.haml rename to app/views/users/profile/show.html.haml index e5516d657..bc6167a0c 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/profile/show.html.haml @@ -1,12 +1,12 @@ .left = image_tag avatar_url(@user, :big) %br - = link_to t("layout.users.settings"), current_user == @user ? edit_profile_path : edit_user_path(@user), :class => 'button width81' if can? :edit, @user + = link_to t("layout.users.settings"), current_user == @user ? profile_settings_path : edit_admin_user_path(@user), :class => 'button width81' if can? :edit, @user .left %h3= title @user.uname = @user.name %br - = link_to @user.email, "mailto:#{ @user.email }" + = link_to @user.email, "mailto:#{@user.email}" %br %h4= t("activerecord.attributes.user.professional_experience") + ":" %p= @user.professional_experience diff --git a/app/views/register_requests/new.html.haml b/app/views/users/register_requests/new.html.haml similarity index 51% rename from app/views/register_requests/new.html.haml rename to app/views/users/register_requests/new.html.haml index 5ff201c35..d69448ed3 100644 --- a/app/views/register_requests/new.html.haml +++ b/app/views/users/register_requests/new.html.haml @@ -8,17 +8,12 @@ %p= value - form_for(@register_request, :html => { :class => "form login" }) do |f| .group.wat-cf - .left - = f.label :name, :class => "label right" - .right - = f.text_field :name, :class => "text_field" + .left= f.label :name, :class => "label right" + .right= f.text_field :name, :class => "text_field" .group.wat-cf - .left - = f.label :email, :class => "label right" - .right - = f.text_field :email, :class => "text_field" + .left= f.label :email, :class => "label right" + .right= f.text_field :email, :class => "text_field" .group.navform.wat-cf .right - %button.button{ :type => "submit" } - = t("layout.register_request.get_token_button") - %span.text_button_padding + %button.button{:type => "submit"}= t("layout.register_request.get_token_button") + %span.text_button_padding \ No newline at end of file diff --git a/app/views/users/settings/notifiers.html.haml b/app/views/users/settings/notifiers.html.haml new file mode 100644 index 000000000..2d206c2aa --- /dev/null +++ b/app/views/users/settings/notifiers.html.haml @@ -0,0 +1,47 @@ +-set_meta_tags :title => t('layout.users.settings_notifier') +%p + = t("layout.settings.notifiers.notice_header", :email => @user.email) + %br + = link_to t("layout.settings.notifiers.change_email_link"), profile_settings_path + %br + %br + += form_for @user.notifier, :url => notifiers_settings_path, :html => {:class => :form} do |f| + .leftside.w25= f.check_box :can_notify + .leftside= f.label :can_notify, t('activerecord.attributes.settings.notifier.can_notify') + .both + %h3= t("layout.settings.notifiers.code_header") + .leftside.w25= f.check_box :new_comment_commit_owner, :class => 'notify_cbx' + .leftside= f.label :new_comment_commit_owner, t('activerecord.attributes.settings.notifier.new_comment_commit_owner') + .both + .leftside.w25= f.check_box :new_comment_commit_repo_owner, :class => 'notify_cbx' + .leftside= f.label :new_comment_commit_repo_owner, t('activerecord.attributes.settings.notifier.new_comment_commit_repo_owner') + .both + .leftside.w25= f.check_box :new_comment_commit_commentor, :class => 'notify_cbx' + .leftside= f.label :new_comment_commit_commentor, t('activerecord.attributes.settings.notifier.new_comment_commit_commentor') + .both + %h3= t("layout.settings.notifiers.tracker_header") + .leftside.w25= f.check_box :new_comment, :class => 'notify_cbx' + .leftside= f.label :new_comment, t('activerecord.attributes.settings.notifier.new_comment') + .both + .leftside.w25= f.check_box :new_comment_reply, :class => 'notify_cbx' + .leftside= f.label :new_comment_reply, t('activerecord.attributes.settings.notifier.new_comment_reply') + .both + .leftside.w25= f.check_box :new_issue, :class => 'notify_cbx' + .leftside= f.label :new_issue, t('activerecord.attributes.settings.notifier.new_issue') + .both + .leftside.w25= f.check_box :issue_assign, :class => 'notify_cbx' + .leftside= f.label :issue_assign, t('activerecord.attributes.settings.notifier.issue_assign') + .both + + %br + .leftside.w25 + \  + .leftside.w420= submit_tag t("layout.save") + .both + +:javascript + disableNotifierCbx($('#settings_notifier_can_notify')); + $('article .right').addClass('bigpadding'); + +- content_for :sidebar, render('sidebar') diff --git a/app/views/users/settings/private.html.haml b/app/views/users/settings/private.html.haml new file mode 100644 index 000000000..3553c4d44 --- /dev/null +++ b/app/views/users/settings/private.html.haml @@ -0,0 +1,22 @@ +-set_meta_tags :title => t('layout.users.settings') +%h3.fix.bpadding10= t('layout.users.private_settings_header') + += form_for @user, :url => private_settings_path, :html => {:class => :form} do |f| + .leftlist= f.label :current_password + .rightlist= f.password_field :current_password + .both + .leftlist= f.label :password + .rightlist= f.password_field :password + .both + .leftlist= f.label :password_confirmation + .rightlist= f.password_field :password_confirmation + .both + .leftlist + \  + .rightlist= submit_tag t('layout.save') + .both + +:javascript + $('article .right').addClass('middlepadding'); + +- content_for :sidebar, render('sidebar') diff --git a/app/views/users/profile.html.haml b/app/views/users/settings/profile.html.haml similarity index 66% rename from app/views/users/profile.html.haml rename to app/views/users/settings/profile.html.haml index f77da522c..bcf053457 100644 --- a/app/views/users/profile.html.haml +++ b/app/views/users/settings/profile.html.haml @@ -1,8 +1,8 @@ -set_meta_tags :title => t('.title') %h3.fix.bpadding10= @user.uname -= form_for @user, :url => user_path(@user), :html => { :class => :form } do |f| - = render :partial => "users/form", :locals => {:f => f} += form_for @user, :url => profile_settings_path, :html => {:class => :form} do |f| + = render 'form', :f => f .notify %p= t('layout.users.public_data_edit_warning') diff --git a/bin/autostart.sh b/bin/autostart.sh index c65917012..02a018aef 100755 --- a/bin/autostart.sh +++ b/bin/autostart.sh @@ -1,8 +1,8 @@ #!/bin/bash -for f in `ls /srv` -do - su -l rosa -c "cd /srv/$f/current && APP_NAME=$f bundle exec bluepill --no-privileged load /srv/$f/current/config/production.pill" -done +# for f in `ls /srv` +# do +# su -l rosa -c "cd /srv/$f/current && APP_NAME=$f bundle exec bluepill --no-privileged load /srv/$f/current/config/production.pill" +# done /srv/rosa_build/current/bin/mount_downloads.sh diff --git a/config/deploy.rb b/config/deploy.rb index 74734e310..ac5e272f1 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,7 +1,6 @@ # -*- encoding : utf-8 -*- -$:.unshift File.expand_path('.') -$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) -set :rvm_type, :user +require 'cape' +require 'capistrano_colors' set :default_environment, { 'LANG' => 'en_US.UTF-8' @@ -34,10 +33,10 @@ set :scm, :git set :repository, "git@github.com:warpc/rosa-build.git" set :deploy_via, :remote_cache -require 'lib/recipes/nginx' -require 'lib/recipes/unicorn' -require 'lib/recipes/bluepill' -require 'lib/recipes/delayed_job' +require './lib/recipes/nginx' +require './lib/recipes/unicorn' +require './lib/recipes/bluepill' +require './lib/recipes/delayed_job' namespace :deploy do task :stub_xml_rpc do @@ -92,7 +91,6 @@ after "deploy:restart", "delayed_job:restart" after "deploy:restart", "deploy:cleanup" -require 'cape' namespace :rake_tasks do Cape do mirror_rake_tasks 'db:seeds' diff --git a/config/locales/menu.en.yml b/config/locales/menu.en.yml index f3bae9b88..6af41623b 100644 --- a/config/locales/menu.en.yml +++ b/config/locales/menu.en.yml @@ -37,4 +37,3 @@ en: users: Users register_requests: Invites event_logs: Event log - diff --git a/config/routes.rb b/config/routes.rb index e3acc0658..ef2bcb97e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,181 +1,16 @@ # -*- encoding : utf-8 -*- Rosa::Application.routes.draw do - devise_scope :user do + devise_scope :users do get '/users/auth/:provider' => 'users/omniauth_callbacks#passthru' - get '/user' => 'users#profile', :as => :edit_profile - put '/user' => 'users#update', :as => :update_profile - get '/users' => 'admin/users#index', :as => :users - get '/users/new' => 'admin/users#new', :as => :new_user - get '/users/list' => 'admin/users#list', :as => :users_list - post '/users/create' => 'admin/users#create', :as => :create_user - constraints :id => /\d+/ do - get '/users/:id/edit' => 'admin/users#profile', :as => :edit_user - put '/users/:id/edit' => 'admin/users#update', :as => :update_user - delete '/users/:id/delete' => 'admin/users#destroy', :as => :delete_user - end end devise_for :users, :controllers => {:omniauth_callbacks => 'users/omniauth_callbacks'} - resources :users, :only => [:show, :profile, :update] do - collection do - resources :register_requests, :only => [:index, :new, :create, :show_message, :approve, :reject] do - get :show_message, :on => :collection - put :update, :on => :collection - get :approve - get :reject - end - get :autocomplete_user_uname - end - namespace :settings do - resource :notifier, :only => [:show, :update] - end - end - get 'users/:id/settings/private' => 'users#private', :as => :user_private_settings - put 'users/:id/settings/private' => 'users#private' - - resources :groups do - get :autocomplete_group_uname, :on => :collection - resources :members, :only => [:index, :edit, :update, :add] do - collection do - get :edit - post :add - post :update - delete :remove - end - member do - post :update - delete :remove - end - end - end - - resources :platforms do - resources :private_users, :except => [:show, :destroy, :update] - member do - get :clone - get :members - post :remove_members - delete :remove_member - post :add_member - post :make_clone - post :build_all - end - collection do - get :autocomplete_user_uname - end - resources :repositories do - member do - get :add_project - delete :remove_project - get :projects_list - end - end - resources :products do - resources :product_build_lists, :only => [:create, :destroy] - end - end - match '/private/:platform_name/*file_path' => 'privates#show' - - resources :projects, :except => [:show] do - resources :wiki do - collection do - match '_history' => 'wiki#wiki_history', :as => :history, :via => :get - match '_access' => 'wiki#git', :as => :git, :via => :get - match '_revert/:sha1/:sha2' => 'wiki#revert_wiki', :as => :revert, :via => [:get, :post] - match '_compare' => 'wiki#compare_wiki', :as => :compare, :via => :post - #match '_compare/:versions' => 'wiki#compare_wiki', :versions => /.*/, :as => :compare_versions, :via => :get - match '_compare/:versions' => 'wiki#compare_wiki', :versions => /([a-f0-9\^]{6,40})(\.\.\.[a-f0-9\^]{6,40})/, :as => :compare_versions, :via => :get - post :preview - get :search - get :pages - end - member do - get :history - get :edit - match 'revert/:sha1/:sha2' => 'wiki#revert', :as => :revert_page, :via => [:get, :post] - match ':ref' => 'wiki#show', :as => :versioned, :via => :get - - post :compare - #match 'compare/*versions' => 'wiki#compare', :as => :compare_versions, :via => :get - match 'compare/:versions' => 'wiki#compare', :versions => /([a-f0-9\^]{6,40})(\.\.\.[a-f0-9\^]{6,40})/, :as => :compare_versions, :via => :get - end - end - resources :issues, :except => :edit do - resources :comments, :only => [:edit, :create, :update, :destroy] - resources :subscribes, :only => [:create, :destroy] - collection do - post :create_label - get :search_collaborators - end - end - post "labels/:label_id" => "issues#destroy_label", :as => :issues_delete_label - post "labels/:label_id/update" => "issues#update_label", :as => :issues_update_label - resources :build_lists, :only => [:index, :new, :create] do - collection { post :search } - end - resources :collaborators do - get :find, :on => :collection - end - member do - post :fork - get :sections - post :sections - delete :remove_user - end - end - # Tree - get '/projects/:project_id' => "git/trees#show", :as => :project - get '/projects/:project_id/tree/:treeish(/*path)' => "git/trees#show", :defaults => {:treeish => :master}, :as => :tree - # Commits - get '/projects/:project_id/commits/:treeish(/*path)' => "git/commits#index", :defaults => {:treeish => :master}, :as => :commits, :format => false - get '/projects/:project_id/commit/:id(.:format)' => "git/commits#show", :as => :commit - # Commit comments - post '/projects/:project_id/commit/:commit_id/comments(.:format)' => "comments#create", :as => :project_commit_comments - get '/projects/:project_id/commit/:commit_id/comments/:id(.:format)' => "comments#edit", :as => :edit_project_commit_comment - put '/projects/:project_id/commit/:commit_id/comments/:id(.:format)' => "comments#update", :as => :project_commit_comment - delete '/projects/:project_id/commit/:commit_id/comments/:id(.:format)' => "comments#destroy" - # Commit subscribes - post '/projects/:project_id/commit/:commit_id/subscribe' => "commit_subscribes#create", :as => :subscribe_commit - delete '/projects/:project_id/commit/:commit_id/unsubscribe' => "commit_subscribes#destroy", :as => :unsubscribe_commit - # Editing files - get '/projects/:project_id/blob/:treeish/*path/edit' => "git/blobs#edit", :defaults => {:treeish => :master}, :as => :edit_blob - put '/projects/:project_id/blob/:treeish/*path' => "git/blobs#update", :defaults => {:treeish => :master}, :format => false - # Blobs - get '/projects/:project_id/blob/:treeish/*path' => "git/blobs#show", :defaults => {:treeish => :master}, :as => :blob, :format => false - # Blame - get '/projects/:project_id/blame/:treeish/*path' => "git/blobs#blame", :defaults => {:treeish => :master}, :as => :blame, :format => false - # Raw - get '/projects/:project_id/raw/:treeish/*path' => "git/blobs#raw", :defaults => {:treeish => :master}, :as => :raw, :format => false - - 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" - match 'build_lists/status_build', :to => "build_lists#status_build" - match 'build_lists/post_build', :to => "build_lists#post_build" - match 'build_lists/pre_build', :to => "build_lists#pre_build" - match 'build_lists/circle_build', :to => "build_lists#circle_build" - 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, :update] do - member do - put :cancel - put :publish - put :reject_publish - end - collection { post :search } - end - resources :product_build_lists, :only => [:index] resources :search, :only => [:index] - resources :event_logs, :only => :index - get '/forbidden' => 'pages#forbidden', :as => 'forbidden' get '/terms-of-service' => 'pages#tos', :as => 'tos' get '/activity_feeds.:format' => 'activity_feeds#index', :as => 'atom_activity_feeds', :format => /atom/ - if APP_CONFIG['anonymous_access'] authenticated do root :to => 'activity_feeds#index' @@ -184,4 +19,187 @@ Rosa::Application.routes.draw do else root :to => 'activity_feeds#index' end + + namespace :admin do + resources :users do + get :list, :on => :collection + end + resources :register_requests, :only => [:index] do + put :update, :on => :collection + member do + get :approve + get :reject + end + end + resources :event_logs, :only => :index + end + + scope :module => 'platforms' do + resources :platforms do + resources :private_users, :except => [:show, :destroy, :update] + member do + get :clone + get :members + post :remove_members + delete :remove_member + post :add_member + post :make_clone + post :build_all + end + get :autocomplete_user_uname, :on => :collection + resources :repositories do + member do + get :add_project + delete :remove_project + get :projects_list + end + end + resources :products do + resources :product_build_lists, :only => [:create, :destroy] + end + end + match '/private/:platform_name/*file_path' => 'privates#show' + + resources :product_build_lists, :only => [:index] + end + + scope :module => 'users' do + resources :settings, :only => [] do + collection do + get :profile + put :profile + get :private + put :private + get :notifiers + put :notifiers + end + end + resources :users, :controller => 'profile', :only => [] do + get :autocomplete_user_uname, :on => :collection + end + resources :register_requests, :only => [:new, :create] + end + + scope :module => 'groups' do + get '/groups/new' => 'profile#new' # need to force next route exclude :id => 'new' + get '/groups/:id' => redirect("/%{id}"), :as => :profile_group # override default group show route + resources :groups, :controller => 'profile' do + get :autocomplete_group_uname, :on => :collection + delete :remove_user, :on => :member + resources :members, :only => [:index] do + collection do + post :add + post :update + delete :remove + end + end + end + end + + scope :module => 'projects' do + # Core callbacks + match 'build_lists/publish_build', :to => "build_lists#publish_build" + match 'build_lists/status_build', :to => "build_lists#status_build" + match 'build_lists/post_build', :to => "build_lists#post_build" + match 'build_lists/pre_build', :to => "build_lists#pre_build" + match 'build_lists/circle_build', :to => "build_lists#circle_build" + 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, :update] do + member do + put :cancel + end + collection { post :search } + end + + resources :projects, :only => [:index, :new, :create] + + scope ':owner_name/:project_name' do # project + scope :as => 'project' do + resources :wiki do + collection do + match '_history' => 'wiki#wiki_history', :as => :history, :via => :get + match '_access' => 'wiki#git', :as => :git, :via => :get + match '_revert/:sha1/:sha2' => 'wiki#revert_wiki', :as => :revert, :via => [:get, :post] + match '_compare' => 'wiki#compare_wiki', :as => :compare, :via => :post + #match '_compare/:versions' => 'wiki#compare_wiki', :versions => /.*/, :as => :compare_versions, :via => :get + match '_compare/:versions' => 'wiki#compare_wiki', :versions => /([a-f0-9\^]{6,40})(\.\.\.[a-f0-9\^]{6,40})/, :as => :compare_versions, :via => :get + post :preview + get :search + get :pages + end + member do + get :history + get :edit + match 'revert/:sha1/:sha2' => 'wiki#revert', :as => :revert_page, :via => [:get, :post] + match ':ref' => 'wiki#show', :as => :versioned, :via => :get + + post :compare + #match 'compare/*versions' => 'wiki#compare', :as => :compare_versions, :via => :get + match 'compare/:versions' => 'wiki#compare', :versions => /([a-f0-9\^]{6,40})(\.\.\.[a-f0-9\^]{6,40})/, :as => :compare_versions, :via => :get + end + end + resources :issues, :except => :edit do + resources :comments, :only => [:edit, :create, :update, :destroy] + resources :subscribes, :only => [:create, :destroy] + collection do + post :create_label + get :search_collaborators + end + end + post "/labels/:label_id" => "issues#destroy_label", :as => :issues_delete_label + post "/labels/:label_id/update" => "issues#update_label", :as => :issues_update_label + resources :build_lists, :only => [:index, :new, :create] do + collection { post :search } + end + resources :collaborators do + get :find, :on => :collection + end + end + # Resource + get '/edit' => 'projects#edit', :as => :edit_project + put '/' => 'projects#update' + delete '/' => 'projects#destroy' + # Member + post '/fork' => 'projects#fork', :as => :fork_project + get '/sections' => 'projects#sections', :as => :sections_project + post '/sections' => 'projects#sections' + delete '/remove_user' => 'projects#remove_user', :as => :remove_user_project + # Tree + get '/' => "git/trees#show", :as => :project + get '/tree/:treeish(/*path)' => "git/trees#show", :defaults => {:treeish => :master}, :as => :tree, :format => false + # Commits + get '/commits/:treeish(/*path)' => "git/commits#index", :defaults => {:treeish => :master}, :as => :commits, :format => false + get '/commit/:id(.:format)' => "git/commits#show", :as => :commit + # Commit comments + post '/commit/:commit_id/comments(.:format)' => "comments#create", :as => :project_commit_comments + get '/commit/:commit_id/comments/:id(.:format)' => "comments#edit", :as => :edit_project_commit_comment + put '/commit/:commit_id/comments/:id(.:format)' => "comments#update", :as => :project_commit_comment + delete '/commit/:commit_id/comments/:id(.:format)' => "comments#destroy" + # Commit subscribes + post '/commit/:commit_id/subscribe' => "commit_subscribes#create", :as => :subscribe_commit + delete '/commit/:commit_id/unsubscribe' => "commit_subscribes#destroy", :as => :unsubscribe_commit + # Editing files + get '/blob/:treeish/*path/edit' => "git/blobs#edit", :defaults => {:treeish => :master}, :as => :edit_blob + put '/blob/:treeish/*path' => "git/blobs#update", :defaults => {:treeish => :master}, :format => false + # Blobs + get '/blob/:treeish/*path' => "git/blobs#show", :defaults => {:treeish => :master}, :as => :blob, :format => false + # Blame + get '/blame/:treeish/*path' => "git/blobs#blame", :defaults => {:treeish => :master}, :as => :blame, :format => false + # Raw + get '/raw/:treeish/*path' => "git/blobs#raw", :defaults => {:treeish => :master}, :as => :raw, :format => false + # Archive + get '/archive/:format/tree/:treeish' => "git/trees#archive", :defaults => {:treeish => :master}, :as => :archive, :format => /zip|tar/ + end + end + + scope ':uname' do # project owner profile + constraints OwnerConstraint.new(User) do + get '/' => 'users/profile#show', :as => :user + end + constraints OwnerConstraint.new(Group, true) do + get '/' => 'groups/profile#show', :as => :group + end + end end diff --git a/lib/ext/rails/owner_constraint.rb b/lib/ext/rails/owner_constraint.rb new file mode 100644 index 000000000..10f091e3f --- /dev/null +++ b/lib/ext/rails/owner_constraint.rb @@ -0,0 +1,12 @@ +# -*- encoding : utf-8 -*- +class OwnerConstraint + def initialize(class_name, bang = false) + @class_name = class_name + @finder = 'find_by_insensitive_uname' + @finder << '!' if bang + end + + def matches?(request) + @class_name.send(@finder, request.params[:uname]).present? + end +end diff --git a/lib/ext/render_errors_in_forms.rb b/lib/ext/rails/render_errors_in_forms.rb similarity index 100% rename from lib/ext/render_errors_in_forms.rb rename to lib/ext/rails/render_errors_in_forms.rb diff --git a/lib/ext/rails/reserved_name_validator.rb b/lib/ext/rails/reserved_name_validator.rb new file mode 100644 index 000000000..d53b045d8 --- /dev/null +++ b/lib/ext/rails/reserved_name_validator.rb @@ -0,0 +1,38 @@ +class ReservedNameValidator < ActiveModel::EachValidator + RESERVED_NAMES = %w{ + about account add admin administrator api autocomplete_group_uname + app apps archive archives auth + blog + config connect contact create commit commits + dashboard delete direct_messages downloads + edit email + faq favorites feed feeds follow followers following + help home + invitations invite + jobs + login log-in log_in logout log-out log_out logs + map maps + new + oauth oauth_clients openid + privacy + register remove replies rss root + save search sessions settings + signup sign-up sign_up signin sign-in sign_in signout sign-out sign_out + sitemap ssl subscribe + teams terms test trends tree + unfollow unsubscribe url user + widget widgets wiki + xfn xmpp + } + + def reserved_names + @reserved_names ||= RESERVED_NAMES + + Rails.application.routes.routes.map{|r| r.path.spec.to_s.match(/^\/([\w-]+)/)[1] rescue nil}.uniq.compact # current routes + end + + def validate_each(record, attribute, value) + if reserved_names.include?(value.to_s.downcase) + record.errors.add(attribute, :exclusion, options.merge(:value => value)) + end + end +end diff --git a/lib/ext/rails/url_for.rb b/lib/ext/rails/url_for.rb new file mode 100644 index 000000000..66f342de0 --- /dev/null +++ b/lib/ext/rails/url_for.rb @@ -0,0 +1,16 @@ +# -*- encoding : utf-8 -*- +module ActionDispatch + module Routing + module UrlFor + def url_for_with_defaults(options = nil) + if options.kind_of?(Hash) + if project = options[:_positional_args].try(:first) and project.is_a?(Project) # for project routes + options[:_positional_args].unshift(project.owner) # add owner to URL for correct generation + end + end + url_for_without_defaults(options) + end + alias_method_chain :url_for, :defaults + end + end +end diff --git a/lib/modules/models/acts_like_member.rb b/lib/modules/models/acts_like_member.rb index a8de53425..d413bb834 100644 --- a/lib/modules/models/acts_like_member.rb +++ b/lib/modules/models/acts_like_member.rb @@ -4,28 +4,38 @@ module Modules module ActsLikeMember extend ActiveSupport::Concern - included do |klass| - scope :not_member_of, lambda { |item| + included do + scope :not_member_of, lambda {|item| where(" - #{klass.table_name}.id NOT IN ( + #{table_name}.id NOT IN ( SELECT relations.actor_id FROM relations WHERE ( - relations.actor_type = '#{klass.to_s}' + relations.actor_type = '#{self.to_s}' AND relations.target_type = '#{item.class.to_s}' AND relations.target_id = #{item.id} ) ) ") } - scope :search_order, order("CHAR_LENGTH(uname) ASC") - scope :without, lambda {|a| where("#{klass.table_name}.id NOT IN (?)", a)} - scope :search, lambda {|q| where("#{klass.table_name}.uname ILIKE ?", "%#{q.strip}%")} + scope :without, lambda {|a| where("#{table_name}.id NOT IN (?)", a)} + scope :by_uname, lambda {|n| where("#{table_name}.uname ILIKE ?", n)} + scope :search, lambda {|q| by_uname("%#{q.to_s.strip}%")} + end + def to_param + uname end module ClassMethods + def find_by_insensitive_uname(uname) + find_by_uname(uname) || by_uname(uname).first + end + + def find_by_insensitive_uname!(uname) + find_by_insensitive_uname(uname) or raise ActiveRecord::RecordNotFound + end end end end diff --git a/lib/plugins/grack/base.rb b/lib/plugins/grack/base.rb index 2f0cc70bc..b464f44ee 100644 --- a/lib/plugins/grack/base.rb +++ b/lib/plugins/grack/base.rb @@ -35,11 +35,8 @@ module Grack def project @project ||= begin uname, name = @env['PATH_INFO'].split('/')[1,2] - name.gsub! /\.git$/, '' - name.gsub! /\.wiki$/, '' - owner = User.find_by_uname(uname) || Group.find_by_uname(uname) - scoped = Project.where(:owner_id => owner.id, :owner_type => owner.class) - scoped.find_by_name(name) || scoped.by_name(name).first + name.gsub!(/\.git$/, '').gsub!(/\.wiki$/, '') + Project.find_by_owner_and_name uname, name end end diff --git a/public/invite.html b/public/invite.html index 4feb0c004..cf0af6f33 100644 --- a/public/invite.html +++ b/public/invite.html @@ -40,7 +40,7 @@

Хочу стать бета-тестером ABF!

-
+ diff --git a/spec/controllers/groups/members_controller_spec.rb b/spec/controllers/groups/members_controller_spec.rb new file mode 100644 index 000000000..a245165e8 --- /dev/null +++ b/spec/controllers/groups/members_controller_spec.rb @@ -0,0 +1,122 @@ +# -*- encoding : utf-8 -*- +require 'spec_helper' + +describe Groups::MembersController do + before(:each) do + stub_rsync_methods + @group = FactoryGirl.create(:group) + @user = @group.owner + set_session_for @user + @another_user = FactoryGirl.create(:user) + @add_params = {:group_id => @group, :user_id => @another_user.uname} + @remove_params = {:group_id => @group, :user_remove => {"#{@group.owner.id}"=>["1"]}} + @update_params = {:group_id => @group, :user => {"#{@group.owner.id}"=>'reader'}} + end + + context 'for owner user' do + it 'should add member to group' do + post :add, @add_params + response.should redirect_to(group_members_path(@group)) + Relation.by_target(@group).by_actor(@another_user).count.should eql(1) + end + + it 'should add reader member to group' do + post :add, @add_params + Relation.by_target(@group).by_actor(@another_user).first.role.should eql('reader') + response.should redirect_to(group_members_path(@group)) + end + + it 'should not remove self from group' do + post :remove, @remove_params + Relation.by_target(@group).by_actor(@user).first.role.should eql('admin') + response.should redirect_to(group_members_path(@group)) + end + end + + context 'for admin user' do + before(:each) do + @admin_user = FactoryGirl.create(:user) + @group.actors.create(:actor_id => @admin_user.id, :actor_type => 'User', :role => 'admin') + set_session_for @admin_user + end + + it 'should add member to group' do + post :add, @add_params + response.should redirect_to(group_members_path(@group)) + Relation.by_target(@group).by_actor(@another_user).count.should eql(1) + response.should redirect_to(group_members_path(@group)) + end + + it 'should add reader member to group' do + post :add, @add_params + Relation.by_target(@group).by_actor(@another_user).first.role.should eql('reader') + response.should redirect_to(group_members_path(@group)) + end + + it 'should not remove owner from group' do + post :remove, @remove_params + Relation.by_target(@group).by_actor(@user).first.role.should eql('admin') + response.should redirect_to(group_members_path(@group)) + end + + it 'should not set read role to owner group' do + post :update, @update_params + Relation.by_target(@group).by_actor(@user).first.role.should eql('admin') + response.should redirect_to(group_members_path(@group)) + end + end + + context 'for writer user' do + before(:each) do + @writer_user = FactoryGirl.create(:user) + @group.actors.create(:actor_id => @writer_user.id, :actor_type => 'User', :role => 'writer') + set_session_for @writer_user + end + + it 'should not add member to group' do + post :add, @add_params + response.should redirect_to(forbidden_path) + end + + it 'should add reader member to group' do + post :add, @add_params + response.should redirect_to(forbidden_path) + end + + it 'should not remove owner from group' do + post :remove, @remove_params + response.should redirect_to(forbidden_path) + end + + it 'should not set read role to owner group' do + post :update, @update_params + response.should redirect_to(forbidden_path) + end + end + + context 'for another user' do + before(:each) do + set_session_for @another_user + end + + it 'should not add member to group' do + post :add, @add_params + response.should redirect_to(forbidden_path) + end + + it 'should add reader member to group' do + post :add, @add_params + response.should redirect_to(forbidden_path) + end + + it 'should not remove owner from group' do + post :remove, @remove_params + response.should redirect_to(forbidden_path) + end + + it 'should not set read role to owner group' do + post :update, @update_params + response.should redirect_to(forbidden_path) + end + end +end diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups/profile_controller_spec.rb similarity index 84% rename from spec/controllers/groups_controller_spec.rb rename to spec/controllers/groups/profile_controller_spec.rb index 68db4bbf4..73605fa66 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups/profile_controller_spec.rb @@ -3,24 +3,24 @@ require 'spec_helper' shared_examples_for 'group user without update rights' do it 'should be not able to perform update action' do - put :update, {:id => @group.id}.merge(@update_params) + put :update, {:id => @group}.merge(@update_params) response.should redirect_to(forbidden_path) end it 'should not be able to update group data' do - put :update, :id => @group.id, :group => {:description => 'new description'} + put :update, :id => @group, :group => {:description => 'new description'} @group.reload.description.should_not == 'new description' end end shared_examples_for 'group user without destroy rights' do it 'should not be able to destroy group' do - delete :destroy, :id => @group.id + delete :destroy, :id => @group response.should redirect_to(forbidden_path) end it 'should not change groups count after destroy action' do - lambda { delete :destroy, :id => @group.id }.should change{ Group.count }.by(0) + lambda { delete :destroy, :id => @group }.should change{ Group.count }.by(0) end end @@ -28,12 +28,12 @@ shared_examples_for 'group admin' do it_should_behave_like 'no group user' it 'should be able to update group data' do - put :update, :id => @group.id, :group => {:description => 'new description'} + put :update, :id => @group, :group => {:description => 'new description'} @group.reload.description.should == 'new description' end it 'should be able to perform update action' do - put :update, {:id => @group.id}.merge(@update_params) + put :update, {:id => @group}.merge(@update_params) response.should redirect_to(group_path(@group)) end end @@ -41,7 +41,7 @@ end shared_examples_for 'no group user' do it 'should be able to perform create action' do post :create, @create_params - response.should redirect_to(group_path( Group.last.id )) + response.should redirect_to(group_path(Group.last)) end it 'should change objects count on create' do @@ -58,16 +58,16 @@ shared_examples_for 'group owner' do it_should_behave_like 'group admin' it 'should be able to destroy group' do - delete :destroy, :id => @group.id + delete :destroy, :id => @group response.should redirect_to(groups_path) end it 'should change groups count after destroy action' do - lambda { delete :destroy, :id => @group.id }.should change{ Group.count }.by(-1) + lambda { delete :destroy, :id => @group }.should change{ Group.count }.by(-1) end end -describe GroupsController do +describe Groups::ProfileController do before(:each) do stub_rsync_methods @group = FactoryGirl.create(:group) @@ -83,7 +83,7 @@ describe GroupsController do end it 'should not be able to perform update action' do - put :update, {:id => @group.id}.merge(@update_params) + put :update, {:id => @group}.merge(@update_params) response.should redirect_to(new_user_session_path) end @@ -108,7 +108,7 @@ describe GroupsController do end it 'should be able to perform update action' do - put :update, {:id => @group.id}.merge(@update_params) + put :update, {:id => @group}.merge(@update_params) response.should redirect_to(group_path(@group)) end end diff --git a/spec/controllers/members_controller_spec.rb b/spec/controllers/members_controller_spec.rb deleted file mode 100644 index 9389bb281..000000000 --- a/spec/controllers/members_controller_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -# -*- encoding : utf-8 -*- -require 'spec_helper' - -describe MembersController do - before(:each) do - stub_rsync_methods - @group = FactoryGirl.create(:group) - @user = @group.owner - set_session_for @user - @another_user = FactoryGirl.create(:user) - @add_params = {:group_id => @group.id, :user_id => @another_user.uname} - end - - context 'for owner user' do - it 'should add member to group' do - post :add, @add_params - response.should redirect_to(edit_group_members_path(@group)) - Relation.by_target(@group).by_actor(@another_user).count.should eql(1) - end - - it 'should add reader member to group' do - post :add, @add_params - Relation.by_target(@group).by_actor(@another_user).first.role.should eql('reader') - end - end -end diff --git a/spec/controllers/platforms_controller_spec.rb b/spec/controllers/platforms/platforms_controller_spec.rb similarity index 98% rename from spec/controllers/platforms_controller_spec.rb rename to spec/controllers/platforms/platforms_controller_spec.rb index c915f1477..5ec928b1c 100644 --- a/spec/controllers/platforms_controller_spec.rb +++ b/spec/controllers/platforms/platforms_controller_spec.rb @@ -33,7 +33,7 @@ shared_examples_for 'user without create rights' do end end -describe PlatformsController do +describe Platforms::PlatformsController do before(:each) do stub_rsync_methods diff --git a/spec/controllers/private_users_controller_spec.rb b/spec/controllers/platforms/private_users_controller_spec.rb similarity index 54% rename from spec/controllers/private_users_controller_spec.rb rename to spec/controllers/platforms/private_users_controller_spec.rb index d73052fac..6a6918ce7 100644 --- a/spec/controllers/private_users_controller_spec.rb +++ b/spec/controllers/platforms/private_users_controller_spec.rb @@ -1,6 +1,6 @@ # -*- encoding : utf-8 -*- require 'spec_helper' -describe PrivateUsersController do +describe Platforms::PrivateUsersController do end diff --git a/spec/controllers/privates_controller_spec.rb b/spec/controllers/platforms/privates_controller_spec.rb similarity index 56% rename from spec/controllers/privates_controller_spec.rb rename to spec/controllers/platforms/privates_controller_spec.rb index 1c6353bde..4a6b49c4d 100644 --- a/spec/controllers/privates_controller_spec.rb +++ b/spec/controllers/platforms/privates_controller_spec.rb @@ -1,6 +1,6 @@ # -*- encoding : utf-8 -*- require 'spec_helper' -describe PrivatesController do +describe Platforms::PrivatesController do end diff --git a/spec/controllers/product_build_lists_controller_spec.rb b/spec/controllers/platforms/product_build_lists_controller_spec.rb similarity index 98% rename from spec/controllers/product_build_lists_controller_spec.rb rename to spec/controllers/platforms/product_build_lists_controller_spec.rb index f8192bc59..c79828492 100644 --- a/spec/controllers/product_build_lists_controller_spec.rb +++ b/spec/controllers/platforms/product_build_lists_controller_spec.rb @@ -24,7 +24,7 @@ shared_examples_for 'admin' do end -describe ProductBuildListsController do +describe Platforms::ProductBuildListsController do before(:each) do stub_rsync_methods end diff --git a/spec/controllers/products_controller_spec.rb b/spec/controllers/platforms/products_controller_spec.rb similarity index 98% rename from spec/controllers/products_controller_spec.rb rename to spec/controllers/platforms/products_controller_spec.rb index 4b8a63c69..7490675e9 100644 --- a/spec/controllers/products_controller_spec.rb +++ b/spec/controllers/platforms/products_controller_spec.rb @@ -22,7 +22,7 @@ shared_examples_for 'admin user' do end -describe ProductsController do +describe Platforms::ProductsController do before(:each) do stub_rsync_methods diff --git a/spec/controllers/repositories_controller_spec.rb b/spec/controllers/platforms/repositories_controller_spec.rb similarity index 99% rename from spec/controllers/repositories_controller_spec.rb rename to spec/controllers/platforms/repositories_controller_spec.rb index b42625942..5fec835cc 100644 --- a/spec/controllers/repositories_controller_spec.rb +++ b/spec/controllers/platforms/repositories_controller_spec.rb @@ -65,7 +65,7 @@ shared_examples_for 'platform admin user' do it_should_behave_like 'not destroy personal repository' end -describe RepositoriesController do +describe Platforms::RepositoriesController do before(:each) do stub_rsync_methods diff --git a/spec/controllers/build_lists_controller_spec.rb b/spec/controllers/projects/build_lists_controller_spec.rb similarity index 93% rename from spec/controllers/build_lists_controller_spec.rb rename to spec/controllers/projects/build_lists_controller_spec.rb index 32a6ced90..bdaf51cc0 100644 --- a/spec/controllers/build_lists_controller_spec.rb +++ b/spec/controllers/projects/build_lists_controller_spec.rb @@ -1,7 +1,7 @@ # -*- encoding : utf-8 -*- require 'spec_helper' -describe BuildListsController do +describe Projects::BuildListsController do shared_examples_for 'show build list' do it 'should be able to perform show action' do @@ -10,7 +10,7 @@ describe BuildListsController do end it 'should be able to perform index action in project scope' do - get :index, :project_id => @project.id + get :index, :owner_name => @project.owner.uname, :project_name => @project.name response.should be_success end end @@ -22,7 +22,7 @@ describe BuildListsController do end it 'should not be able to perform index action in project scope' do - get :index, :project_id => @project.id + get :index, :owner_name => @project.owner.uname, :project_name => @project.name response.should redirect_to(forbidden_url) end end @@ -31,35 +31,35 @@ describe BuildListsController do before {test_git_commit(@project)} it 'should be able to perform new action' do - get :new, :project_id => @project.id + get :new, :owner_name => @project.owner.uname, :project_name => @project.name response.should render_template(:new) end it 'should be able to perform create action' do - post :create, {:project_id => @project.id}.merge(@create_params) + post :create, {:owner_name => @project.owner.uname, :project_name => @project.name}.merge(@create_params) response.should redirect_to project_build_lists_path(@project) end it 'should save correct commit_hash for branch based build' do - post :create, {:project_id => @project.id}.merge(@create_params).deep_merge(:build_list => {:project_version => "latest_master"}) + post :create, {:owner_name => @project.owner.uname, :project_name => @project.name}.merge(@create_params).deep_merge(:build_list => {:project_version => "latest_master"}) @project.build_lists.last.commit_hash.should == @project.git_repository.commits('master').last.id end it 'should save correct commit_hash for tag based build' do system("cd #{@project.git_repository.path} && git tag 4.7.5.3") # TODO REDO through grit - post :create, {:project_id => @project.id}.merge(@create_params).deep_merge(:build_list => {:project_version => "4.7.5.3"}) + post :create, {:owner_name => @project.owner.uname, :project_name => @project.name}.merge(@create_params).deep_merge(:build_list => {:project_version => "4.7.5.3"}) @project.build_lists.last.commit_hash.should == @project.git_repository.commits('4.7.5.3').last.id end end shared_examples_for 'not create build list' do it 'should not be able to perform new action' do - get :new, :project_id => @project.id + get :new, :owner_name => @project.owner.uname, :project_name => @project.name response.should redirect_to(forbidden_url) end it 'should not be able to perform create action' do - post :create, {:project_id => @project.id}.merge(@create_params) + post :create, {:owner_name => @project.owner.uname, :project_name => @project.name}.merge(@create_params) response.should redirect_to(forbidden_url) end end @@ -107,7 +107,7 @@ describe BuildListsController do rel.save @user = FactoryGirl.create(:user) set_session_for(@user) - @show_params = {:project_id => @project.id, :id => @build_list.id} + @show_params = {:owner_name => @project.owner.uname, :project_name => @project.name, :id => @build_list.id} end context 'for all build lists' do @@ -192,7 +192,7 @@ describe BuildListsController do @build_list = FactoryGirl.create(:build_list_core, :project => @project) set_session_for(@user) - @show_params = {:project_id => @project.id, :id => @build_list.id} + @show_params = {:owner_name => @project.owner.uname, :project_name => @project.name, :id => @build_list.id} end context 'for all build lists' do diff --git a/spec/controllers/collaborators_controller_spec.rb b/spec/controllers/projects/collaborators_controller_spec.rb similarity index 79% rename from spec/controllers/collaborators_controller_spec.rb rename to spec/controllers/projects/collaborators_controller_spec.rb index bee7f4187..f40f0b3c8 100644 --- a/spec/controllers/collaborators_controller_spec.rb +++ b/spec/controllers/projects/collaborators_controller_spec.rb @@ -13,19 +13,19 @@ def create_params :role => 'reader' } @create_params = { - :project_id => @project.id.to_s, + :owner_name => @project.owner.uname, :project_name => @project.name, :format => :json } end shared_examples_for 'project admin user' do it 'should be able to view collaborators list' do - get :index, :project_id => @project.id + get :index, :owner_name => @project.owner.uname, :project_name => @project.name response.should be_success end it 'should be able to perform update action' do - put :update, {:project_id => @project.id, :id => @collaborator.id}.merge(@update_params) + put :update, {:owner_name => @project.owner.uname, :project_name => @project.name, :id => @collaborator.id}.merge(@update_params) response.should be_success end @@ -40,29 +40,29 @@ shared_examples_for 'project admin user' do end it 'should be able to set reader role for any user' do - put :update, {:project_id => @project.id, :id => @collaborator.id}.merge(@update_params) + put :update, {:owner_name => @project.owner.uname, :project_name => @project.name, :id => @collaborator.id}.merge(@update_params) @another_user.relations.exists? :target_id => @project.id, :target_type => 'Project', :role => 'read' end end shared_examples_for 'user with no rights for this project' do it 'should not be able to view collaborators list' do - get :index, :project_id => @project.id + get :index, :owner_name => @project.owner.uname, :project_name => @project.name response.should redirect_to(forbidden_path) end it 'should not be able to perform update action' do - put :update, {:project_id => @project.id, :id => @collaborator.id}.merge(@update_params) + put :update, {:owner_name => @project.owner.uname, :project_name => @project.name, :id => @collaborator.id}.merge(@update_params) response.should redirect_to(forbidden_path) end it 'should not be able to set reader role for any user' do - put :update, {:project_id => @project.id, :id => @collaborator.id}.merge(@update_params) + put :update, {:owner_name => @project.owner.uname, :project_name => @project.name, :id => @collaborator.id}.merge(@update_params) !@another_user.relations.exists? :target_id => @project.id, :target_type => 'Project', :role => 'read' end end -describe CollaboratorsController do +describe Projects::CollaboratorsController do before(:each) do stub_rsync_methods @project = FactoryGirl.create(:project) @@ -75,12 +75,12 @@ describe CollaboratorsController do context 'for guest' do it 'should not be able to perform index action' do - get :index, :project_id => @project.id + get :index, :owner_name => @project.owner.uname, :project_name => @project.name response.should redirect_to(new_user_session_path) end it 'should not be able to perform update action' do - put :update, {:project_id => @project.id, :id => @collaborator.id}.merge(@update_params) + put :update, {:owner_name => @project.owner.uname, :project_name => @project.name, :id => @collaborator.id}.merge(@update_params) response.code.should == '401' end end diff --git a/spec/controllers/comments_controller_for_commit_spec.rb b/spec/controllers/projects/comments_controller_for_commit_spec.rb similarity index 87% rename from spec/controllers/comments_controller_for_commit_spec.rb rename to spec/controllers/projects/comments_controller_for_commit_spec.rb index 6f646eae7..9cc131c3e 100644 --- a/spec/controllers/comments_controller_for_commit_spec.rb +++ b/spec/controllers/projects/comments_controller_for_commit_spec.rb @@ -54,35 +54,35 @@ end shared_examples_for 'user without destroy comment rights for commits' do it 'should not be able to perform destroy action' do - delete :destroy, :id => @stranger_comment.id, :commit_id => @commit.id, :project_id => @project.id + delete :destroy, :id => @stranger_comment.id, :commit_id => @commit.id, :owner_name => @project.owner.uname, :project_name => @project.name response.should redirect_to(forbidden_path) end it 'should not reduce comments count' do - lambda{ delete :destroy, :id => @stranger_comment.id, :commit_id => @commit.id, :project_id => @project.id }.should change{ Comment.count }.by(0) + lambda{ delete :destroy, :id => @stranger_comment.id, :commit_id => @commit.id, :owner_name => @project.owner.uname, :project_name => @project.name }.should change{ Comment.count }.by(0) end end #shared_examples_for 'user with destroy rights' do # it 'should be able to perform destroy action' do -# delete :destroy, :id => @stranger_comment.id, :project_id => @project.id +# delete :destroy, :id => @stranger_comment.id, :owner_name => @project.owner.uname, :project_name => @project.name # response.should redirect_to(commit_path(@project, @commit.id)) # end # # it 'should reduce comments count' do -# lambda{ delete :destroy, :id => @stranger_comment.id, :issue_id => @issue.serial_id, :project_id => @project.id }.should change{ Comment.count }.by(-1) +# lambda{ delete :destroy, :id => @stranger_comment.id, :issue_id => @issue.serial_id, :owner_name => @project.owner.uname, :project_name => @project.name }.should change{ Comment.count }.by(-1) # end #end -describe CommentsController do +describe Projects::CommentsController do before(:each) do stub_rsync_methods @project = FactoryGirl.create(:project) %x(cp -Rf #{Rails.root}/spec/tests.git/* #{@project.git_repository.path}) # maybe FIXME ? @commit = @project.git_repository.commits.first - @create_params = {:comment => {:body => 'I am a comment!'}, :project_id => @project.id, :commit_id => @commit.id} - @update_params = {:comment => {:body => 'updated'}, :project_id => @project.id, :commit_id => @commit.id} + @create_params = {:comment => {:body => 'I am a comment!'}, :owner_name => @project.owner.uname, :project_name => @project.name, :commit_id => @commit.id} + @update_params = {:comment => {:body => 'updated'}, :owner_name => @project.owner.uname, :project_name => @project.name, :commit_id => @commit.id} any_instance_of(Project, :versions => ['v1.0', 'v2.0']) @stranger_comment = create_comment FactoryGirl.create(:user) diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/projects/comments_controller_spec.rb similarity index 85% rename from spec/controllers/comments_controller_spec.rb rename to spec/controllers/projects/comments_controller_spec.rb index 01b3c468f..41d6009b4 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/projects/comments_controller_spec.rb @@ -50,27 +50,27 @@ end shared_examples_for 'user without destroy comment rights' do it 'should not be able to perform destroy action' do - delete :destroy, :id => @comment.id, :issue_id => @issue.serial_id, :project_id => @project.id + delete :destroy, :id => @comment.id, :issue_id => @issue.serial_id, :owner_name => @project.owner.uname, :project_name => @project.name response.should redirect_to(forbidden_path) end it 'should not reduce comments count' do - lambda{ delete :destroy, :id => @comment.id, :issue_id => @issue.serial_id, :project_id => @project.id }.should change{ Issue.count }.by(0) + lambda{ delete :destroy, :id => @comment.id, :issue_id => @issue.serial_id, :owner_name => @project.owner.uname, :project_name => @project.name }.should change{ Issue.count }.by(0) end end #shared_examples_for 'user with destroy rights' do # it 'should be able to perform destroy action' do -# delete :destroy, :id => @comment.id, :issue_id => @issue.id, :project_id => @project.id +# delete :destroy, :id => @comment.id, :issue_id => @issue.id, :owner_name => @project.owner.uname, :project_name => @project.name # response.should redirect_to([@project, @issue]) # end # # it 'should reduce comments count' do -# lambda{ delete :destroy, :id => @comment.id, :issue_id => @issue.id, :project_id => @project.id }.should change{ Comment.count }.by(-1) +# lambda{ delete :destroy, :id => @comment.id, :issue_id => @issue.id, :owner_name => @project.owner.uname, :project_name => @project.name }.should change{ Comment.count }.by(-1) # end #end -describe CommentsController do +describe Projects::CommentsController do before(:each) do stub_rsync_methods @@ -78,8 +78,8 @@ describe CommentsController do @issue = FactoryGirl.create(:issue, :project_id => @project.id, :user => FactoryGirl.create(:user)) @comment = FactoryGirl.create(:comment, :commentable => @issue, :project_id => @project.id) - @create_params = {:comment => {:body => 'I am a comment!'}, :project_id => @project.id, :issue_id => @issue.serial_id} - @update_params = {:comment => {:body => 'updated'}, :project_id => @project.id, :issue_id => @issue.serial_id} + @create_params = {:comment => {:body => 'I am a comment!'}, :owner_name => @project.owner.uname, :project_name => @project.name, :issue_id => @issue.serial_id} + @update_params = {:comment => {:body => 'updated'}, :owner_name => @project.owner.uname, :project_name => @project.name, :issue_id => @issue.serial_id} any_instance_of(Project, :versions => ['v1.0', 'v2.0']) @@ -102,6 +102,7 @@ describe CommentsController do context 'for project owner user' do before(:each) do @project.update_attribute(:owner, @user) + @create_params[:owner_name] = @user.uname; @update_params[:owner_name] = @user.uname end it_should_behave_like 'user with create comment rights' diff --git a/spec/controllers/git_trees_controller_spec.rb b/spec/controllers/projects/git/git_trees_controller_spec.rb similarity index 92% rename from spec/controllers/git_trees_controller_spec.rb rename to spec/controllers/projects/git/git_trees_controller_spec.rb index 25b85dff3..16a10a40b 100644 --- a/spec/controllers/git_trees_controller_spec.rb +++ b/spec/controllers/projects/git/git_trees_controller_spec.rb @@ -1,7 +1,7 @@ # -*- encoding : utf-8 -*- require 'spec_helper' -describe Git::TreesController do +describe Projects::Git::TreesController do def fill_project %x(cp -Rf #{Rails.root}/spec/tests.git/* #{@project.git_repository.path}) # maybe FIXME ? @@ -12,7 +12,7 @@ describe Git::TreesController do @project = FactoryGirl.create(:project) @another_user = FactoryGirl.create(:user) - @params = {:project_id => @project.id, :format => 'tar'} + @params = {:owner_name => @project.owner.uname, :project_name => @project.name, :format => 'tar'} end context 'for guest' do diff --git a/spec/controllers/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb similarity index 86% rename from spec/controllers/issues_controller_spec.rb rename to spec/controllers/projects/issues_controller_spec.rb index 9a52e8fe6..fe1028f67 100644 --- a/spec/controllers/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -3,12 +3,12 @@ require 'spec_helper' shared_examples_for 'issue user with project reader rights' do it 'should be able to perform index action' do - get :index, :project_id => @project.id + get :index, :owner_name => @project.owner.uname, :project_name => @project.name response.should render_template(:index) end it 'should be able to perform show action' do - get :show, :project_id => @project.id, :id => @issue.serial_id + get :show, :owner_name => @project.owner.uname, :project_name => @project.name, :id => @issue.serial_id response.should render_template(:show) end end @@ -50,12 +50,12 @@ end shared_examples_for 'user without issue destroy rights' do it 'should not be able to perform destroy action' do - delete :destroy, :id => @issue.serial_id, :project_id => @project.id + delete :destroy, :id => @issue.serial_id, :owner_name => @project.owner.uname, :project_name => @project.name response.should redirect_to(controller.current_user ? forbidden_path : new_user_session_path) end it 'should not reduce issues count' do - lambda{ delete :destroy, :id => @issue.serial_id, :project_id => @project.id }.should_not change{ Issue.count } + lambda{ delete :destroy, :id => @issue.serial_id, :owner_name => @project.owner.uname, :project_name => @project.name }.should_not change{ Issue.count } end end @@ -71,7 +71,7 @@ shared_examples_for 'project with issues turned off' do end end -describe IssuesController do +describe Projects::IssuesController do before(:each) do stub_rsync_methods @@ -82,17 +82,16 @@ describe IssuesController do @issue = FactoryGirl.create(:issue, :project_id => @project.id, :assignee_id => @issue_user.id) @create_params = { - :project_id => @project.id, + :owner_name => @project.owner.uname, :project_name => @project.name, :issue => { :title => "issue1", - :body => "issue body", - :project_id => @project.id + :body => "issue body" }, :assignee_id => @issue_user.id, :assignee_uname => @issue_user.uname } @update_params = { - :project_id => @project.id, + :owner_name => @project.owner.uname, :project_name => @project.name, :issue => { :title => "issue2" } @@ -129,7 +128,7 @@ describe IssuesController do before(:each) do @user = FactoryGirl.create(:user) set_session_for(@user) - @project.update_attribute(:owner, @user) + @project.update_attribute(:owner, @user); @create_params[:owner_name] = @user.uname; @update_params[:owner_name] = @user.uname @project.relations.create!(:actor_type => 'User', :actor_id => @user.id, :role => 'admin') end @@ -191,12 +190,12 @@ describe IssuesController do it_should_behave_like 'issue user with project reader rights' else it 'should not be able to perform index action' do - get :index, :project_id => @project.id + get :index, :owner_name => @project.owner.uname, :project_name => @project.name response.should redirect_to(new_user_session_path) end it 'should not be able to perform show action' do - get :show, :project_id => @project.id, :id => @issue.serial_id + get :show, :owner_name => @project.owner.uname, :project_name => @project.name, :id => @issue.serial_id response.should redirect_to(new_user_session_path) end end diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects/projects_controller_spec.rb similarity index 78% rename from spec/controllers/projects_controller_spec.rb rename to spec/controllers/projects/projects_controller_spec.rb index 95bfc5cf5..4893709f2 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects/projects_controller_spec.rb @@ -1,7 +1,7 @@ # -*- encoding : utf-8 -*- require 'spec_helper' -describe ProjectsController do +describe Projects::ProjectsController do before(:each) do stub_rsync_methods @@ -9,7 +9,7 @@ describe ProjectsController do @project = FactoryGirl.create(:project) @another_user = FactoryGirl.create(:user) @create_params = {:project => {:name => 'pro'}} - @update_params = {:project => {:name => 'pro2'}} + @update_params = {:project => {:description => 'pro2'}} end context 'for guest' do @@ -19,7 +19,7 @@ describe ProjectsController do end it 'should not be able to perform update action' do - put :update, {:id => @project.id}.merge(@update_params) + put :update, {:owner_name => @project.owner.uname, :project_name => @project.name}.merge(@update_params) response.should redirect_to(new_user_session_path) end end @@ -35,7 +35,7 @@ describe ProjectsController do it 'should be able to perform create action' do post :create, @create_params - response.should redirect_to(project_path( Project.last.id )) + response.should redirect_to(project_path( Project.last )) end it 'should change objects count on create' do @@ -55,17 +55,18 @@ describe ProjectsController do it_should_behave_like 'user with rights to view projects' it 'should be able to perform destroy action' do - delete :destroy, {:id => @project.id} + delete :destroy, {:owner_name => @project.owner.uname, :project_name => @project.name} response.should redirect_to(@project.owner) end it 'should change objects count on destroy' do - lambda { delete :destroy, :id => @project.id }.should change{ Project.count }.by(-1) + lambda { delete :destroy, :owner_name => @project.owner.uname, :project_name => @project.name }.should change{ Project.count }.by(-1) end it 'should not be able to fork project' do - post :fork, :id => @project.id - response.should redirect_to(forbidden_path) + post :fork, :owner_name => @project.owner.uname, :project_name => @project.name + # @project.errors.count.should == 1 + response.should redirect_to(@project) end end @@ -97,15 +98,15 @@ describe ProjectsController do it 'should not be able to fork project to other group' do group = FactoryGirl.create(:group) - post :fork, :id => @project.id, :group => group.id + post :fork, :owner_name => @project.owner.uname, :project_name => @project.name, :group => group.id response.should redirect_to(forbidden_path) end it 'should be able to fork project to group' do group = FactoryGirl.create(:group) group.actors.create(:actor_type => 'User', :actor_id => @user.id, :role => 'admin') - post :fork, :id => @project.id, :group => group.id - response.should redirect_to(project_path(group.projects.first.id)) + post :fork, :owner_name => @project.owner.uname, :project_name => @project.name, :group => group.id + response.should redirect_to(project_path(group.projects.first)) end end @@ -128,7 +129,7 @@ describe ProjectsController do @user = FactoryGirl.create(:user) set_session_for(@user) @project.update_attribute(:visibility, 'hidden') - post :fork, :id => @project.id + post :fork, :owner_name => @project.owner.uname, :project_name => @project.name response.should redirect_to(forbidden_path) end end diff --git a/spec/controllers/subscribes_controller_spec.rb b/spec/controllers/projects/subscribes_controller_spec.rb similarity index 90% rename from spec/controllers/subscribes_controller_spec.rb rename to spec/controllers/projects/subscribes_controller_spec.rb index b443b2893..ea6c9b5af 100644 --- a/spec/controllers/subscribes_controller_spec.rb +++ b/spec/controllers/projects/subscribes_controller_spec.rb @@ -47,15 +47,15 @@ shared_examples_for 'can not unsubscribe' do end end -describe SubscribesController do +describe Projects::SubscribesController do before(:each) do stub_rsync_methods @project = FactoryGirl.create(:project) @issue = FactoryGirl.create(:issue, :project_id => @project.id) - @create_params = {:issue_id => @issue.serial_id, :project_id => @project.id} - @destroy_params = {:issue_id => @issue.serial_id, :project_id => @project.id} + @create_params = {:issue_id => @issue.serial_id, :owner_name => @project.owner.uname, :project_name => @project.name} + @destroy_params = {:issue_id => @issue.serial_id, :owner_name => @project.owner.uname, :project_name => @project.name} any_instance_of(Project, :versions => ['v1.0', 'v2.0']) diff --git a/spec/controllers/wiki_controller_spec.rb b/spec/controllers/projects/wiki_controller_spec.rb similarity index 59% rename from spec/controllers/wiki_controller_spec.rb rename to spec/controllers/projects/wiki_controller_spec.rb index c2297dc15..2dca6d702 100644 --- a/spec/controllers/wiki_controller_spec.rb +++ b/spec/controllers/projects/wiki_controller_spec.rb @@ -1,6 +1,6 @@ # -*- encoding : utf-8 -*- require 'spec_helper' -describe WikiController do +describe Projects::WikiController do end diff --git a/spec/controllers/settings/notifiers_controller_spec.rb b/spec/controllers/settings/notifiers_controller_spec.rb deleted file mode 100644 index b12e4526c..000000000 --- a/spec/controllers/settings/notifiers_controller_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -*- encoding : utf-8 -*- -require 'spec_helper' - -describe Settings::NotifiersController do - -end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users/profile_controller_spec.rb similarity index 76% rename from spec/controllers/users_controller_spec.rb rename to spec/controllers/users/profile_controller_spec.rb index dd58d3ecd..6c370e44f 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users/profile_controller_spec.rb @@ -1,7 +1,7 @@ # -*- encoding : utf-8 -*- require 'spec_helper' -describe UsersController do +describe Users::ProfileController do before(:each) do stub_rsync_methods @@ -16,15 +16,9 @@ describe UsersController do context 'for guest' do it 'should not be able to view profile' do - get :profile + get :show, :owner_name => @simple_user.uname response.should redirect_to(new_user_session_path) end - - it 'should not be able to update other profile' do - get :update, {:id => @other_user.id}.merge(@update_params) - response.should redirect_to(new_user_session_path) - @other_user.reload.email.should_not == @update_params[:email] - end end context 'for simple user' do @@ -33,7 +27,7 @@ describe UsersController do end it 'should be able to view profile' do - get :profile + get :show, :uname => @other_user.uname response.code.should eq('200') end diff --git a/spec/factories/settings_notifiers.rb b/spec/factories/settings_notifiers.rb index 04a8e4b82..723afeadd 100644 --- a/spec/factories/settings_notifiers.rb +++ b/spec/factories/settings_notifiers.rb @@ -1,7 +1,6 @@ # -*- encoding : utf-8 -*- -# Read about factories at http://github.com/thoughtbot/factory_girl FactoryGirl.define do - factory :notifier do - end + factory :settings_notifier do + end end diff --git a/spec/helpers/settings/notifiers_helper_spec.rb b/spec/helpers/settings/notifiers_helper_spec.rb deleted file mode 100644 index 820d9bcb2..000000000 --- a/spec/helpers/settings/notifiers_helper_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -# -*- encoding : utf-8 -*- -require 'spec_helper' - -# Specs in this file have access to a helper object that includes -# the Settings::NotifiersHelper. For example: -# -# describe Settings::NotifiersHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# helper.concat_strings("this","that").should == "this that" -# end -# end -# end -describe Settings::NotifiersHelper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/cancan_spec.rb b/spec/models/cancan_spec.rb index 71a228613..d2317f33b 100644 --- a/spec/models/cancan_spec.rb +++ b/spec/models/cancan_spec.rb @@ -45,10 +45,6 @@ describe CanCan do it 'should not be able to destroy personal repositories' do @ability.should_not be_able_to(:destroy, personal_repository) end - - it 'should not be able to create new register requests' do - @ability.should_not be_able_to(:create, RegisterRequest) - end end context 'Site guest' do @@ -70,10 +66,6 @@ describe CanCan do end end - it 'should be able to create register request' do - @ability.should be_able_to(:create, RegisterRequest) - end - it 'should not be able to update register request' do @ability.should_not be_able_to(:update, register_request) end diff --git a/spec/models/settings/notifier_spec.rb b/spec/models/settings/notifier_spec.rb deleted file mode 100644 index bf9f548c6..000000000 --- a/spec/models/settings/notifier_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -# -*- encoding : utf-8 -*- -require 'spec_helper' - -describe Settings::Notifier do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/support/shared_examples/projects_controller.rb b/spec/support/shared_examples/projects_controller.rb index a31fe4727..0562f06d8 100644 --- a/spec/support/shared_examples/projects_controller.rb +++ b/spec/support/shared_examples/projects_controller.rb @@ -3,14 +3,14 @@ shared_examples_for 'projects user with reader rights' do it_should_behave_like 'user with rights to view projects' it 'should be able to fork project' do - post :fork, :id => @project.id + post :fork, :owner_name => @project.owner.uname, :project_name => @project.name response.should redirect_to(project_path(Project.last)) end end shared_examples_for 'projects user with admin rights' do it 'should be able to perform update action' do - put :update, {:id => @project.id}.merge(@update_params) + put :update, {:owner_name => @project.owner.uname, :project_name => @project.name}.merge(@update_params) response.should redirect_to(project_path(@project)) end end