Changes up to samples in views folder

This commit is contained in:
Luka Murn 2016-11-19 16:51:40 +01:00
parent f5795f5516
commit 595b213b1a
15 changed files with 1 additions and 171 deletions

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -1,2 +0,0 @@
<h1>Activities#index</h1>
<p>Find me in app/views/activities/index.html.erb</p>

View file

@ -1,7 +0,0 @@
<% provide(:head_title, raw(t("my_module_comments.new.head_title", project: @my_module.project.name, module: @my_module.name))) %>
<h2><%=t "my_module_comments.new.title", module: @my_module.name %></h2>
<%= bootstrap_form_for [@my_module, @comment], url: my_module_my_module_comments_path do |f| %>
<%= f.text_area :message, style: "margin-top: 10px;" %><br />
<%= f.submit t("my_module_comments.new.create"), style: "margin-top: 10px;" %>
<% end %>

View file

@ -1,10 +0,0 @@
<% provide(:head_title, raw(t("my_module_tags.new.head_title", project: @my_module.project.name, module: @my_module.name))) %>
<h2><%=t "my_module_tags.new.title", module: @my_module.name %></h2>
<%= 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 ) %>
<br />
<%= f.submit t("my_module_tags.new.create"), style: "margin-top: 10px;" %>
<% end %>
<br />
<%= link_to t("my_module_tags.new.new_tag"), new_tag_path, type: "button", class: "btn btn-default" %>

View file

@ -1,9 +0,0 @@
<% provide(:head_title, raw(t("my_modules.edit.head_title", project: @my_module.project.name, module: @my_module.name))) %>
<h2><%=t "my_modules.edit.title", module: @my_module.name %></h2>
<%= 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 %>

View file

@ -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 %>

View file

@ -1,26 +0,0 @@
<% if errors.present? %>
<div class="alert alert-danger" role="alert">
<div><%=t "organizations.parse_sheet.errors.errors_list_title" %></div>
<br>
<ul>
<% errors.each do |err| %>
<% err.each do |row_nr, row_errors| %>
<li>
<%=t "organizations.parse_sheet.errors.list_row", row: row_nr %>
<ul>
<% row_errors.each do |row_err| %>
<% row_err.each do |k, vals| %>
<% vals.each do |v| %>
<li>
<%=t "organizations.parse_sheet.errors.list_error", key: k, val: v %>
</li>
<% end %>
<% end %>
<% end %>
</ul>
</li>
<% end %>
<% end %>
</ul>
</div>
<% end %>

View file

@ -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" %>

View file

@ -1,7 +0,0 @@
<% provide(:head_title, raw(t("project_comments.new.head_title", project: @project.name))) %>
<h2><%=t "project_comments.new.title", project: @project.name %></h2>
<%= bootstrap_form_for [@project, @comment], url: project_project_comments_path do |f| %>
<%= f.text_area :message, style: "margin-top: 10px;" %><br />
<%= f.submit t("project_comments.new.create"), style: "margin-top: 10px;" %>
<% end %>

View file

@ -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))) %>
<h2><%=t "result_comments.new.title" %></h2>
<%= bootstrap_form_for [@result, @comment], url: result_result_comments_path do |f| %>
<%= f.text_area :message, style: "margin-top: 10px;" %><br />
<%= f.submit t("result_comments.new.create"), style: "margin-top: 10px;" %>
<% end %>

View file

@ -1,9 +0,0 @@
<% provide(:head_title, raw(t("sample_groups.edit.head_title", organization: @organization.name))) %>
<h2><%=t "sample_groups.edit.title", sample_group: @sample_group.name, organization: @organization.name %></h2>
<%= bootstrap_form_for [@sample_group], url: sample_group_path do |f| %>
<%= f.text_area :name, style: "margin-top: 10px;" %>
<%= f.text_field :color %>
<br />
<%= f.submit t("sample_groups.edit.create"), style: "margin-top: 10px;" %>
<% end %>

View file

@ -1,8 +0,0 @@
<% provide(:head_title, raw(t("sample_types.edit.head_title", organization: @organization.name))) %>
<h2><%=t "sample_types.edit.title", sample_type: @sample_type.name, organization: @organization.name %></h2>
<%= bootstrap_form_for [@sample_type], url: sample_type_path do |f| %>
<%= f.text_area :name, style: "margin-top: 10px;" %>
<br />
<%= f.submit t("sample_types.edit.create"), style: "margin-top: 10px;" %>
<% end %>

View file

@ -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