Great controllers and routes refactor - separate them to namespaces. Add user/group routes in github style, refactor. Implement templates inheritance. Refactor and cleanup views. Fix specs. Other minor fixes. Refs #263

This commit is contained in:
Pavel Chipiga 2012-05-02 12:18:07 +03:00
parent b957600eda
commit 2539ef4795
242 changed files with 865 additions and 1206 deletions

View File

@ -0,0 +1,5 @@
# -*- encoding : utf-8 -*-
class Admin::BaseController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource
end

View File

@ -1,8 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class EventLogsController < ApplicationController class Admin::EventLogsController < Admin::BaseController
before_filter :authenticate_user!
load_and_authorize_resource
def index def index
@event_logs = EventLog.default_order.eager_loading.paginate :page => params[:page] @event_logs = EventLog.default_order.eager_loading.paginate :page => params[:page]
end end

View File

@ -0,0 +1,29 @@
# -*- 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
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
end

View File

@ -1,7 +1,6 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class Admin::UsersController < ApplicationController class Admin::UsersController < Admin::BaseController
before_filter :authenticate_user! prepend_before_filter :find_user
load_and_authorize_resource
def index def index
@filter = params[:filter] || 'all' @filter = params[:filter] || 'all'
@ -15,7 +14,7 @@ class Admin::UsersController < ApplicationController
@user.confirmed_at = Time.now.utc @user.confirmed_at = Time.now.utc
if @user.save if @user.save
flash[:notice] = t('flash.user.saved') flash[:notice] = t('flash.user.saved')
redirect_to users_path redirect_to admin_users_path
else else
flash[:error] = t('flash.user.save_error') flash[:error] = t('flash.user.save_error')
flash[:warning] = @user.errors.full_messages.join('. ') flash[:warning] = @user.errors.full_messages.join('. ')
@ -23,7 +22,7 @@ class Admin::UsersController < ApplicationController
end end
end end
def profile def edit
end end
def update def update
@ -34,18 +33,18 @@ class Admin::UsersController < ApplicationController
@user.save @user.save
end end
flash[:notice] = t('flash.user.saved') flash[:notice] = t('flash.user.saved')
redirect_to users_path#edit_user_path(@user) redirect_to admin_users_path
else else
flash[:error] = t('flash.user.save_error') flash[:error] = t('flash.user.save_error')
flash[:warning] = @user.errors.full_messages.join('. ') flash[:warning] = @user.errors.full_messages.join('. ')
render(:action => :profile) render :action => :edit
end end
end end
def destroy def destroy
@user.destroy @user.destroy
flash[:notice] = t("flash.user.destroyed") flash[:notice] = t("flash.user.destroyed")
redirect_to users_path redirect_to admin_users_path
end end
def list def list
@ -66,4 +65,10 @@ class Admin::UsersController < ApplicationController
render :partial => 'users_ajax', :layout => false render :partial => 'users_ajax', :layout => false
end end
protected
def find_user
@user = User.find_by_uname!(params[:id]) if params[:id]
end
end end

View File

@ -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[:owner_name] || params[:group_id] || params[:id]
@group = Group.find_by_owner_name! group_id
end
end
end

View File

@ -1,32 +1,11 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class MembersController < ApplicationController class Groups::MembersController < Groups::BaseController
before_filter :authenticate_user!
is_related_controller! is_related_controller!
belongs_to :group, :finder => 'find_by_owner_name!', :optional => true
belongs_to :group, :optional => true before_filter lambda { authorize! :manage_members, @group }
# before_filter :find_target
before_filter :find_users
def index 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 end
def update def update
@ -34,42 +13,30 @@ class MembersController < ApplicationController
role = params['user'][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') 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) relation.update_all(:role => role)
else else
relation = parent.actors.build(:actor_id => user_id, :actor_type => 'User', :role => role) relation = parent.actors.build(:actor_id => user_id, :actor_type => 'User', :role => role)
relation.save! relation.save!
end end
} if params['user'] } if params['user']
if parent.save if parent.save
flash[:notice] = t("flash.members.successfully_changed") flash[:notice] = t("flash.members.successfully_changed")
else else
flash[:error] = t("flash.members.error_in_changing") flash[:error] = t("flash.members.error_in_changing")
end end
redirect_to group_members_path(parent)
redirect_to edit_group_members_path(parent)
end end
def remove 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 = [] all_user_ids = []
params['user_remove'].keys.each { |user_id| params['user_remove'].keys.each { |user_id|
all_user_ids << user_id if params['user_remove'][user_id] == ["1"] all_user_ids << user_id if params['user_remove'][user_id] == ["1"]
} if params['user_remove'] } if params['user_remove']
all_user_ids.each do |user_id| all_user_ids.each do |user_id|
u = User.find(user_id) u = User.find(user_id)
Relation.by_actor(u).by_target(parent).each {|r| r.destroy} Relation.by_actor(u).by_target(parent).each {|r| r.destroy}
end end
redirect_to group_members_path(parent)
redirect_to edit_group_members_path(parent)
end
end end
def add def add
@ -86,13 +53,6 @@ class MembersController < ApplicationController
flash[:error] = t("flash.members.already_added") flash[:error] = t("flash.members.already_added")
end end
end end
redirect_to edit_group_members_path(parent) redirect_to group_members_path(parent)
end end
protected
def find_users
@users = parent.members #User.all
end
end end

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,3 @@
# -*- encoding : utf-8 -*-
class Platforms::BaseController < ApplicationController
end

View File

@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class PlatformsController < ApplicationController class Platforms::PlatformsController < Platforms::BaseController
before_filter :authenticate_user! before_filter :authenticate_user!
load_and_authorize_resource load_and_authorize_resource
@ -17,7 +17,6 @@ class PlatformsController < ApplicationController
end end
def show def show
end end
def new def new

View File

@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class PrivateUsersController < ApplicationController class Platforms::PrivateUsersController < Platforms::BaseController
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :find_platform_and_private_users before_filter :find_platform_and_private_users

View File

@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class PrivatesController < ApplicationController class Platforms::PrivatesController < Platforms::BaseController
require 'digest/sha2' require 'digest/sha2'
before_filter :find_platform before_filter :find_platform

View File

@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class ProductBuildListsController < ApplicationController class Platforms::ProductBuildListsController < Platforms::BaseController
before_filter :authenticate_user!, :except => [:status_build] before_filter :authenticate_user!, :except => [:status_build]
skip_before_filter :authenticate_user!, :only => [:index] if APP_CONFIG['anonymous_access'] skip_before_filter :authenticate_user!, :only => [:index] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :platform, :only => [:create, :destroy] load_and_authorize_resource :platform, :only => [:create, :destroy]

View File

@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class ProductsController < ApplicationController class Platforms::ProductsController < Platforms::BaseController
before_filter :authenticate_user! before_filter :authenticate_user!
load_and_authorize_resource :platform load_and_authorize_resource :platform

View File

@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class RepositoriesController < ApplicationController class Platforms::RepositoriesController < Platforms::BaseController
before_filter :authenticate_user! before_filter :authenticate_user!
load_and_authorize_resource :platform load_and_authorize_resource :platform

View File

@ -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

View File

@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*- # -*- 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] CALLBACK_ACTIONS = [:publish_build, :status_build, :pre_build, :post_build, :circle_build, :new_bbdt]
NESTED_ACTIONS = [:search, :index, :new, :create] NESTED_ACTIONS = [:search, :index, :new, :create]
@ -14,8 +14,6 @@ class BuildListsController < ApplicationController
load_and_authorize_resource :build_list, :through => :project, :only => NESTED_ACTIONS, :shallow => true load_and_authorize_resource :build_list, :through => :project, :only => NESTED_ACTIONS, :shallow => true
load_and_authorize_resource :except => CALLBACK_ACTIONS.concat(NESTED_ACTIONS) load_and_authorize_resource :except => CALLBACK_ACTIONS.concat(NESTED_ACTIONS)
include Modules::Controllers::FindProject
def search def search
new_params = {:filter => {}} new_params = {:filter => {}}
params[:filter].each do |k,v| params[:filter].each do |k,v|
@ -37,7 +35,7 @@ class BuildListsController < ApplicationController
end end
def new def new
@build_list = BuildList.new # @build_list = BuildList.new # @build_list already created by CanCan
end end
def create def create

View File

@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class CollaboratorsController < ApplicationController class Projects::CollaboratorsController < Projects::BaseController
respond_to :html, :json respond_to :html, :json
before_filter :authenticate_user! before_filter :authenticate_user!
@ -9,8 +9,6 @@ class CollaboratorsController < ApplicationController
before_filter :find_users before_filter :find_users
before_filter :find_groups before_filter :find_groups
include Modules::Controllers::FindProject
def index def index
@collaborators = Collaborator.find_by_project(@project) @collaborators = Collaborator.find_by_project(@project)
respond_with @collaborators respond_with @collaborators

View File

@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class CommentsController < ApplicationController class Projects::CommentsController < Projects::BaseController
before_filter :authenticate_user! before_filter :authenticate_user!
load_and_authorize_resource :project load_and_authorize_resource :project
before_filter :find_commentable before_filter :find_commentable
@ -7,7 +7,6 @@ class CommentsController < ApplicationController
load_and_authorize_resource load_and_authorize_resource
include CommentsHelper include CommentsHelper
include Modules::Controllers::FindProject
def create def create
if @comment.save if @comment.save

View File

@ -1,12 +1,10 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class CommitSubscribesController < ApplicationController class Projects::CommitSubscribesController < Projects::BaseController
before_filter :authenticate_user! before_filter :authenticate_user!
load_and_authorize_resource :project load_and_authorize_resource :project
before_filter :find_commit before_filter :find_commit
include Modules::Controllers::FindProject
def create def create
if Subscribe.subscribe_to_commit(@options) if Subscribe.subscribe_to_commit(@options)
flash[:notice] = I18n.t("flash.subscribe.commit.saved") flash[:notice] = I18n.t("flash.subscribe.commit.saved")

View File

@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class Git::BaseController < ApplicationController class Projects::Git::BaseController < Projects::BaseController
before_filter :authenticate_user! before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:show, :index, :blame, :raw, :archive] if APP_CONFIG['anonymous_access'] skip_before_filter :authenticate_user!, :only => [:show, :index, :blame, :raw, :archive] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :project load_and_authorize_resource :project
@ -11,8 +11,6 @@ class Git::BaseController < ApplicationController
before_filter :set_current_tag before_filter :set_current_tag
before_filter :set_current_branch before_filter :set_current_branch
include Modules::Controllers::FindProject
protected protected
def find_git_repository def find_git_repository

View File

@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class Git::BlobsController < Git::BaseController class Projects::Git::BlobsController < Projects::Git::BaseController
before_filter :find_tree before_filter :find_tree
before_filter :find_branch before_filter :find_branch
before_filter :set_path_blob before_filter :set_path_blob

View File

@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class Git::CommitsController < Git::BaseController class Projects::Git::CommitsController < Projects::Git::BaseController
helper_method :split_commits_by_date helper_method :split_commits_by_date
def index def index

View File

@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class Git::TreesController < Git::BaseController class Projects::Git::TreesController < Projects::Git::BaseController
def show def show
redirect_to project_path(@project) and return if params[:treeish] == @project.default_branch and params[:path].blank? 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 # @commit = @git_repository.commits(@treeish, 1).first
# Raises Grit::Git::GitTimeout # Raises Grit::Git::GitTimeout
@commit = @branch.present? ? @branch.commit() : @git_repository.log(@treeish, @path, :max_count => 1).first @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 @tree = @tree / @path if @path
render :template => "git/trees/show"
end end
def archive def archive
@ -28,8 +27,6 @@ class Git::TreesController < Git::BaseController
file = Tempfile.new fullname, 'tmp' file = Tempfile.new fullname, 'tmp'
system("cd #{@project.path}; git archive --format=#{format} --prefix=#{name}/ #{treeish} #{format == 'tar' ? ' | gzip -9' : ''} > #{file.path}") system("cd #{@project.path}; git archive --format=#{format} --prefix=#{name}/ #{treeish} #{format == 'tar' ? ' | gzip -9' : ''} > #{file.path}")
file.close file.close
send_file file.path, :disposition => 'attachment', :type => "application/#{format == 'tar' ? 'x-tar-gz' : 'zip'}", send_file file.path, :disposition => 'attachment', :type => "application/#{format == 'tar' ? 'x-tar-gz' : 'zip'}", :filename => fullname
:filename => fullname
end end
end end

View File

@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class IssuesController < ApplicationController class Projects::IssuesController < Projects::BaseController
NON_RESTFUL_ACTION = [:create_label, :update_label, :destroy_label, :search_collaborators] NON_RESTFUL_ACTION = [:create_label, :update_label, :destroy_label, :search_collaborators]
before_filter :authenticate_user! before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access'] skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access']
@ -9,8 +9,6 @@ class IssuesController < ApplicationController
layout 'application' layout 'application'
include Modules::Controllers::FindProject
def index(status = 200) def index(status = 200)
@is_assigned_to_me = params[:filter] == 'to_me' @is_assigned_to_me = params[:filter] == 'to_me'
@status = params[:status] == 'closed' ? 'closed' : 'open' @status = params[:status] == 'closed' ? 'closed' : 'open'
@ -57,11 +55,11 @@ class IssuesController < ApplicationController
def update def update
if params[:issue] && status = params[:issue][:status] if params[:issue] && status = params[:issue][:status]
action = 'issues/_status' action = 'status'
@issue.set_close(current_user) if status == 'closed' @issue.set_close(current_user) if status == 'closed'
@issue.set_open if status == 'open' @issue.set_open if status == 'open'
status = 200 if @issue.save status = 200 if @issue.save
render action, :status => (status || 500), :layout => false render :partial => action, :status => (status || 500), :layout => false
elsif params[:issue] elsif params[:issue]
@issue.labelings.destroy_all if params[:issue][:labelings_attributes] # FIXME @issue.labelings.destroy_all if params[:issue][:labelings_attributes] # FIXME
status = 200 if @issue.update_attributes(params[:issue]) status = 200 if @issue.update_attributes(params[:issue])
@ -98,7 +96,7 @@ class IssuesController < ApplicationController
users = User.joins(:groups => :projects).where(:projects => {:id => @project.id}).where("users.uname ILIKE ?", search) users = User.joins(:groups => :projects).where(:projects => {:id => @project.id}).where("users.uname ILIKE ?", search)
users2 = @project.collaborators.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) @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 end
private private

View File

@ -1,10 +1,8 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class ProjectsController < ApplicationController class Projects::ProjectsController < Projects::BaseController
before_filter :authenticate_user! before_filter :authenticate_user!
load_and_authorize_resource load_and_authorize_resource
include Modules::Controllers::FindProject
def index def index
@projects = Project.accessible_by(current_ability, :membered) @projects = Project.accessible_by(current_ability, :membered)
# @projects = @projects.search(params[:query]).search_order if params[:query].present? # @projects = @projects.search(params[:query]).search_order if params[:query].present?

View File

@ -1,13 +1,11 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class SubscribesController < ApplicationController class Projects::SubscribesController < Projects::BaseController
before_filter :authenticate_user! before_filter :authenticate_user!
load_and_authorize_resource :project load_and_authorize_resource :project
load_and_authorize_resource :issue, :through => :project, :find_by => :serial_id load_and_authorize_resource :issue, :through => :project, :find_by => :serial_id
load_and_authorize_resource :subscribe, :through => :issue, :find_by => :user_id load_and_authorize_resource :subscribe, :through => :issue, :find_by => :user_id
include Modules::Controllers::FindProject
def create def create
@subscribe = @issue.subscribes.build(:user_id => current_user.id) @subscribe = @issue.subscribes.build(:user_id => current_user.id)
if @subscribe.save if @subscribe.save

View File

@ -2,7 +2,7 @@
#require 'lib/gollum' #require 'lib/gollum'
require 'cgi' require 'cgi'
class WikiController < ApplicationController class Projects::WikiController < Projects::BaseController
WIKI_OPTIONS = {} WIKI_OPTIONS = {}
before_filter :authenticate_user! before_filter :authenticate_user!
@ -13,8 +13,6 @@ class WikiController < ApplicationController
before_filter :authorize_write_actions, :only => [:edit, :update, :new, :create, :destroy, :revert, :revert_wiki, :preview] before_filter :authorize_write_actions, :only => [:edit, :update, :new, :create, :destroy, :revert, :revert_wiki, :preview]
before_filter :get_wiki before_filter :get_wiki
include Modules::Controllers::FindProject
def index def index
@name = 'Home' @name = 'Home'
@page = @wiki.page(@name) @page = @wiki.page(@name)

View File

@ -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

View File

@ -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

View File

@ -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[:owner_name] || params[:user_id] || params[:id]
@user = User.find_by_owner_name! user_id
end
end
end

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,7 +1,7 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
module ActivityFeedsHelper module ActivityFeedsHelper
def render_activity_feed(activity_feed) 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 end
def get_feed_title_from_content(content) def get_feed_title_from_content(content)

View File

@ -2,15 +2,15 @@
module ApplicationHelper module ApplicationHelper
def layout_class def layout_class
case case
when params[:controller] == 'issues' && params[:action] == 'new' when controller_name == 'issues' && action_name == 'new'
'right nopadding' 'right nopadding'
when params[:controller] == 'build_lists' && params[:action] == 'index' when controller_name == 'build_lists' && action_name == 'index'
'right slim' 'right slim'
when params[:controller] == 'build_lists' && ['new', 'create'].include?(params[:action]) when controller_name == 'build_lists' && ['new', 'create'].include?(action_name)
nil nil
when params[:controller] == 'platforms' && params[:action] == 'show' when controller_name == 'platforms' && action_name == 'show'
'right bigpadding' 'right bigpadding'
when params[:controller] == 'platforms' && params[:action] == 'clone' when controller_name == 'platforms' && action_name == 'clone'
'right middlepadding' 'right middlepadding'
else else
content_for?(:sidebar) ? 'right' : 'all' content_for?(:sidebar) ? 'right' : 'all'

View File

@ -1,3 +0,0 @@
# -*- encoding : utf-8 -*-
module Settings::NotifiersHelper
end

View File

@ -1,3 +0,0 @@
# -*- encoding : utf-8 -*-
module SubscribesHelper
end

View File

@ -23,12 +23,11 @@ class Ability
can [:publish_build, :status_build, :pre_build, :post_build, :circle_build, :new_bbdt], BuildList can [:publish_build, :status_build, :pre_build, :post_build, :circle_build, :new_bbdt], BuildList
if user.guest? # Guest rights if user.guest? # Guest rights
can [:create, :show_message], RegisterRequest # can [:new, :create], RegisterRequest
else # Registered user rights else # Registered user rights
if user.admin? if user.admin?
can :manage, :all can :manage, :all
# Protection # Protection
cannot :create, RegisterRequest
cannot :approve, RegisterRequest, :approved => true cannot :approve, RegisterRequest, :approved => true
cannot :reject, RegisterRequest, :rejected => true cannot :reject, RegisterRequest, :rejected => true
cannot [:destroy, :create], Subscribe cannot [:destroy, :create], Subscribe
@ -40,15 +39,13 @@ class Ability
if user.user? if user.user?
can [:show, :autocomplete_user_uname], 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 [:read, :create, :autocomplete_group_uname], Group
can [:update, :manage_members], Group do |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 group.actors.exists?(:actor_type => 'User', :actor_id => user.id, :role => 'admin') # or group.owner_id = user.id
end end
can :destroy, Group, :owner_id => user.id can :destroy, Group, :owner_id => user.id
can :remove_user, Group
can :create, Project can :create, Project
can :read, Project, :visibility => 'open' can :read, Project, :visibility => 'open'

View File

@ -14,21 +14,20 @@ class Group < ActiveRecord::Base
validates :owner, :presence => true validates :owner, :presence => true
validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => {:with => /^[a-z0-9_]+$/}, :reserved_name => true validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => {:with => /^[a-z0-9_]+$/}, :reserved_name => true
validate { errors.add(:uname, :taken) if User.where('uname LIKE ?', uname).present? } validate { errors.add(:uname, :taken) if User.by_uname(uname).present? }
scope :opened, where('1=1') scope :opened, where('1=1')
scope :by_owner, lambda {|owner| where(:owner_id => owner.id)} 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')} 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 :uname, :description
attr_readonly :uname
attr_accessible :description
attr_readonly :own_projects_count
delegate :email, :to => :owner delegate :email, :to => :owner
after_create :add_owner_to_members after_create :add_owner_to_members
include Modules::Models::ActsLikeMember
include Modules::Models::PersonalRepository include Modules::Models::PersonalRepository
# include Modules::Models::Owner # include Modules::Models::Owner
@ -36,10 +35,6 @@ class Group < ActiveRecord::Base
(by_owner(user) | by_admin(user)) (by_owner(user) | by_admin(user))
end end
def to_param
uname
end
def name def name
uname uname
end end
@ -47,7 +42,6 @@ class Group < ActiveRecord::Base
protected protected
def add_owner_to_members def add_owner_to_members
Relation.create_with_role(self.owner, self, 'admin') Relation.create_with_role(self.owner, self, 'admin') # members << self.owner if !members.exists?(:id => self.owner.id)
# members << self.owner if !members.exists?(:id => self.owner.id)
end end
end end

View File

@ -36,9 +36,7 @@ class Platform < ActiveRecord::Base
scope :main, where(:platform_type => 'main') scope :main, where(:platform_type => 'main')
scope :personal, where(:platform_type => 'personal') 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, :owner, :visibility, :description, :released #, :owner_id, :owner_type
attr_accessible :name, :distrib_type, :parent_platform_id, :platform_type
attr_readonly :name, :distrib_type, :parent_platform_id, :platform_type attr_readonly :name, :distrib_type, :parent_platform_id, :platform_type
include Modules::Models::Owner include Modules::Models::Owner
@ -100,7 +98,8 @@ class Platform < ActiveRecord::Base
def base_clone(attrs = {}) # :description, :name, :owner def base_clone(attrs = {}) # :description, :name, :owner
clone.tap do |c| 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.updated_at = nil; c.created_at = nil # :id = nil
c.parent = self c.parent = self
end end

View File

@ -15,8 +15,7 @@ class Product < ActiveRecord::Base
scope :recent, order("name ASC") scope :recent, order("name ASC")
attr_accessible :name, :counter, :ks, :menu, :tar, :cron_tab, :use_cron attr_accessible :name, :counter, :ks, :menu, :tar, :cron_tab, :use_cron, :description, :build_script, :delete_tar
attr_accessible :description, :build_script, :delete_tar
attr_readonly :platform_id attr_readonly :platform_id
def delete_tar def delete_tar

View File

@ -6,6 +6,7 @@ class Project < ActiveRecord::Base
belongs_to :owner, :polymorphic => true, :counter_cache => :own_projects_count belongs_to :owner, :polymorphic => true, :counter_cache => :own_projects_count
has_many :issues, :dependent => :destroy has_many :issues, :dependent => :destroy
has_many :labels, :dependent => :destroy
has_many :build_lists, :dependent => :destroy has_many :build_lists, :dependent => :destroy
has_many :project_imports, :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 :relations, :as => :target, :dependent => :destroy
has_many :collaborators, :through => :relations, :source => :actor, :source_type => 'User' has_many :collaborators, :through => :relations, :source => :actor, :source_type => 'User'
has_many :groups, :through => :relations, :source => :actor, :source_type => 'Group' has_many :groups, :through => :relations, :source => :actor, :source_type => 'Group'
has_many :labels
validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^[a-zA-Z0-9_\-\+\.]+$/} validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^[a-zA-Z0-9_\-\+\.]+$/}
validates :owner, :presence => true validates :owner, :presence => true
@ -51,10 +51,12 @@ class Project < ActiveRecord::Base
include Modules::Models::Owner include Modules::Models::Owner
def to_param; name; end def to_param
name
end
def self.find_by_owner_and_name(owner_name, project_name) def self.find_by_owner_and_name(owner_name, project_name)
owner = User.find_by_uname(owner_name) || Group.find_by_uname(owner_name) and 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 = where(:owner_id => owner.id, :owner_type => owner.class) and
scoped.find_by_name(project_name) || scoped.by_name(project_name).first scoped.find_by_name(project_name) || scoped.by_name(project_name).first
end end
@ -268,7 +270,7 @@ class Project < ActiveRecord::Base
def create_wiki def create_wiki
if has_wiki && !FileTest.exist?(wiki_path) if has_wiki && !FileTest.exist?(wiki_path)
Grit::Repo.init_bare(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"), wiki.write_page('Home', :markdown, I18n.t("wiki.seed.welcome_content"),
{:name => owner.name, :email => owner.email, :message => 'Initial commit'}) {:name => owner.name, :email => owner.email, :message => 'Initial commit'})
end end

View File

@ -1,6 +0,0 @@
# -*- encoding : utf-8 -*-
module Settings
def self.table_name_prefix
'settings_'
end
end

View File

@ -1,5 +1,5 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class Settings::Notifier < ActiveRecord::Base class SettingsNotifier < ActiveRecord::Base
belongs_to :user belongs_to :user
validates :user_id, :presence => true validates :user_id, :presence => true

View File

@ -15,7 +15,7 @@ class User < ActiveRecord::Base
} }
validates_inclusion_of :avatar_file_size, :in => (0..MAX_AVATAR_SIZE), :allow_nil => true 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 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_groups, :foreign_key => :owner_id, :class_name => 'Group', :dependent => :destroy
has_many :own_platforms, :as => :owner, :class_name => 'Platform', :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_]+$/}, :reserved_name => true validates :uname, :presence => true, :uniqueness => {:case_sensitive => false}, :format => {:with => /^[a-z0-9_]+$/}, :reserved_name => true
validate { errors.add(:uname, :taken) if Group.where('uname LIKE ?', uname).present? } validate { errors.add(:uname, :taken) if Group.by_uname(uname).present? }
validates :role, :inclusion => {:in => ROLES}, :allow_blank => true validates :role, :inclusion => {:in => ROLES}, :allow_blank => true
validates :language, :inclusion => {:in => LANGUAGES}, :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, attr_accessible :email, :password, :password_confirmation, :current_password, :remember_me, :login, :name, :uname, :language,
:site, :company, :professional_experience, :location, :avatar :site, :company, :professional_experience, :location, :avatar
attr_readonly :uname, :own_projects_count attr_readonly :uname
attr_accessor :login attr_accessor :login
scope :opened, where('1=1') scope :opened, where('1=1')
@ -52,14 +50,11 @@ class User < ActiveRecord::Base
scope :admin, where(:role => 'admin') scope :admin, where(:role => 'admin')
scope :real, where(:role => ['', nil]) scope :real, where(:role => ['', nil])
include Modules::Models::ActsLikeMember
after_create lambda { self.create_notifier } after_create lambda { self.create_notifier }
before_create :ensure_authentication_token before_create :ensure_authentication_token
def to_param include Modules::Models::PersonalRepository
uname include Modules::Models::ActsLikeMember
end
def admin? def admin?
role == 'admin' role == 'admin'
@ -81,6 +76,10 @@ class User < ActiveRecord::Base
return "#{uname} (#{name})" return "#{uname} (#{name})"
end end
def user_appeal
name.presence || uname
end
class << self class << self
def find_for_database_authentication(warden_conditions) def find_for_database_authentication(warden_conditions)
conditions = warden_conditions.dup conditions = warden_conditions.dup
@ -130,14 +129,4 @@ class User < ActiveRecord::Base
false false
end end
end end
def user_appeal
name.blank? ? uname : name
end
private
def create_settings_notifier
self.create_notifier
end
end end

View File

@ -1,3 +0,0 @@
- content_for :submenu do
%nav
= render :partial => 'layouts/menu/top', :locals => {:which_menu => 'admins_menu'}

View File

@ -0,0 +1,2 @@
- content_for :submenu do
%nav= render 'layouts/menu/top', :which_menu => 'admins_menu'

View File

@ -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'

View File

@ -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 &nbsp;
%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'

View File

@ -1,7 +1,7 @@
- content_for :sidebar do - content_for :sidebar do
.bordered .bordered
- if can? :create, User.new - 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") %h3= t("layout.users.filter_header")
%table %table
- t('layout.users.users_filter').each_key do |base| - t('layout.users.users_filter').each_key do |base|

View File

@ -9,9 +9,9 @@
"<%= user.uname %>", "<%= user.uname %>",
"<%= user.email %>", "<%= user.email %>",
"<span style='<%=user.access_locked? ? 'background: #FEDEDE' : ''%>'><%= user.role %></span>", "<span style='<%=user.access_locked? ? 'background: #FEDEDE' : ''%>'><%= user.role %></span>",
"<%= j raw [(link_to t('layout.show'), user_path(user) if can? :read, user), "<%= j raw [(link_to t('layout.show'), user if can? :read, user),
(link_to t('layout.edit'), edit_user_path(user) if can? :edit, user), (link_to t('layout.edit'), edit_admin_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) (link_to t('layout.delete'), admin_user_path(user), :method => :delete, :confirm => t('layout.users.confirm_delete') if can? :destroy, user)
].compact.join('&nbsp;|&nbsp;') %>" ].compact.join('&nbsp;|&nbsp;') %>"
]<%= user == @users.last ? '' : ',' %> ]<%= user == @users.last ? '' : ',' %>
<% end %> <% end %>

View File

@ -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'

View File

@ -23,8 +23,8 @@
%tbody %tbody
%br %br
= render :partial => 'admin/users/sidebar' = render 'sidebar'
= render 'admin/submenu' = render 'submenu'
:javascript :javascript
$('#users_filter[type="radio"]').live('change', function(){ $('#users_filter[type="radio"]').live('change', function(){

View File

@ -2,10 +2,9 @@
.content .content
%h2.title= title t("layout.users.new_header") %h2.title= title t("layout.users.new_header")
.inner .inner
= form_for @user, :url => create_user_path, :html => { :class => :form } do |f| = form_for @user, :url => admin_users_path, :html => {:class => :form} do |f|
= render :partial => "users/form", :locals => {:f => f} = render "users/base/form", :f => f
- content_for :sidebar do - content_for :sidebar do
.bordered.nopadding .bordered.nopadding
= render 'submenu'
= render 'admin/submenu'

View File

@ -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

View File

@ -20,4 +20,4 @@
= image_tag("choose.png", :alt => t("devise.confirmations.send")) = image_tag("choose.png", :alt => t("devise.confirmations.send"))
= t("devise.confirmations.send") = t("devise.confirmations.send")
%span.text_button_padding %span.text_button_padding
= render :partial => "devise/shared/links" = render "devise/shared/links"

View File

@ -1,7 +1,7 @@
%h3.fix.bpadding10= @user.uname %h3.fix.bpadding10= @user.uname
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => "form" }) do |f| = 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 .notify
%p= t('layout.users.public_data_edit_warning') %p= t('layout.users.public_data_edit_warning')

View File

@ -6,4 +6,4 @@
%br/ %br/
= f.text_field :email = f.text_field :email
%p= f.submit "Resend unlock instructions" %p= f.submit "Resend unlock instructions"
= render :partial => "devise/shared/links" = render "devise/shared/links"

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -6,8 +6,8 @@
.admin-preferences .admin-preferences
%ul %ul
- if can? :edit, @group - 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) = link_to t("layout.groups.edit"), edit_group_path(@group)
- if can? :manage_members, @group - if can? :manage_members, @group
%li{:class => (act == :edit && contr == :members) ? 'active' : ''} %li{:class => (act == :index && contr == :members) ? 'active' : ''}
= link_to t("layout.groups.edit_members"), edit_group_members_path(@group) = link_to t("layout.groups.edit_members"), group_members_path(@group)

View File

@ -6,35 +6,28 @@
%tr %tr
%th %th
\  \ 
%th %th= t("layout.collaborators.members")
= t("layout.collaborators.members") %th{:colspan => "3"}= t("layout.collaborators.roles")
%th{:colspan => "3"}
= t("layout.collaborators.roles")
%tbody %tbody
- @users.each do |user| - parent.members.each do |user|
%tr %tr
%td %td
%span#niceCheckbox1.niceCheck-main %span#niceCheckbox1.niceCheck-main= check_box_tag "user_remove[#{user.id}][]"
= check_box_tag "user_remove[#{user.id}][]"
%td %td
.img .img= image_tag avatar_url(user)
= image_tag avatar_url(user)
.forimg= link_to user.name, user_path(user) .forimg= link_to user.name, user_path(user)
- Relation::ROLES.each_with_index do |role, i| - Relation::ROLES.each_with_index do |role, i|
%td %td
.radio .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_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 }") .forradio= t("layout.collaborators.role_names.#{ role }")
= link_to_function t("layout.delete"), "deleteAdminMember();", :class => 'button' = link_to_function t("layout.delete"), "deleteAdminMember();", :class => 'button'
.both .both
.hr.top .hr.top
= form_tag add_group_members_path(parent) do = form_tag add_group_members_path(parent) do
.admin-search .admin-search= autocomplete_field_tag 'user_id', params[:user_id], autocomplete_user_uname_users_path#, :id_element => '#member_id_field'
= autocomplete_field_tag 'user_id', params[:user_id], autocomplete_user_uname_users_path#, :id_element => '#member_id_field'
.admin-role .admin-role
.lineForm .lineForm= select_tag 'role', options_for_collaborators_roles_select
= select_tag 'role', options_for_collaborators_roles_select
.both .both
%br %br
= submit_tag t("layout.add"), :class => 'button' = submit_tag t("layout.add"), :class => 'button'
@ -43,4 +36,4 @@
.both .both
= link_to_function t("layout.save"), "saveAdminMember();", :class => 'button' = link_to_function t("layout.save"), "saveAdminMember();", :class => 'button'
- content_for :sidebar, render('groups/sidebar') - content_for :sidebar, render('sidebar')

View File

@ -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

View File

@ -1,16 +1,13 @@
-set_meta_tags :title => [title_object(@group), t('layout.groups.edit')] -set_meta_tags :title => [title_object(@group), t('layout.groups.edit')]
= form_for @group, :html => { :class => :form, :multipart => true } do |f| = form_for @group do |f|
= render :partial => "form", :locals => {:f => f} = render "form", :f => f
.hr .hr
.groups-profile .groups-profile= image_tag('code.png')
= image_tag('code.png') .groups-profile= link_to t("layout.groups.public_profile"), @group
.groups-profile
= link_to t("layout.groups.public_profile"), @group
.both .both
.hr .hr
.leftside .leftside= t("layout.groups.delete_warning")
= t("layout.groups.delete_warning")
.rightside .rightside
= link_to t("layout.delete"), group_path(@group), :method => :delete, :confirm => t("layout.groups.confirm_delete"), :class => 'button' if can? :destroy, @group = link_to t("layout.delete"), group_path(@group), :method => :delete, :confirm => t("layout.groups.confirm_delete"), :class => 'button' if can? :destroy, @group
.both .both

View File

@ -12,4 +12,4 @@
%td= link_to group.name, group_path(group) %td= link_to group.name, group_path(group)
%td.td2= group.description %td.td2= group.description
%td.td5 %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

View File

@ -1,6 +1,6 @@
%h3.bpadding10= title t("layout.groups.new_header") %h3.bpadding10= title t("layout.groups.new_header")
= form_for @group, :url => groups_path do |f| = form_for @group do |f|
= render :partial => "form", :locals => {:f => f} = render "form", :f => f
:javascript :javascript
$('article .all').addClass('bigpadding'); $('article .all').addClass('bigpadding');

View File

@ -5,7 +5,7 @@
%p= @group.description %p= @group.description
%h4= t("layout.groups.projects_list") + ":" %h4= t("layout.groups.projects_list") + ":"
%p %p
- @group.projects.each do |project| - @projects.each do |project|
= link_to project.name, project = link_to project.name, project
%br %br
%br %br

View File

@ -19,7 +19,7 @@
.middle .middle
%menu %menu
.logo= link_to image_tag('logo-mini.png', :alt => 'logo'), root_path .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 .information
= render 'search/form' = render 'search/form'
- if current_user - if current_user
@ -34,7 +34,7 @@
.droplist-wrap .droplist-wrap
#droplist.droplist #droplist.droplist
.a= link_to current_user.uname, current_user .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 .a= link_to t('layout.logout'), destroy_user_session_path, :method => :delete
- else - else
.user .user

View File

@ -1,6 +1,7 @@
- namespace = which_menu == 'admins_menu' ? 'admin_' : ''
%ul %ul
- (collection = t which_menu).each do |base, title| - (collection = t which_menu).each do |base, title|
- if can? :index, base.to_s.classify.constantize - 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' - 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' : ''

View File

@ -13,7 +13,7 @@
= display_meta_tags :site => APP_CONFIG['project_name'], :reverse => true, :separator => '-' = display_meta_tags :site => APP_CONFIG['project_name'], :reverse => true, :separator => '-'
%body %body
-# render :partial => "layouts/flashes" -# render "layouts/flashes"
= yield = yield
= render 'layouts/counters' unless current_user.try(:admin?) = render 'layouts/counters' unless current_user.try(:admin?)

View File

@ -1,4 +1,4 @@
- render :partial => 'tos_sidebar' - render 'tos_sidebar'
.tos .tos
%a{:name => '#'} %a{:name => '#'}

View File

@ -22,8 +22,3 @@
-#- if current_user.owner_of? @platform or current_user.admin? -#- if current_user.owner_of? @platform or current_user.admin?
%li{:class => (act == :index && contr == :private_users) ? 'active' : ''} %li{:class => (act == :index && contr == :private_users) ? 'active' : ''}
= link_to t("layout.platforms.private_users"), platform_private_users_path(@platform) = 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)

View File

@ -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'

View File

@ -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}

View File

@ -6,7 +6,5 @@
%tbody %tbody
- @platforms.each do |platform| - @platforms.each do |platform|
%tr{:class => cycle("odd", "even")} %tr{:class => cycle("odd", "even")}
%td %td= link_to platfrom_printed_name(platform), platform_path(platform)
= link_to platfrom_printed_name(platform), platform_path(platform) %td= platform.distrib_type
%td
= platform.distrib_type

View File

@ -1,6 +1,6 @@
-set_meta_tags :title => [title_object(@platform), t('layout.platforms.clone_header')] -set_meta_tags :title => [title_object(@platform), t('layout.platforms.clone_header')]
= render :partial => 'submenu' = render 'submenu'
= render :partial => 'sidebar' = render 'sidebar'
= form_for @cloned, :url => make_clone_platform_path(@platform), :html => { :class => :form } do |f| = form_for @cloned, :url => make_clone_platform_path(@platform), :html => { :class => :form } do |f|
.leftlist= f.label :name, :class => :label .leftlist= f.label :name, :class => :label

View File

@ -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'

View File

@ -1,4 +1,4 @@
-set_meta_tags :title => t('layout.platforms.list_header') -set_meta_tags :title => t('layout.platforms.list_header')
= link_to t("layout.platforms.new"), new_platform_path, :class => 'button' if can? :create, Platform = 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 = will_paginate @platforms

View File

@ -1,6 +1,6 @@
-set_meta_tags :title => [title_object(@platform), t('layout.platforms.members')] -set_meta_tags :title => [title_object(@platform), t('layout.platforms.members')]
= render :partial => 'submenu' = render 'submenu'
= render :partial => 'sidebar' = render 'sidebar'
= form_tag remove_members_platform_path(@platform), :id => 'members_form', :method => :post do = form_tag remove_members_platform_path(@platform), :id => 'members_form', :method => :post do
%table.tablesorter{:cellpadding => "0", :cellspacing => "0"} %table.tablesorter{:cellpadding => "0", :cellspacing => "0"}

View File

@ -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

View File

@ -1,6 +1,6 @@
-set_meta_tags :title => title_object(@platform) -set_meta_tags :title => title_object(@platform)
= render :partial => 'submenu' = render 'submenu'
= render :partial => 'sidebar' = render 'sidebar'
%h3.fix= "#{t("layout.platforms.about")} #{@platform.name}" %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 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 = 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 'connection_info' if @platform.platform_type == 'personal' and @platform.visibility == 'open'
= render :partial => 'connection_info'

View File

@ -1,5 +1,4 @@
-set_meta_tags :title => t('.title') -set_meta_tags :title => t('.title')
/ #myTable
%table.tablesorter{:cellpadding => "0", :cellspacing => "0"} %table.tablesorter{:cellpadding => "0", :cellspacing => "0"}
%thead %thead
%tr %tr
@ -10,10 +9,10 @@
-#%th.lpadding16= t("activerecord.attributes.product_build_list.user") -#%th.lpadding16= t("activerecord.attributes.product_build_list.user")
%th= t("layout.product_build_lists.action") %th= t("layout.product_build_lists.action")
%th.lpadding16= t("activerecord.attributes.product_build_list.notified_at") %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 .both
= will_paginate @product_build_lists = will_paginate @product_build_lists
= render 'product_build_lists/filter' = render 'filter'
= render 'build_lists/submenu' = render 'projects/build_lists/submenu'

View File

@ -35,7 +35,7 @@
.rightlist= f.check_box :delete_tar .rightlist= f.check_box :delete_tar
.both .both
= render :partial => "products/crontab", :locals => { :form => f } = render "crontab", :form => f
.both .both
.button_block .button_block

View File

@ -1,6 +1,6 @@
-set_meta_tags :title => [title_object(@product), t('title_editing')] -set_meta_tags :title => [title_object(@product), t('title_editing')]
= render :partial => 'platforms/submenu' = render 'submenu'
= render :partial => 'platforms/sidebar' = render 'sidebar'
%h3 %h3
= t("layout.products.edit_header") = t("layout.products.edit_header")
@ -8,5 +8,5 @@
%br %br
= form_for [@platform, @product], :html => { :class => :form, :multipart => true } do |f| = form_for [@platform, @product], :html => { :class => :form, :multipart => true } do |f|
= render :partial => "form", :locals => {:f => f} = render "form", :f => f

View File

@ -1,7 +1,7 @@
-set_meta_tags :title => [title_object(@platform), t('layout.products.list_header')] -set_meta_tags :title => [title_object(@platform), t('layout.products.list_header')]
= render :partial => 'platforms/submenu' if params[:platform_id] = render 'submenu' if params[:platform_id]
= render :partial => 'platforms/sidebar' 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 = 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 = will_paginate @products

View File

@ -1,7 +1,6 @@
-set_meta_tags :title => [title_object(@platform), t('layout.products.new')] -set_meta_tags :title => [title_object(@platform), t('layout.products.new')]
= render :partial => 'platforms/submenu' = render 'submenu'
= render :partial => 'platforms/sidebar' = render 'sidebar'
= form_for [@platform, @product], :html => { :class => :form, :multipart => true } do |f| = form_for [@platform, @product], :html => { :class => :form, :multipart => true } do |f|
= render :partial => "form", :locals => {:f => f} = render "form", :f => f

View File

@ -1,6 +1,6 @@
-set_meta_tags :title => title_object(@product) -set_meta_tags :title => title_object(@product)
= render :partial => 'platforms/submenu' = render 'submenu'
= render :partial => 'platforms/sidebar' = render 'sidebar'
%h3 #{t("layout.products.about")} #{@product.name} %h3 #{t("layout.products.about")} #{@product.name}
@ -25,4 +25,4 @@
%th= t("layout.product_build_lists.product") %th= t("layout.product_build_lists.product")
%th= t("layout.product_build_lists.action") %th= t("layout.product_build_lists.action")
%th= t("activerecord.attributes.product_build_list.notified_at") %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

Some files were not shown because too many files have changed in this diff Show More