forked from presidential-innovation-fellows/apps-gov-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Draft Functionality to ProductRequest
Adds Draft Functionality to the ProductRequest model. This enables ProductOwners to request editing privileges for a Product. * Add Draftsman gem * Add drafting functionality to ProductRequest * Create ProductRequest controller for handling ProductOwner-specific requests
- Loading branch information
Showing
18 changed files
with
136 additions
and
24 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
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
left: 50%; | ||
margin-left: -15em; | ||
opacity: 0; | ||
overflow: hidden; | ||
padding: 2em; | ||
position: fixed; | ||
top: 4em; | ||
|
23 changes: 23 additions & 0 deletions
23
app/controllers/product_owners/product_requests_controller.rb
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,23 @@ | ||
module ProductOwners | ||
class ProductRequestsController < ProductOwnersController | ||
def create | ||
@product_request = ProductRequest.new(product_request_params) | ||
|
||
if @product_request.draft_creation | ||
flash[:success] = | ||
I18n.t("product_owners.product_requests.create.success") | ||
else | ||
flash[:error] = | ||
I18n.t("product_owners.product_requests.create.failure") | ||
end | ||
redirect_to product_path(@product_request.product) | ||
end | ||
|
||
private | ||
|
||
def product_request_params | ||
params.require(:product_request). | ||
permit(:product_id).merge(user: signed_in_user) | ||
end | ||
end | ||
end |
34 changes: 18 additions & 16 deletions
34
app/controllers/product_owners/registrations_controller.rb
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 |
---|---|---|
@@ -1,21 +1,23 @@ | ||
class ProductOwners::RegistrationsController < RegistrationsController | ||
respond_to :html, :json | ||
layout "minimal" | ||
module ProductOwners | ||
class RegistrationsController < RegistrationsController | ||
respond_to :html, :json | ||
layout "minimal" | ||
|
||
private | ||
private | ||
|
||
def account_update_params | ||
params.require(:product_owner). | ||
permit( | ||
:first_name, | ||
:last_name, | ||
:email, | ||
:password, | ||
:current_password) | ||
end | ||
def account_update_params | ||
params.require(:product_owner). | ||
permit( | ||
:first_name, | ||
:last_name, | ||
:email, | ||
:password, | ||
:current_password) | ||
end | ||
|
||
def sign_up_params | ||
params.require(:product_owner). | ||
permit(:first_name, :last_name, :email, :password) | ||
def sign_up_params | ||
params.require(:product_owner). | ||
permit(:first_name, :last_name, :email, :password) | ||
end | ||
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,6 @@ | ||
class ProductOwnersController < ApplicationController | ||
load_and_authorize_resource | ||
rescue_from CanCan::AccessDenied do | ||
redirect_to new_product_owner_registration_path | ||
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
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
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,15 @@ | ||
# Override global `draft` class. For example, perhaps you want your own class at `app/models/draft.rb` that adds | ||
# extra attributes, validations, associations, methods, etc. Be sure that this new model class extends | ||
# `Draftsman::Draft`. | ||
# Draftsman.draft_class_name = 'Draftsman::Draft' | ||
|
||
# Serializer for `object`, `object_changes`, and `previous_draft` columns. To use the JSON serializer, change to | ||
# `Draftsman::Serializers::Json`. You could implement your own serializer if you really wanted to. See files in | ||
# `lib/draftsman/serializers`. | ||
# | ||
# Note: this option is not needed if you're using the PostgreSQL JSON data type for the `object`, | ||
# `object_changes`, and `previous_draft` columns. | ||
# Draftsman.serializer = Draftsman::Serializers::Json | ||
|
||
# Field which records when a draft was created. | ||
# Draftsman.timestamp_field = :created_at |
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
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,22 @@ | ||
class CreateDrafts < ActiveRecord::Migration | ||
def change | ||
create_table :drafts do |t| | ||
t.string :item_type, :null => false | ||
t.integer :item_id, :null => false | ||
t.string :event, :null => false | ||
t.string :whodunnit# :null => false | ||
t.text :object | ||
t.text :previous_draft | ||
t.timestamps :null => false | ||
end | ||
|
||
change_table :drafts do |t| | ||
t.index :item_type | ||
t.index :item_id | ||
t.index :event | ||
t.index :whodunnit | ||
t.index :created_at | ||
t.index :updated_at | ||
end | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
db/migrate/20160506165423_add_draft_attributes_to_product_request.rb
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 @@ | ||
class AddDraftAttributesToProductRequest < ActiveRecord::Migration | ||
def change | ||
add_column :product_requests, :draft_id, :integer | ||
add_column :product_requests, :published_at, :timestamp | ||
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
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
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