Skip to content

Commit

Permalink
Merge pull request #62 from Navinnair/master
Browse files Browse the repository at this point in the history
locked carrierwave version to fix image upload issue and fixed member count issue
  • Loading branch information
stpnlr authored May 27, 2019
2 parents 523ab37 + 53994c2 commit 503c7a4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ gem "therubyracer"
gem "foundation-rails",'5.2.1.0'
gem 'hirb'
gem 'thin'
gem 'carrierwave'
gem 'carrierwave', '1.0'
gem "mini_magick"
gem "select2-rails", '3.5.4'
#gem "cancan"
Expand Down
7 changes: 1 addition & 6 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@ def update
# DELETE /users/1
# DELETE /users/1.json
def destroy
if @user.update_attribute(:is_deleted, true)
@user.project_managers.update_all(:status => 'archived')
@user.team_members.update_all(:status => 'archived')
@user.reporting_managers.update_all(:status => 'archived')
@user.reporting_employees.update_all(:status => 'archived')
end
@user.archive_user
respond_to do |format|
format.html { redirect_to users_url }
format.json { head :no_content }
Expand Down
2 changes: 1 addition & 1 deletion app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Project < ActiveRecord::Base
has_many :project_managers
has_many :users,:through=>:project_managers,:after_remove => :update_user_project_count
has_many :team_members, :through => :teams
has_many :project_members, :through=>:team_members, :source=>:user
has_many :project_members, -> { uniq }, :through => :team_members, :source => :user
scope :active, -> {where(is_deleted: false)}

validates_presence_of :name, :code
Expand Down
4 changes: 2 additions & 2 deletions app/models/team_member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TeamMember < ActiveRecord::Base

def update_member_counts
user.update_attributes(:admin_teams_count=>user.admin_teams.count) if self.role == 'lead'
team.update_attributes(:members_count=>team.users.active.count,:managers_count=>team.team_leads.active.count)
team.project.update_attributes(:member_count=>team.project.project_members.active.count)
team.update_attributes(:members_count=>team.members.count,:managers_count=>team.team_leads.active.count)
team.project.update_attribute(:member_count, team.project.project_members.active.count)
end
end
11 changes: 10 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class User < ActiveRecord::Base
has_many :project_managers
has_many :projects, :through => :project_managers
has_many :team_members
has_many :teams, :through => :team_members
has_many :teams, -> { uniq }, :through => :team_members
has_many :admin_teams, :through => :projects, :source => :teams
has_many :leads, -> { where role: 'lead' }, class_name: 'TeamMember'
has_many :admin_teams, :through => :leads, :source => :team #,:foreign_key=>'user_id'
Expand Down Expand Up @@ -110,5 +110,14 @@ def ensure_manager_exists
end
end
end

def archive_user
if self.update_attribute(:is_deleted, true)
project_managers.update_all(:status => 'archived')
team_members.each{|tm| tm.update_attribute(:status, 'archived')}
reporting_managers.update_all(:status => 'archived')
reporting_employees.update_all(:status => 'archived')
end
end

end

0 comments on commit 503c7a4

Please sign in to comment.