From c7fda1a810bcfe032f60287818e1078059754187 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 2 Oct 2012 19:14:08 +0400 Subject: [PATCH] #349: updated ability model according to Alexander comments, reverted some changes, added paging for projects on #show page --- app/assets/stylesheets/design/main.scss | 39 +++++++++++--------- app/controllers/groups/profile_controller.rb | 7 ++-- app/controllers/users/profile_controller.rb | 4 +- app/models/ability.rb | 3 ++ app/models/project.rb | 2 +- app/views/groups/profile/show.html.haml | 14 ++----- app/views/users/profile/show.html.haml | 22 ++--------- 7 files changed, 38 insertions(+), 53 deletions(-) diff --git a/app/assets/stylesheets/design/main.scss b/app/assets/stylesheets/design/main.scss index 98b5d3a06..a0e76e21f 100644 --- a/app/assets/stylesheets/design/main.scss +++ b/app/assets/stylesheets/design/main.scss @@ -362,27 +362,30 @@ article div.all.verybigpadding { width: 545px; padding: 0px 40px 20px 200px; text-align: left; -} -article div.all.verybigpadding div.left { - float: left; + .info, .avatar { + display: inline-block; + } + .avatar { margin: 0 20px 20px 0; } + .info { + width: 380px; + } + .content { + width: 550px; + display: inline-block; + .pagination { position: absolute; } + } + img { + padding-right: 40px; + margin-top: 20px; + } + h3, h4, p { width: 420px; } + tmargin5 { + padding-top: 5px; + position: relative; + } } -article div.all.verybigpadding div.left img{ - padding-right: 40px; - margin-top: 20px; -} - -article div.all.verybigpadding div.left h3, article div.all.verybigpadding div.left h4, article div.all.verybigpadding div.left p{ - width: 420px; -} - -article div.all.verybigpadding div.left .tmargin5 { - padding-top: 5px; - position: relative; -} - - /* Left part of page markup */ aside div.bordered { diff --git a/app/controllers/groups/profile_controller.rb b/app/controllers/groups/profile_controller.rb index 624fcf600..16537806b 100644 --- a/app/controllers/groups/profile_controller.rb +++ b/app/controllers/groups/profile_controller.rb @@ -1,7 +1,6 @@ # -*- encoding : utf-8 -*- class Groups::ProfileController < Groups::BaseController - load_and_authorize_resource :class => Group, :instance_name => 'group', :except => :show - load_resource :class => Group, :instance_name => 'group', :only => :show + load_and_authorize_resource :class => Group, :instance_name => 'group' skip_before_filter :authenticate_user!, :only => :show if APP_CONFIG['anonymous_access'] autocomplete :group, :uname @@ -12,7 +11,9 @@ class Groups::ProfileController < Groups::BaseController end def show - @projects = @group.projects.by_visibilities(['open']) + @projects = @group.projects.by_visibilities(['open']). + search(params[:search]).search_order. + paginate(:page => params[:page], :per_page => 25) end def new diff --git a/app/controllers/users/profile_controller.rb b/app/controllers/users/profile_controller.rb index 5bd9c3d0d..4555d2266 100644 --- a/app/controllers/users/profile_controller.rb +++ b/app/controllers/users/profile_controller.rb @@ -4,6 +4,8 @@ class Users::ProfileController < Users::BaseController skip_before_filter :authenticate_user!, :only => :show if APP_CONFIG['anonymous_access'] def show - @projects = @user.projects.by_visibilities(['open']) + @projects = @user.projects.by_visibilities(['open']). + search(params[:search]).search_order. + paginate(:page => params[:page], :per_page => 25) end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 6e222702c..f3ffb9e2e 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -31,6 +31,9 @@ class Ability can [:read, :projects_list], Repository, :platform => {:visibility => 'open'} can :read, Product, :platform => {:visibility => 'open'} + can :show, Group + can :show, User + if user.guest? # Guest rights # can [:new, :create], RegisterRequest else # Registered user rights diff --git a/app/models/project.rb b/app/models/project.rb index be0967e3b..81f9080e8 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -37,7 +37,7 @@ class Project < ActiveRecord::Base scope :recent, order("name ASC") scope :search_order, order("CHAR_LENGTH(name) ASC") scope :search, lambda {|q| by_name("%#{q.to_s.strip}%")} - scope :by_name, lambda {|name| where('projects.name ILIKE ?', name)} + scope :by_name, lambda {|name| where('projects.name ILIKE ?', name) if name.present?} scope :by_visibilities, lambda {|v| where(:visibility => v)} scope :opened, where(:visibility => 'open') scope :package, where(:is_package => true) diff --git a/app/views/groups/profile/show.html.haml b/app/views/groups/profile/show.html.haml index a67abf0e8..890b9c2c9 100644 --- a/app/views/groups/profile/show.html.haml +++ b/app/views/groups/profile/show.html.haml @@ -1,12 +1,4 @@ -set_meta_tags :title => title_object(@group) -.all.verybigpadding - %h3= @group.name - %h4= t("activerecord.attributes.group.description") + ":" - %p= @group.description - %h4= t("layout.groups.public_projects_list") + ":" - %p - - @projects.each do |project| - = link_to project.name, project - %br - %br - = link_to t("layout.edit"), edit_group_path(@group), :class => 'button' if can? :edit, @group + +- edit_link = can?(:edit, @group) ? link_to(t("layout.edit"), edit_group_path(@group), :class => 'button') : nil += render 'shared/profile', :uname => @group.name, :group => @group, :search_path => group_path, :projects => @projects, :edit_link => edit_link diff --git a/app/views/users/profile/show.html.haml b/app/views/users/profile/show.html.haml index 3ab79e99f..0dca78c81 100644 --- a/app/views/users/profile/show.html.haml +++ b/app/views/users/profile/show.html.haml @@ -1,20 +1,4 @@ -.left - = image_tag avatar_url(@user, :big) - %br - = 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 - = mail_to @user.email, @user.email, :encode => "javascript" - %br - %h4= t("activerecord.attributes.user.professional_experience") + ":" - %p= @user.professional_experience - %h4= t("layout.users.public_projects_list") + ":" - %p - - @projects.each do |project| - = link_to project.name, project - %br +-set_meta_tags :title => title_object(@user) -:javascript - $('article .all').addClass('verybigpadding'); +- edit_link = can?(:edit, @user) ? link_to(t("layout.users.settings"), current_user == @user ? profile_settings_path : edit_admin_user_path(@user), :class => 'button width81') : nil += render 'shared/profile', :uname => @user.uname, :name => @user.name, :user => @user, :search_path => user_path, :projects => @projects, :edit_link => edit_link, :avatar_url => avatar_url(@user, :big) \ No newline at end of file