Commit 9f4fde04 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

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

parent d61a21d2
...@@ -325,9 +325,13 @@ class User < ActiveRecord::Base ...@@ -325,9 +325,13 @@ class User < ActiveRecord::Base
MergeRequest.cared(self) MergeRequest.cared(self)
end end
def projects_limit_left
projects_limit - owned_projects.count
end
def projects_limit_percent def projects_limit_percent
return 100 if projects_limit.zero? return 100 if projects_limit.zero?
(personal_projects.count.to_f / projects_limit) * 100 (owned_projects.count.to_f / projects_limit) * 100
end end
def recent_push project_id = nil def recent_push project_id = nil
......
...@@ -73,16 +73,17 @@ ...@@ -73,16 +73,17 @@
Want to share a team between projects? Want to share a team between projects?
= link_to new_team_path, class: "btn btn-tiny" do = link_to new_team_path, class: "btn btn-tiny" do
Create a team Create a team
%fieldset - unless current_user.projects_limit_left > 100
%legend %fieldset
Personal projects: %legend
%small.pull-right Owned projects:
%span= current_user.owned_projects.count %small.pull-right
of %span= current_user.owned_projects.count
%span= current_user.projects_limit of
.padded %span= current_user.projects_limit
.progress .padded
.bar{style: "width: #{current_user.projects_limit_percent}%;"} .progress
.bar{style: "width: #{current_user.projects_limit_percent}%;"}
%fieldset %fieldset
%legend %legend
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment