summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-22 19:45:13 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-22 19:45:13 +0200
commit96d97c4857cd2497108c8e5740ac8134cd439546 (patch)
treef8a3ab0b20ee989948b49646fce52df9b844a01f /app
parent70690e1971f6d009da9a37782764ae7446f69636 (diff)
downloadgitlab-ce-96d97c4857cd2497108c8e5740ac8134cd439546.tar.gz
Fix routing. Finalize user show page
Diffstat (limited to 'app')
-rw-r--r--app/controllers/users_controller.rb2
-rw-r--r--app/models/team.rb4
-rw-r--r--app/views/users/_projects.html.haml20
-rw-r--r--app/views/users/show.html.haml17
4 files changed, 30 insertions, 13 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 4d106dc7a21..e027057fe65 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,6 +1,6 @@
class UsersController < ApplicationController
def show
- @user = User.find_by_username(params[:username])
+ @user = User.find_by_username!(params[:username])
@projects = @user.authorized_projects.where('projects.id in (?)', current_user.authorized_projects.map(&:id))
@events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20)
end
diff --git a/app/models/team.rb b/app/models/team.rb
index f235d20ebdb..51f4ff68d7b 100644
--- a/app/models/team.rb
+++ b/app/models/team.rb
@@ -21,6 +21,10 @@ class Team
end
end
+ def get_tm user_id
+ project.users_projects.find_by_user_id(user_id)
+ end
+
def add_user(user, access)
add_users_ids([user.id], access)
end
diff --git a/app/views/users/_projects.html.haml b/app/views/users/_projects.html.haml
new file mode 100644
index 00000000000..f46a0ed1161
--- /dev/null
+++ b/app/views/users/_projects.html.haml
@@ -0,0 +1,20 @@
+.ui-box
+ %h5.title Projects
+ %ul.well-list
+ - @projects.each do |project|
+ %li
+ = link_to project_path(project), class: dom_class(project) do
+ - if project.namespace
+ = project.namespace.human_name
+ \/
+ %strong.well-title
+ = truncate(project.name, length: 45)
+ %span.right.light
+ - if project.owner == @user
+ %i.icon-wrench
+ - tm = project.team.get_tm(@user.id)
+ - if tm
+ = tm.project_access_human
+%p.light
+ %i.icon-wrench
+ &ndash; user is a project owner
diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml
index 613ff358a87..2a77c6bfa3d 100644
--- a/app/views/users/show.html.haml
+++ b/app/views/users/show.html.haml
@@ -3,7 +3,10 @@
%h3.page_title
= image_tag gravatar_icon(@user.email, 90), class: "avatar s90"
= @user.name
- %span.light (@#{@user.username})
+ %br
+ %small @#{@user.username}
+ %br
+ %small member since #{@user.created_at.stamp("Nov 12, 2031")}
.clearfix
%hr
%h5 Recent events
@@ -31,14 +34,4 @@
%li
%strong Bio
%span.right= @user.bio
- .ui-box
- %h5.title Projects
- %ul.well-list
- - @projects.each do |project|
- %li
- = link_to project_path(project), class: dom_class(project) do
- - if project.namespace
- = project.namespace.human_name
- \/
- %strong.well-title
- = truncate(project.name, length: 45)
+ = render 'projects'