Commit 96d97c4857cd2497108c8e5740ac8134cd439546
1 parent
70690e19
Exists in
master
and in
4 other branches
Fix routing. Finalize user show page
Showing
5 changed files
with
31 additions
and
14 deletions
Show diff stats
app/controllers/users_controller.rb
| 1 | class UsersController < ApplicationController | 1 | class UsersController < ApplicationController |
| 2 | def show | 2 | def show |
| 3 | - @user = User.find_by_username(params[:username]) | 3 | + @user = User.find_by_username!(params[:username]) |
| 4 | @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id)) | 4 | @projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id)) |
| 5 | @events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20) | 5 | @events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20) |
| 6 | end | 6 | end |
app/models/team.rb
| @@ -21,6 +21,10 @@ class Team | @@ -21,6 +21,10 @@ class Team | ||
| 21 | end | 21 | end |
| 22 | end | 22 | end |
| 23 | 23 | ||
| 24 | + def get_tm user_id | ||
| 25 | + project.users_projects.find_by_user_id(user_id) | ||
| 26 | + end | ||
| 27 | + | ||
| 24 | def add_user(user, access) | 28 | def add_user(user, access) |
| 25 | add_users_ids([user.id], access) | 29 | add_users_ids([user.id], access) |
| 26 | end | 30 | end |
| @@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
| 1 | +.ui-box | ||
| 2 | + %h5.title Projects | ||
| 3 | + %ul.well-list | ||
| 4 | + - @projects.each do |project| | ||
| 5 | + %li | ||
| 6 | + = link_to project_path(project), class: dom_class(project) do | ||
| 7 | + - if project.namespace | ||
| 8 | + = project.namespace.human_name | ||
| 9 | + \/ | ||
| 10 | + %strong.well-title | ||
| 11 | + = truncate(project.name, length: 45) | ||
| 12 | + %span.right.light | ||
| 13 | + - if project.owner == @user | ||
| 14 | + %i.icon-wrench | ||
| 15 | + - tm = project.team.get_tm(@user.id) | ||
| 16 | + - if tm | ||
| 17 | + = tm.project_access_human | ||
| 18 | +%p.light | ||
| 19 | + %i.icon-wrench | ||
| 20 | + – user is a project owner |
app/views/users/show.html.haml
| @@ -3,7 +3,10 @@ | @@ -3,7 +3,10 @@ | ||
| 3 | %h3.page_title | 3 | %h3.page_title |
| 4 | = image_tag gravatar_icon(@user.email, 90), class: "avatar s90" | 4 | = image_tag gravatar_icon(@user.email, 90), class: "avatar s90" |
| 5 | = @user.name | 5 | = @user.name |
| 6 | - %span.light (@#{@user.username}) | 6 | + %br |
| 7 | + %small @#{@user.username} | ||
| 8 | + %br | ||
| 9 | + %small member since #{@user.created_at.stamp("Nov 12, 2031")} | ||
| 7 | .clearfix | 10 | .clearfix |
| 8 | %hr | 11 | %hr |
| 9 | %h5 Recent events | 12 | %h5 Recent events |
| @@ -31,14 +34,4 @@ | @@ -31,14 +34,4 @@ | ||
| 31 | %li | 34 | %li |
| 32 | %strong Bio | 35 | %strong Bio |
| 33 | %span.right= @user.bio | 36 | %span.right= @user.bio |
| 34 | - .ui-box | ||
| 35 | - %h5.title Projects | ||
| 36 | - %ul.well-list | ||
| 37 | - - @projects.each do |project| | ||
| 38 | - %li | ||
| 39 | - = link_to project_path(project), class: dom_class(project) do | ||
| 40 | - - if project.namespace | ||
| 41 | - = project.namespace.human_name | ||
| 42 | - \/ | ||
| 43 | - %strong.well-title | ||
| 44 | - = truncate(project.name, length: 45) | 37 | + = render 'projects' |
config/routes.rb
| @@ -97,7 +97,7 @@ Gitlab::Application.routes.draw do | @@ -97,7 +97,7 @@ Gitlab::Application.routes.draw do | ||
| 97 | end | 97 | end |
| 98 | 98 | ||
| 99 | resources :keys | 99 | resources :keys |
| 100 | - match "/u/:username" => "users#show", as: :user | 100 | + match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ } |
| 101 | 101 | ||
| 102 | 102 | ||
| 103 | 103 |