-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move protocols and protocol drugs into the admin namespace.
- Change paths everywhere - Fix tests - Remove json from controllers
- Loading branch information
Showing
20 changed files
with
151 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
class Admin::ProtocolDrugsController < ApplicationController | ||
before_action :set_protocol_drug, only: %i[show edit update destroy] | ||
before_action :set_protocols, only: %i[create edit update new] | ||
|
||
def index | ||
@protocol_drugs = ProtocolDrug.all | ||
end | ||
|
||
def show | ||
end | ||
|
||
def new | ||
@protocol_drug = ProtocolDrug.new | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def create | ||
@protocol_drug = ProtocolDrug.new(protocol_drug_params) | ||
if @protocol_drug.save | ||
redirect_to [:admin, :protocols], notice: 'Protocol drug was successfully created.' | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def update | ||
if @protocol_drug.update(protocol_drug_params) | ||
redirect_to [:admin, :protocols], notice: 'Protocol drug was successfully updated.' | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
@protocol_drug.destroy | ||
redirect_to [:admin, :protocols], notice: 'Protocol drug was successfully destroyed.' | ||
end | ||
|
||
private | ||
|
||
def set_protocols | ||
@protocols = Protocol.all | ||
end | ||
|
||
def set_protocol_drug | ||
@protocol_drug = ProtocolDrug.find(params[:id]) | ||
end | ||
|
||
def protocol_drug_params | ||
params.require(:protocol_drug).permit(:name, :dosage, :rxnorm_code, :protocol_id) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
class Admin::ProtocolsController < ApplicationController | ||
before_action :set_protocol, only: %i[show edit update destroy] | ||
|
||
def index | ||
@protocols = Protocol.all | ||
end | ||
|
||
def show | ||
end | ||
|
||
def new | ||
@protocol = Protocol.new | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def create | ||
@protocol = Protocol.new(protocol_params) | ||
if @protocol.save | ||
redirect_to [:admin, @protocol], notice: 'Protocol was successfully created.' | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def update | ||
if @protocol.update(protocol_params) | ||
redirect_to [:admin, @protocol], notice: 'Protocol was successfully updated.' | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
@protocol.destroy | ||
redirect_to admin_protocols_url, notice: 'Protocol was successfully destroyed.' | ||
end | ||
|
||
private | ||
|
||
def set_protocol | ||
@protocol = Protocol.find(params[:id]) | ||
end | ||
|
||
def protocol_params | ||
params.require(:protocol).permit(:name, :follow_up_days) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
app/views/protocol_drugs/_form.html.erb → ...views/admin/protocol_drugs/_form.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing Protocol Drug</h1> | ||
|
||
<%= render 'form', protocol_drug: @protocol_drug %> | ||
<%= link_to 'Show', [:admin, @protocol_drug] %> | | ||
<%= link_to 'Back', admin_protocol_drugs_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
app/views/protocols/_form.html.erb → app/views/admin/protocols/_form.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing Protocol</h1> | ||
|
||
<%= render 'form', protocol: @protocol %> | ||
<%= link_to 'Show', [:admin, @protocol]%> | | ||
<%= link_to 'Back', admin_protocols_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New Protocol</h1> | ||
|
||
<%= render 'form', protocol: @protocol%> | ||
<%= link_to 'Back', admin_protocols_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.