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
def update
#update both the NILM and the Db models
@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')
render :show, status: :ok
else
@service.errors = @nilm.errors.full_messages +
@db.errors.full_messages
@service.errors = @nilm.errors.full_messages
render :show, status: :unprocessable_entity
end
end
......@@ -77,15 +78,10 @@ class NilmsController < ApplicationController
# Never trust parameters from the scary internet,
# only allow the white list through.
def nilm_params
params.permit(:name, :description,:url)
params.permit(:name, :description, :url)
end
def db_params
unless params[:db].nil?
params[:db].permit(:max_points_per_plot)
else
return {}
end
params.permit(:max_points_per_plot)
end
#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 @@
json.data do
json.extract! @nilm, *Nilm.json_keys
json.role @role
unless @nilm.db.nil?
json.partial! "db", db: @nilm.db, as: :db
json.available @nilm.db.available
json.max_points_per_plot @nilm.db.max_points_per_plot
json.root_folder do
json.partial! 'db_folders/db_folder',
db_folder: @nilm.db.root_folder,
nilm: @nilm
end
json.jouleModules(@nilm.joule_modules) do |m|
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