forked from External/greenlight
Added a Recordings page where the user can see all recordings (#352)
This commit is contained in:
committed by
Jesus Federico
parent
ef23cae73d
commit
8ff05643dc
@ -20,6 +20,8 @@ class UsersController < ApplicationController
|
||||
before_action :find_user, only: [:edit, :update, :destroy]
|
||||
before_action :ensure_unauthenticated, only: [:new, :create]
|
||||
|
||||
include RecordingsHelper
|
||||
|
||||
# POST /u
|
||||
def create
|
||||
# Verify that GreenLight is configured to allow user signup.
|
||||
@ -109,6 +111,27 @@ class UsersController < ApplicationController
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
# GET /u/:user_uid/recordings
|
||||
def recordings
|
||||
if current_user && current_user.uid == params[:user_uid]
|
||||
@recordings = []
|
||||
current_user.rooms.each do |room|
|
||||
# Check that current user is the room owner
|
||||
next unless room.owner == current_user
|
||||
|
||||
recs = room.recordings
|
||||
# Add the room id to each recording object
|
||||
recs.each do |rec|
|
||||
rec[:room_uid] = room.uid
|
||||
end
|
||||
# Adds an array to another array
|
||||
@recordings.push(*recs)
|
||||
end
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
# GET | POST /terms
|
||||
def terms
|
||||
redirect_to '/404' unless Rails.configuration.terms
|
||||
|
Reference in New Issue
Block a user