Commit 52247d85 by John Doe

elminated db routes and views, clients do not see the db object

parent 627fde04
...@@ -44,12 +44,13 @@ class NilmsController < ApplicationController ...@@ -44,12 +44,13 @@ class NilmsController < ApplicationController
def update def update
#update both the NILM and the Db models #update both the NILM and the Db models
@service = StubService.new @service = StubService.new
if @nilm.update(nilm_params) && @db.update(db_params) # redundant since the user must be an owner...
@role = current_user.get_nilm_permission(@nilm)
if @nilm.update(nilm_params) and @nilm.db.update(db_params)
@service.add_notice('Installation Updated') @service.add_notice('Installation Updated')
render :show, status: :ok render :show, status: :ok
else else
@service.errors = @nilm.errors.full_messages + @service.errors = @nilm.errors.full_messages
@db.errors.full_messages
render :show, status: :unprocessable_entity render :show, status: :unprocessable_entity
end end
end end
...@@ -77,15 +78,10 @@ class NilmsController < ApplicationController ...@@ -77,15 +78,10 @@ class NilmsController < ApplicationController
# Never trust parameters from the scary internet, # Never trust parameters from the scary internet,
# only allow the white list through. # only allow the white list through.
def nilm_params def nilm_params
params.permit(:name, :description,:url) params.permit(:name, :description, :url)
end end
def db_params def db_params
unless params[:db].nil? params.permit(:max_points_per_plot)
params[:db].permit(:max_points_per_plot)
else
return {}
end
end end
#authorization based on nilms #authorization based on nilms
......
json.partial! "dbs/db", db: @db
json.data do
json.partial! "dbs/db", db: @db
end
json.partial! "helpers/messages", service: @service
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
json.data do json.data do
json.extract! @nilm, *Nilm.json_keys json.extract! @nilm, *Nilm.json_keys
json.role @role json.role @role
unless @nilm.db.nil? json.max_points_per_plot @nilm.db.max_points_per_plot
json.partial! "db", db: @nilm.db, as: :db json.root_folder do
json.available @nilm.db.available json.partial! 'db_folders/db_folder',
db_folder: @nilm.db.root_folder,
nilm: @nilm
end end
json.jouleModules(@nilm.joule_modules) do |m| json.jouleModules(@nilm.joule_modules) do |m|
json.extract! m, *JouleModule.json_keys json.extract! m, *JouleModule.json_keys
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment