Skip to content
Snippets Groups Projects
Commit cbb990a2 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Added ability to give recordings to users.

parent 08c55bdf
Branches master
No related tags found
No related merge requests found
...@@ -150,6 +150,22 @@ class RecordingsController < ApplicationController ...@@ -150,6 +150,22 @@ class RecordingsController < ApplicationController
:page => cookies[:recording_page] :page => cookies[:recording_page]
end 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&nbsp;%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 def archive
recording = Recording.find(params[:id]) recording = Recording.find(params[:id])
user_id = cookies[:user_id] user_id = cookies[:user_id]
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
<table border="1"> <table border="1">
<tr> <tr>
<th colspan="3">&nbsp;</th> <th colspan="3">Action</th>
<th>Give to</th>
<% for column_name in sorted_columns %> <% for column_name in sorted_columns %>
<th><%= Recording.columns_hash[column_name].human_name %></th> <th><%= Recording.columns_hash[column_name].human_name %></th>
<%end%> <%end%>
...@@ -41,6 +42,24 @@ ...@@ -41,6 +42,24 @@
</form> </form>
<% end %> <% end %>
</td> </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 %>
&nbsp;
<% end %>
</td>
<% for column_name in sorted_columns %> <% for column_name in sorted_columns %>
<td> <td>
...@@ -49,6 +68,12 @@ ...@@ -49,6 +68,12 @@
<%= recording["when"].strftime("%Y-%m-%d&nbsp;%H:%M:%S") %> <%= recording["when"].strftime("%Y-%m-%d&nbsp;%H:%M:%S") %>
<% when "length": %> <% when "length": %>
<%= (10*recording["length"].to_f).round / 10.0 %> <%= (10*recording["length"].to_f).round / 10.0 %>
<% when "user_id": %>
<% if recording.user.nil? %>
&nbsp;
<% else %>
<%=h recording.user.username %>
<% end %>
<% else %> <% else %>
<% if recording[column_name].to_s != "" %> <% if recording[column_name].to_s != "" %>
<%=h recording.send(column_name) %> <%=h recording.send(column_name) %>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment