Add credit form to internal/users (#2581)
* add credit form to internal users * add missing file whoooops
This commit is contained in:
parent
158c398df4
commit
0383873070
5 changed files with 26 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<div class="row">
|
||||
<h3><u>Activity:</u></h3>
|
||||
<h3><u>Activity</u></h3>
|
||||
<ul>
|
||||
<li><%= @user.comments.size %> comments</li>
|
||||
<li><%= @user.articles.size %> articles</li>
|
||||
|
|
|
|||
11
app/views/internal/users/_credits.erb
Normal file
11
app/views/internal/users/_credits.erb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<div class="row">
|
||||
<h3><u>Credits</u></h3>
|
||||
<p>Avaiable Credits: <%= @user.credits.where(spent: false).size %></p>
|
||||
<%= form_for [:internal, @user] do |f| %>
|
||||
<%= f.label "Add Credit(s): " %>
|
||||
<br>
|
||||
<%= f.text_field :add_credits %>
|
||||
<br>
|
||||
<%= f.submit "Add Credits" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
@ -42,6 +42,7 @@
|
|||
</dl>
|
||||
</div>
|
||||
<%= render "activity" %>
|
||||
<%= render "credits" %>
|
||||
<div class="row">
|
||||
<h3><u>Mentorship</u></h3>
|
||||
<% if @user.mentors.count > 0 %>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue