From 595b213b1aff149e0f1e3c8b825ad5775bc86990 Mon Sep 17 00:00:00 2001 From: Luka Murn Date: Sat, 19 Nov 2016 16:51:40 +0100 Subject: [PATCH] Changes up to samples in views folder --- app/controllers/sample_groups_controller.rb | 24 ------------ app/controllers/sample_types_controller.rb | 37 ------------------- app/helpers/permission_helper.rb | 8 ---- app/views/activities/index.html.erb | 2 - app/views/my_module_comments/new.html.erb | 7 ---- app/views/my_module_tags/new.html.erb | 10 ----- app/views/my_modules/edit.html.erb | 9 ----- app/views/my_modules/show.html.erb | 11 ------ .../organizations/_parse_errors.html.erb | 26 ------------- app/views/project_activities/index.html.erb | 3 -- app/views/project_comments/new.html.erb | 7 ---- app/views/result_comments/new.html.erb | 7 ---- app/views/sample_groups/edit.html.erb | 9 ----- app/views/sample_types/edit.html.erb | 8 ---- config/routes.rb | 4 +- 15 files changed, 1 insertion(+), 171 deletions(-) delete mode 100644 app/views/activities/index.html.erb delete mode 100644 app/views/my_module_comments/new.html.erb delete mode 100644 app/views/my_module_tags/new.html.erb delete mode 100644 app/views/my_modules/edit.html.erb delete mode 100644 app/views/my_modules/show.html.erb delete mode 100644 app/views/organizations/_parse_errors.html.erb delete mode 100644 app/views/project_activities/index.html.erb delete mode 100644 app/views/project_comments/new.html.erb delete mode 100644 app/views/result_comments/new.html.erb delete mode 100644 app/views/sample_groups/edit.html.erb delete mode 100644 app/views/sample_types/edit.html.erb diff --git a/app/controllers/sample_groups_controller.rb b/app/controllers/sample_groups_controller.rb index f3319ba48..821de9bc4 100644 --- a/app/controllers/sample_groups_controller.rb +++ b/app/controllers/sample_groups_controller.rb @@ -1,8 +1,6 @@ class SampleGroupsController < ApplicationController - before_action :load_vars, only: [:edit, :update] before_action :load_vars_nested, only: [:new, :create] before_action :check_create_permissions, only: [:new, :create] - before_action :check_edit_permissions, only: [:edit, :update] def new @sample_group = SampleGroup.new @@ -37,10 +35,6 @@ class SampleGroupsController < ApplicationController end end - def edit - - end - def update @sample_group.last_modified_by = current_user if @sample_group.update_attributes(sample_group_params) @@ -54,20 +48,8 @@ class SampleGroupsController < ApplicationController end end - def destroy - end - private - def load_vars - @sample_group = SampleGroup.find_by_id(params[:id]) - @organization = @sample_group.organization - - unless @sample_group - render_404 - end - end - def load_vars_nested @organization = Organization.find_by_id(params[:organization_id]) @@ -82,12 +64,6 @@ class SampleGroupsController < ApplicationController end end - def check_edit_permissions - unless can_edit_sample_type_in_organization(@organization) - render_403 - end - end - def sample_group_params params.require(:sample_group).permit(:name, :color) end diff --git a/app/controllers/sample_types_controller.rb b/app/controllers/sample_types_controller.rb index 783572a5c..b8afc7619 100644 --- a/app/controllers/sample_types_controller.rb +++ b/app/controllers/sample_types_controller.rb @@ -1,8 +1,6 @@ class SampleTypesController < ApplicationController - before_action :load_vars, only: [:edit, :update] before_action :load_vars_nested, only: [:new, :create] before_action :check_create_permissions, only: [:new, :create] - before_action :check_edit_permissions, only: [:edit, :update] def new @sample_type = SampleType.new @@ -37,37 +35,8 @@ class SampleTypesController < ApplicationController end end - def edit - - end - - def update - @sample_type.last_modified_by = current_user - if @sample_type.update_attributes(sample_type_params) - flash[:success] = t( - "sample_types.update.success_flash", - sample_type: @sample_type.name, - organization: @organization.name) - redirect_to (session.delete(:return_to) || root_path) - else - render :edit - end - end - - def destroy - end - private - def load_vars - @sample_type = SampleType.find_by_id(params[:id]) - @organization = @sample_type.organization - - unless @sample_type - render_404 - end - end - def load_vars_nested @organization = Organization.find_by_id(params[:organization_id]) @@ -82,12 +51,6 @@ class SampleTypesController < ApplicationController end end - def check_edit_permissions - unless can_edit_sample_type_in_organization(@organization) - render_403 - end - end - def sample_type_params params.require(:sample_type).permit(:name) end diff --git a/app/helpers/permission_helper.rb b/app/helpers/permission_helper.rb index dab8b691d..43972e678 100644 --- a/app/helpers/permission_helper.rb +++ b/app/helpers/permission_helper.rb @@ -662,20 +662,12 @@ module PermissionHelper is_normal_user_or_admin_of_organization(organization) end - def can_edit_sample_type_in_organization(organization) - is_normal_user_or_admin_of_organization(organization) - end - # ---- SAMPLE GROUPS PERMISSIONS ---- def can_create_sample_group_in_organization(organization) is_normal_user_or_admin_of_organization(organization) end - def can_edit_sample_group_in_organization(organization) - is_normal_user_or_admin_of_organization(organization) - end - # ---- CUSTOM FIELDS PERMISSIONS ---- def can_create_custom_field_in_organization(organization) diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb deleted file mode 100644 index 70399ed5a..000000000 --- a/app/views/activities/index.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Activities#index

-

Find me in app/views/activities/index.html.erb

diff --git a/app/views/my_module_comments/new.html.erb b/app/views/my_module_comments/new.html.erb deleted file mode 100644 index c09110960..000000000 --- a/app/views/my_module_comments/new.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<% provide(:head_title, raw(t("my_module_comments.new.head_title", project: @my_module.project.name, module: @my_module.name))) %> -

<%=t "my_module_comments.new.title", module: @my_module.name %>

- -<%= bootstrap_form_for [@my_module, @comment], url: my_module_my_module_comments_path do |f| %> - <%= f.text_area :message, style: "margin-top: 10px;" %>
- <%= f.submit t("my_module_comments.new.create"), style: "margin-top: 10px;" %> -<% end %> diff --git a/app/views/my_module_tags/new.html.erb b/app/views/my_module_tags/new.html.erb deleted file mode 100644 index caa1ae966..000000000 --- a/app/views/my_module_tags/new.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -<% provide(:head_title, raw(t("my_module_tags.new.head_title", project: @my_module.project.name, module: @my_module.name))) %> -

<%=t "my_module_tags.new.title", module: @my_module.name %>

- -<%= bootstrap_form_for [@my_module, @mt], url: my_module_my_module_tags_path do |f| %> - <%= collection_select(:my_module_tag, :tag_id, @tags, :id, :name ) %> -
- <%= f.submit t("my_module_tags.new.create"), style: "margin-top: 10px;" %> -<% end %> -
-<%= link_to t("my_module_tags.new.new_tag"), new_tag_path, type: "button", class: "btn btn-default" %> diff --git a/app/views/my_modules/edit.html.erb b/app/views/my_modules/edit.html.erb deleted file mode 100644 index 5079899b0..000000000 --- a/app/views/my_modules/edit.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -<% provide(:head_title, raw(t("my_modules.edit.head_title", project: @my_module.project.name, module: @my_module.name))) %> -

<%=t "my_modules.edit.title", module: @my_module.name %>

- -<%= bootstrap_form_for @my_module, url: my_module_path do |f| %> - <%= f.text_field :name, label: t("my_modules.edit.name") %> - <%= f.text_area :description, style: "margin-top: 10px;" %> - <%= f.datetime_picker :due_date, label: t("my_modules.edit.due_date"), clear: true %> - <%= f.submit t("my_modules.edit.save"), style: "margin-top: 10px;" %> -<% end %> \ No newline at end of file diff --git a/app/views/my_modules/show.html.erb b/app/views/my_modules/show.html.erb deleted file mode 100644 index 4625e9ef3..000000000 --- a/app/views/my_modules/show.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<% provide(:head_title, raw(t("my_modules.show.head_title", project: @my_module.project.name, module: @my_module.name))) %> -<%= render partial: "shared/sidebar" %> -<%= render partial: "shared/secondary_navigation" %> - -<% unless @my_module.archived %> -<%= form_for @my_module, method: :patch, format: :html do |f| %> - <%= f.hidden_field :archived, value: true %> - <%= button_tag t('my_modules.show.archive_action'), class: 'btn btn-danger', - data: { confirm: t('my_modules.show.archive_confirm_text') } %> -<% end %> -<% end %> diff --git a/app/views/organizations/_parse_errors.html.erb b/app/views/organizations/_parse_errors.html.erb deleted file mode 100644 index 8712c94b1..000000000 --- a/app/views/organizations/_parse_errors.html.erb +++ /dev/null @@ -1,26 +0,0 @@ -<% if errors.present? %> - -<% end %> \ No newline at end of file diff --git a/app/views/project_activities/index.html.erb b/app/views/project_activities/index.html.erb deleted file mode 100644 index 6faacef80..000000000 --- a/app/views/project_activities/index.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% provide(:head_title, raw(t("projects.activities.head_title", project: @project.name))) %> -<%= render partial: "shared/sidebar" %> -<%= render partial: "shared/secondary_navigation" %> diff --git a/app/views/project_comments/new.html.erb b/app/views/project_comments/new.html.erb deleted file mode 100644 index 82a994265..000000000 --- a/app/views/project_comments/new.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<% provide(:head_title, raw(t("project_comments.new.head_title", project: @project.name))) %> -

<%=t "project_comments.new.title", project: @project.name %>

- -<%= bootstrap_form_for [@project, @comment], url: project_project_comments_path do |f| %> - <%= f.text_area :message, style: "margin-top: 10px;" %>
- <%= f.submit t("project_comments.new.create"), style: "margin-top: 10px;" %> -<% end %> diff --git a/app/views/result_comments/new.html.erb b/app/views/result_comments/new.html.erb deleted file mode 100644 index e892c69f5..000000000 --- a/app/views/result_comments/new.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<% provide(:head_title, raw(t("result_comments.new.head_title", project: @result.my_module.project.name, module: @result.my_module.name))) %> -

<%=t "result_comments.new.title" %>

- -<%= bootstrap_form_for [@result, @comment], url: result_result_comments_path do |f| %> - <%= f.text_area :message, style: "margin-top: 10px;" %>
- <%= f.submit t("result_comments.new.create"), style: "margin-top: 10px;" %> -<% end %> diff --git a/app/views/sample_groups/edit.html.erb b/app/views/sample_groups/edit.html.erb deleted file mode 100644 index e04ffa78d..000000000 --- a/app/views/sample_groups/edit.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -<% provide(:head_title, raw(t("sample_groups.edit.head_title", organization: @organization.name))) %> -

<%=t "sample_groups.edit.title", sample_group: @sample_group.name, organization: @organization.name %>

- -<%= bootstrap_form_for [@sample_group], url: sample_group_path do |f| %> - <%= f.text_area :name, style: "margin-top: 10px;" %> - <%= f.text_field :color %> -
- <%= f.submit t("sample_groups.edit.create"), style: "margin-top: 10px;" %> -<% end %> diff --git a/app/views/sample_types/edit.html.erb b/app/views/sample_types/edit.html.erb deleted file mode 100644 index c398c9967..000000000 --- a/app/views/sample_types/edit.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<% provide(:head_title, raw(t("sample_types.edit.head_title", organization: @organization.name))) %> -

<%=t "sample_types.edit.title", sample_type: @sample_type.name, organization: @organization.name %>

- -<%= bootstrap_form_for [@sample_type], url: sample_type_path do |f| %> - <%= f.text_area :name, style: "margin-top: 10px;" %> -
- <%= f.submit t("sample_types.edit.create"), style: "margin-top: 10px;" %> -<% end %> diff --git a/config/routes.rb b/config/routes.rb index 01073c51f..8ba85c8c6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -170,7 +170,7 @@ Rails.application.routes.draw do # Show action is a popup (JSON) for individual module in full-zoom canvas, # as well as "module info" page for single module (HTML) - resources :my_modules, path: "/modules", only: [:show, :edit, :update, :destroy] do + resources :my_modules, path: "/modules", only: [:show, :update, :destroy] do resources :my_module_tags, path: "/tags", only: [:index, :create, :update, :destroy] resources :user_my_modules, path: "/users", only: [:index, :new, :create, :destroy] resources :my_module_comments, @@ -223,8 +223,6 @@ Rails.application.routes.draw do resources :samples, only: [:edit, :update, :destroy] get 'samples/:id', to: 'samples#show' - resources :sample_types, only: [:edit, :update] - resources :sample_groups, only: [:edit, :update] resources :result_texts, only: [:edit, :update, :destroy] get 'result_texts/:id/download' => 'result_texts#download', as: :result_text_download