Skip to content

Commit

Permalink
Merge 1bd13e2 into e6af684
Browse files Browse the repository at this point in the history
  • Loading branch information
relf committed Jul 3, 2020
2 parents e6af684 + 1bd13e2 commit b2c3d30
Show file tree
Hide file tree
Showing 35 changed files with 644 additions and 112 deletions.
116 changes: 58 additions & 58 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@ GEM
remote: https://rubygems.org/
remote: https://rails-assets.org/
specs:
actioncable (6.0.3)
actionpack (= 6.0.3)
actioncable (6.0.3.2)
actionpack (= 6.0.3.2)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.0.3)
actionpack (= 6.0.3)
activejob (= 6.0.3)
activerecord (= 6.0.3)
activestorage (= 6.0.3)
activesupport (= 6.0.3)
actionmailbox (6.0.3.2)
actionpack (= 6.0.3.2)
activejob (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
mail (>= 2.7.1)
actionmailer (6.0.3)
actionpack (= 6.0.3)
actionview (= 6.0.3)
activejob (= 6.0.3)
actionmailer (6.0.3.2)
actionpack (= 6.0.3.2)
actionview (= 6.0.3.2)
activejob (= 6.0.3.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.0.3)
actionview (= 6.0.3)
activesupport (= 6.0.3)
actionpack (6.0.3.2)
actionview (= 6.0.3.2)
activesupport (= 6.0.3.2)
rack (~> 2.0, >= 2.0.8)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.0.3)
actionpack (= 6.0.3)
activerecord (= 6.0.3)
activestorage (= 6.0.3)
activesupport (= 6.0.3)
actiontext (6.0.3.2)
actionpack (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
nokogiri (>= 1.8.5)
actionview (6.0.3)
activesupport (= 6.0.3)
actionview (6.0.3.2)
activesupport (= 6.0.3.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
Expand All @@ -43,20 +43,20 @@ GEM
activemodel (>= 4.1, < 6.1)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activejob (6.0.3)
activesupport (= 6.0.3)
activejob (6.0.3.2)
activesupport (= 6.0.3.2)
globalid (>= 0.3.6)
activemodel (6.0.3)
activesupport (= 6.0.3)
activerecord (6.0.3)
activemodel (= 6.0.3)
activesupport (= 6.0.3)
activestorage (6.0.3)
actionpack (= 6.0.3)
activejob (= 6.0.3)
activerecord (= 6.0.3)
activemodel (6.0.3.2)
activesupport (= 6.0.3.2)
activerecord (6.0.3.2)
activemodel (= 6.0.3.2)
activesupport (= 6.0.3.2)
activestorage (6.0.3.2)
actionpack (= 6.0.3.2)
activejob (= 6.0.3.2)
activerecord (= 6.0.3.2)
marcel (~> 0.3.1)
activesupport (6.0.3)
activesupport (6.0.3.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
Expand Down Expand Up @@ -164,7 +164,7 @@ GEM
guard-compat (~> 1.2)
minitest (>= 3.0)
highline (2.0.3)
i18n (1.8.2)
i18n (1.8.3)
concurrent-ruby (~> 1.0)
image_processing (1.10.3)
mini_magick (>= 4.9.5, < 5)
Expand All @@ -186,7 +186,7 @@ GEM
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.5.0)
loofah (2.6.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.2.4)
Expand Down Expand Up @@ -256,7 +256,7 @@ GEM
nio4r (~> 2.0)
pundit (2.1.0)
activesupport (>= 3.0.0)
rack (2.2.2)
rack (2.2.3)
rack-attack (6.3.0)
rack (>= 1.0, < 3)
rack-cors (1.1.1)
Expand All @@ -265,30 +265,30 @@ GEM
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.0.3)
actioncable (= 6.0.3)
actionmailbox (= 6.0.3)
actionmailer (= 6.0.3)
actionpack (= 6.0.3)
actiontext (= 6.0.3)
actionview (= 6.0.3)
activejob (= 6.0.3)
activemodel (= 6.0.3)
activerecord (= 6.0.3)
activestorage (= 6.0.3)
activesupport (= 6.0.3)
rails (6.0.3.2)
actioncable (= 6.0.3.2)
actionmailbox (= 6.0.3.2)
actionmailer (= 6.0.3.2)
actionpack (= 6.0.3.2)
actiontext (= 6.0.3.2)
actionview (= 6.0.3.2)
activejob (= 6.0.3.2)
activemodel (= 6.0.3.2)
activerecord (= 6.0.3.2)
activestorage (= 6.0.3.2)
activesupport (= 6.0.3.2)
bundler (>= 1.3.0)
railties (= 6.0.3)
railties (= 6.0.3.2)
sprockets-rails (>= 2.0.0)
rails-assets-tether (1.4.7)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (6.0.3)
actionpack (= 6.0.3)
activesupport (= 6.0.3)
railties (6.0.3.2)
actionpack (= 6.0.3.2)
activesupport (= 6.0.3.2)
method_source
rake (>= 0.8.7)
thor (>= 0.20.3, < 2.0)
Expand Down Expand Up @@ -381,7 +381,7 @@ GEM
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (4.0.0)
sprockets (4.0.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
Expand Down Expand Up @@ -428,14 +428,14 @@ GEM
rack-proxy (>= 0.6.1)
railties (>= 5.2)
semantic_range (>= 2.3.0)
websocket-driver (0.7.1)
websocket-driver (0.7.2)
websocket-extensions (>= 0.1.0)
websocket-driver (0.7.1-java)
websocket-driver (0.7.2-java)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.4)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.3.0)
zeitwerk (2.3.1)

PLATFORMS
java
Expand Down
28 changes: 13 additions & 15 deletions app/controllers/analyses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ class AnalysesController < ApplicationController
# GET /mdas
def index
@mdas = policy_scope(Analysis).roots
if params[:design_project]
@design_project = DesignProject.find(params[:design_project])
if @design_project
current_user.analyses_scope_design_project_id = @design_project.id
else
redirect_to mdas_url, notice: "Project with id ##{params[:design_project]} not found"
end
end
unless current_user.analyses_scope_design_project_id.blank?
@mdas = @mdas.joins(:design_project_filing)
.where(design_project_filings: {design_project_id: current_user.analyses_scope_design_project_id})
end
end

# GET /mdas/1
Expand All @@ -18,10 +30,6 @@ def new
authorize @mda
end

# GET /mdas/1/edit
def edit
end

# POST /mdas
def create
if params[:cancel_button]
Expand Down Expand Up @@ -51,15 +59,6 @@ def create
end
end

# PATCH/PUT /mdas/1
def update
if @mda.update(mda_params)
redirect_to mda_url(@mda), notice: "Analysis #{@mda.name} was successfully updated."
else
render :edit
end
end

# DELETE /mdas/1
def destroy
if @mda.parent
Expand All @@ -84,7 +83,6 @@ def set_mda
end

def mda_params
params.require(:analysis)
.permit(:name, :public)
params.require(:analysis).permit(:name, :public, design_project: [:id])
end
end
14 changes: 7 additions & 7 deletions app/controllers/api/v1/analyses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
class Api::V1::AnalysesController < Api::ApiController
before_action :set_mda, only: [:show, :update]

# GET /api/v1/mdas[?with_sub_analyses=true]
# GET /api/v1/mdas
def index
if params[:with_sub_analyses]
@mdas = policy_scope(Analysis)
else
@mdas = policy_scope(Analysis).roots
end
@mdas = policy_scope(Analysis).roots
json_response @mdas, :ok, each_serializer: AnalysisItemSerializer
end

Expand Down Expand Up @@ -53,7 +49,10 @@ def update
authorize(fromAnalysis, :show?)
@mda.import!(fromAnalysis, import[:disciplines])
else
@mda.update!(mda_params)
if mda_params[:design_project_id]
@mda.update_design_project!(mda_params[:design_project_id])
end
@mda.update!(mda_params.except(:design_project_id))
end
head :no_content
end
Expand All @@ -77,6 +76,7 @@ def mda_params
:with_sub_analyses,
:name,
:note,
:design_project_id,
:public,
import: [:analysis, disciplines: [] ],
disciplines_attributes: [
Expand Down
9 changes: 9 additions & 0 deletions app/controllers/api/v1/design_projects_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class Api::V1::DesignProjectsController < Api::ApiController
# GET /api/v1/users
def index
json_response policy_scope(DesignProject)
end

end
2 changes: 1 addition & 1 deletion app/controllers/api/v1/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ def update
end

def user_params
params.require(:user).permit(settings: [:analyses_query])
params.require(:user).permit(settings: [:analyses_query, :analyses_scope_design_project_id])
end
end
64 changes: 64 additions & 0 deletions app/controllers/design_projects_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
class DesignProjectsController < ApplicationController
before_action :set_design_project, only: [:show, :edit, :update, :destroy]

# GET /design_projects
def index
@design_projects = policy_scope(DesignProject)
end

# GET /design_projects/1
def show
end

# GET /design_projects/new
def new
@design_project = DesignProject.new
authorize @design_project
end

# GET /design_projects/1/edit
def edit
end

# POST /design_projects
def create
@design_project = DesignProject.new(design_project_params)
authorize @design_project
if params[:cancel_button]
redirect_to design_projects_url, notice: "Design Project creation cancelled."
else
if @design_project.save
@design_project.set_owner(current_user)
redirect_to design_projects_url, notice: "Design project #{@design_project.name} was successfully created."
else
redirect_to new_design_project_url, error: "Something went wrong while creating #{@design_project.name}."
end
end
end

# PATCH/PUT /design_projects/1
def update
if @design_project.update(design_project_params)
redirect_to design_projects_url, notice: "Design project #{@design_project.name} was successfully updated."
else
render :edit
end
end

# DELETE /design_projects/1
def destroy
@design_project.destroy
redirect_to design_projects_url, notice: "Design project #{@design_project.name} was successfully deleted."
end

private
def set_design_project
@design_project = DesignProject.find(params[:id])
authorize @design_project
end

def design_project_params
params.require(:design_project).permit(:name, :description)
end

end
6 changes: 6 additions & 0 deletions app/helpers/analyses_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ def badges(analysis)
if analysis.uq_mode?
res += '<span class="badge badge-pill badge-info mr-2">UQ</span>'
end
if analysis.has_objective?
res += '<span class="badge badge-pill badge-primary mr-2">OPTIM</span>'
end
if analysis.nesting_depth > 2
res += '<span class="badge badge-pill badge-danger mr-2">DEEP</span>'
end
raw(res)
end
end
Loading

0 comments on commit b2c3d30

Please sign in to comment.