#349: updated ability model according to Alexander comments, reverted some changes, added paging for projects on #show page

This commit is contained in:
Vokhmin Alexey V 2012-10-02 19:14:08 +04:00
parent 8d8aaa9e3b
commit c7fda1a810
7 changed files with 38 additions and 53 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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