Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions app/controllers/api/projects/phrases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,19 @@ def show
end

def update
components = project_params[:components]
@project = Project.find_by!(identifier: params[:id])

components.each do |comp_params|
component = Component.find(comp_params[:id])
component.update(comp_params)
end
if oauth_user_id && oauth_user_id == @project.user_id
components = project_params[:components]

head :ok
components.each do |comp_params|
component = Component.find(comp_params[:id])
component.update(comp_params)
end
head :ok
else
head :unauthorized
end
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/views/api/projects/show.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

json.call(@project, :identifier, :project_type, :name)
json.call(@project, :identifier, :project_type, :name, :user_id)

json.components @project.components, :id, :name, :extension, :content