From e64a174968fc58929e862f8214e700f26ecaa3c0 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 5 Feb 2012 21:26:04 +0200 Subject: [PATCH] project membership widget. css fixes --- app/assets/stylesheets/reset_bootstrap.scss | 4 ++ app/controllers/projects_controller.rb | 1 + app/models/users_project.rb | 8 ++++ app/views/devise/sessions/new.html.erb | 2 +- .../layouts/_project_side_right.html.haml | 42 +------------------ app/views/widgets/_project_member.html.haml | 28 +++++++++++++ app/views/widgets/_recent_projects.html.haml | 10 +++++ 7 files changed, 54 insertions(+), 41 deletions(-) create mode 100644 app/views/widgets/_project_member.html.haml create mode 100644 app/views/widgets/_recent_projects.html.haml diff --git a/app/assets/stylesheets/reset_bootstrap.scss b/app/assets/stylesheets/reset_bootstrap.scss index 4a413fb29b9..c52cf67022b 100644 --- a/app/assets/stylesheets/reset_bootstrap.scss +++ b/app/assets/stylesheets/reset_bootstrap.scss @@ -36,3 +36,7 @@ a { } } +.widget { + padding:20px; + margin-bottom:20px; +} diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 7f9e6866d89..6530f47eeed 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -96,6 +96,7 @@ class ProjectsController < ApplicationController end def graph + render_full_content @days_json, @commits_json = GraphCommit.to_graph(project) end diff --git a/app/models/users_project.rb b/app/models/users_project.rb index b98aa1fded4..2d09fa74ec5 100644 --- a/app/models/users_project.rb +++ b/app/models/users_project.rb @@ -32,6 +32,14 @@ class UsersProject < ActiveRecord::Base c.update_project(project.path, project) end end + + def project_access_human + Project.access_options.key(self.project_access) + end + + def repo_access_human + Repository.access_options.key(self.repo_access) + end end # == Schema Information # diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index c110eee315d..9fe627d3589 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -4,7 +4,7 @@ <%= f.password_field :password, :class => "text bottom", :placeholder => "Password" %> <% if devise_mapping.rememberable? -%> -
<%= f.label :remember_me %><%= f.check_box :remember_me %>
+
<%= f.label :remember_me %>   <%= f.check_box :remember_me %>
<% end -%>
<%= f.submit "Sign in", :class => "primary btn" %> diff --git a/app/views/layouts/_project_side_right.html.haml b/app/views/layouts/_project_side_right.html.haml index 841f549844e..cc4e6b14260 100644 --- a/app/views/layouts/_project_side_right.html.haml +++ b/app/views/layouts/_project_side_right.html.haml @@ -4,43 +4,5 @@ - else - if content_for? :sidebar_top_block = yield :sidebar_top_block - - else - - if can? current_user, :write_project, @project - .alert-message.block-message.info - You have access to create new issue or merge request. - %div - = link_to new_project_issue_path(@project), :title => "New Issue", :class => "btn small" do - New Issue » - %div - = link_to new_project_merge_request_path(@project), :title => "New Merge Request", :class => "btn small" do - New Merge Request » - - - if current_user.projects.count > 0 - %div.entry - %h5 - Recent Projects: - %ul - - current_user.projects.order("id DESC").limit(5).each do |project| - %li - = link_to project_path(project) do - = project.name - = link_to "More » ", projects_path - - -#%h4 - -#Recent Issues: - -#%ul - -#- current_user.assigned_issues.order("id DESC").limit(5).each do |issue| - -#%li - -#= link_to project_issue_path(issue.project, issue) do - -#= truncate issue.title - - - -#%h4 - -#Recent Requests: - -#%ul - -#- current_user.assigned_merge_requests.order("id DESC").limit(5).each do |issue| - -#%li - -#= link_to project_merge_request_path(issue.project, issue) do - -#= truncate issue.title - - + = render "widgets/project_member" + = render "widgets/recent_projects" diff --git a/app/views/widgets/_project_member.html.haml b/app/views/widgets/_project_member.html.haml new file mode 100644 index 00000000000..1af911120de --- /dev/null +++ b/app/views/widgets/_project_member.html.haml @@ -0,0 +1,28 @@ +- member = @project.team_member_by_id(current_user.id) +.widget + .media-grid + %li + = link_to project_team_member_path(@project, member), :title => current_user.name do + = image_tag gravatar_icon(current_user.email, 90), :class => "thumbnail" + .row + .span4 + %h4 + = truncate(current_user.name, :lenght => 24) + - if @project.owner == current_user + %span.label Project Owner + + .span3 + %span.label= member.project_access_human + %span.label= member.repo_access_human + + - if can? current_user, :write_project, @project + %hr + .span3 + %p You have access to create new issue or merge request. + %div + = link_to new_project_issue_path(@project), :title => "New Issue", :class => "" do + New Issue » + %div + = link_to new_project_merge_request_path(@project), :title => "New Merge Request", :class => "" do + New Merge Request » + diff --git a/app/views/widgets/_recent_projects.html.haml b/app/views/widgets/_recent_projects.html.haml new file mode 100644 index 00000000000..394aa1ad8ca --- /dev/null +++ b/app/views/widgets/_recent_projects.html.haml @@ -0,0 +1,10 @@ +- if current_user.projects.count > 0 + %div.widget + %h4 + Recent Projects: + %ul + - current_user.projects.order("id DESC").limit(5).each do |project| + %li + = link_to project_path(project) do + = project.name + = link_to "More » ", projects_path