From 9f4fde04f5b74199c9bd72621e03c544aaf6f2ef Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 3 Apr 2013 18:36:37 +0300 Subject: [PATCH] Dont show project limit sidebar if user can own 100+ more projects --- app/models/user.rb | 6 +++++- app/views/profiles/show.html.haml | 21 +++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index dcbf581..4559363 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -325,9 +325,13 @@ class User < ActiveRecord::Base MergeRequest.cared(self) end + def projects_limit_left + projects_limit - owned_projects.count + end + def projects_limit_percent return 100 if projects_limit.zero? - (personal_projects.count.to_f / projects_limit) * 100 + (owned_projects.count.to_f / projects_limit) * 100 end def recent_push project_id = nil diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index 9cab3ba..f63729f 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -73,16 +73,17 @@ Want to share a team between projects? = link_to new_team_path, class: "btn btn-tiny" do Create a team - %fieldset - %legend - Personal projects: - %small.pull-right - %span= current_user.owned_projects.count - of - %span= current_user.projects_limit - .padded - .progress - .bar{style: "width: #{current_user.projects_limit_percent}%;"} + - unless current_user.projects_limit_left > 100 + %fieldset + %legend + Owned projects: + %small.pull-right + %span= current_user.owned_projects.count + of + %span= current_user.projects_limit + .padded + .progress + .bar{style: "width: #{current_user.projects_limit_percent}%;"} %fieldset %legend -- libgit2 0.21.2