diff --git a/app/controllers/recordings_controller.rb b/app/controllers/recordings_controller.rb index 3fb912fe27a14d3c1d269d703c0c1aa8cd04b3bb..5c5a561e635e5f716c2186d92aebe6897a6daa26 100644 --- a/app/controllers/recordings_controller.rb +++ b/app/controllers/recordings_controller.rb @@ -150,6 +150,22 @@ class RecordingsController < ApplicationController :page => cookies[:recording_page] end + def give + recording = Recording.find(params[:id]) + user = User.find(params[:user_id]) + if user.nil? + logger.add(Logger::DEBUG, "User to give to not found") + return + end + + recording.user_id = user.id + recording.save! + rec_id = recording["when"].strftime("%Y-%m-%d %H:%M:%S") + flash[:notice] = 'Recording ' + rec_id + ' given to ' + user.username + '.' + redirect_to :action => cookies[:recording_goal], + :page => cookies[:recording_page] + end + def archive recording = Recording.find(params[:id]) user_id = cookies[:user_id] diff --git a/app/views/recordings/_list.rhtml b/app/views/recordings/_list.rhtml index 9c37cbe8b1c2de9f26022a26e4b5b464f90baf1a..9ae62099ac1d1f7de0ac047a5f97888810b1a20e 100644 --- a/app/views/recordings/_list.rhtml +++ b/app/views/recordings/_list.rhtml @@ -9,7 +9,8 @@ <table border="1"> <tr> - <th colspan="3"> </th> + <th colspan="3">Action</th> + <th>Give to</th> <% for column_name in sorted_columns %> <th><%= Recording.columns_hash[column_name].human_name %></th> <%end%> @@ -41,6 +42,24 @@ </form> <% end %> </td> + <td> + <% give_printed = false %> + <% for user in User.find(:all) %> + <% if user.id != @owner.id && user.id != recording.user_id %> + <form class="actionform" method="post" + action="<%= url_for :controller=>"recordings", + :action=>"give" %>" > + <input type="hidden" name="id" value="<%= recording.id %>" /> + <input type="hidden" name="user_id" value="<%= user.id %>" /> + <input type="submit" value="<%=h user.username %>" /> + </form> + <% give_printed = true %> + <% end %> + <% end %> + <% if !give_printed %> + + <% end %> + </td> <% for column_name in sorted_columns %> <td> @@ -49,6 +68,12 @@ <%= recording["when"].strftime("%Y-%m-%d %H:%M:%S") %> <% when "length": %> <%= (10*recording["length"].to_f).round / 10.0 %> + <% when "user_id": %> + <% if recording.user.nil? %> + + <% else %> + <%=h recording.user.username %> + <% end %> <% else %> <% if recording[column_name].to_s != "" %> <%=h recording.send(column_name) %>