Commit 9f4fde04f5b74199c9bd72621e03c544aaf6f2ef

Authored by Dmitriy Zaporozhets
1 parent d61a21d2

Dont show project limit sidebar if user can own 100+ more projects

app/models/user.rb
@@ -325,9 +325,13 @@ class User < ActiveRecord::Base @@ -325,9 +325,13 @@ class User < ActiveRecord::Base
325 MergeRequest.cared(self) 325 MergeRequest.cared(self)
326 end 326 end
327 327
  328 + def projects_limit_left
  329 + projects_limit - owned_projects.count
  330 + end
  331 +
328 def projects_limit_percent 332 def projects_limit_percent
329 return 100 if projects_limit.zero? 333 return 100 if projects_limit.zero?
330 - (personal_projects.count.to_f / projects_limit) * 100 334 + (owned_projects.count.to_f / projects_limit) * 100
331 end 335 end
332 336
333 def recent_push project_id = nil 337 def recent_push project_id = nil
app/views/profiles/show.html.haml
@@ -73,16 +73,17 @@ @@ -73,16 +73,17 @@
73 Want to share a team between projects? 73 Want to share a team between projects?
74 = link_to new_team_path, class: "btn btn-tiny" do 74 = link_to new_team_path, class: "btn btn-tiny" do
75 Create a team 75 Create a team
76 - %fieldset  
77 - %legend  
78 - Personal projects:  
79 - %small.pull-right  
80 - %span= current_user.owned_projects.count  
81 - of  
82 - %span= current_user.projects_limit  
83 - .padded  
84 - .progress  
85 - .bar{style: "width: #{current_user.projects_limit_percent}%;"} 76 + - unless current_user.projects_limit_left > 100
  77 + %fieldset
  78 + %legend
  79 + Owned projects:
  80 + %small.pull-right
  81 + %span= current_user.owned_projects.count
  82 + of
  83 + %span= current_user.projects_limit
  84 + .padded
  85 + .progress
  86 + .bar{style: "width: #{current_user.projects_limit_percent}%;"}
86 87
87 %fieldset 88 %fieldset
88 %legend 89 %legend