diff --git a/app/controllers/internal/users_controller.rb b/app/controllers/internal/users_controller.rb index 2de04dcc5..17d21086b 100644 --- a/app/controllers/internal/users_controller.rb +++ b/app/controllers/internal/users_controller.rb @@ -41,6 +41,7 @@ class Internal::UsersController < Internal::ApplicationController @new_mentor = user_params[:add_mentor] make_matches add_note if user_params[:new_note] + add_credits if user_params[:add_credits] if user_params[:quick_match] redirect_to "/internal/users/unmatched_mentee" else @@ -58,6 +59,15 @@ class Internal::UsersController < Internal::ApplicationController ) end + def add_credits + amount = user_params[:add_credits].to_i + credit_objects = [] + amount.times do + credit_objects << Credit.new(user_id: @user.id) + end + Credit.import credit_objects + end + def user_status @user = User.find(params[:id]) begin @@ -127,6 +137,7 @@ class Internal::UsersController < Internal::ApplicationController :user_status, :toggle_mentorship, :pro, - :merge_user_id) + :merge_user_id, + :add_credits) end end diff --git a/app/models/user.rb b/app/models/user.rb index 901120530..18985d726 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,7 +1,7 @@ class User < ApplicationRecord include CloudinaryHelper - attr_accessor :scholar_email, :new_note, :quick_match, :mentorship_note, :note_for_current_role, :add_mentor, :add_mentee, :user_status, :toggle_mentorship, :pro, :merge_user_id + attr_accessor :scholar_email, :new_note, :quick_match, :mentorship_note, :note_for_current_role, :add_mentor, :add_mentee, :user_status, :toggle_mentorship, :pro, :merge_user_id, :add_credits rolify include AlgoliaSearch diff --git a/app/views/internal/users/_activity.erb b/app/views/internal/users/_activity.erb index f6c06a835..24b6bb38c 100644 --- a/app/views/internal/users/_activity.erb +++ b/app/views/internal/users/_activity.erb @@ -1,5 +1,5 @@
-

Activity:

+

Activity

<%= render "activity" %> +<%= render "credits" %>

Mentorship

<% if @user.mentors.count > 0 %>