Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from alphagov/new_product_features_form
New product features form
- Loading branch information
Showing
40 changed files
with
511 additions
and
144 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
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,4 @@ | ||
legend { | ||
font-size: 1.2em; | ||
font-weight: bold; | ||
} |
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,53 +1,7 @@ | ||
require "zendesk_request" | ||
require "zendesk_client" | ||
|
||
class ApplicationController < ActionController::Base | ||
include GDS::SSO::ControllerMethods | ||
|
||
before_filter :authenticate_user! | ||
|
||
protect_from_forgery | ||
|
||
private | ||
|
||
def on_get(template) | ||
load_client_and_organisations("zendesk_error_upon_new_form") | ||
|
||
@formdata = {} | ||
render :"#{template}", :layout => "application" | ||
end | ||
|
||
def on_post(params, route) | ||
load_client_and_organisations("zendesk_error_upon_submit") | ||
@formdata = params | ||
|
||
if @errors.empty? | ||
ticket = ZendeskRequest.raise_zendesk_request(@client, params, route) | ||
if ticket | ||
redirect_to '/acknowledge' | ||
else | ||
return render :"support/zendesk_error", :locals => {:error_string => "zendesk_error_upon_submit"} | ||
end | ||
else | ||
render :"#{@template}", :layout => "application", :status => 400 | ||
end | ||
end | ||
|
||
def load_client_and_organisations(error_string) | ||
begin | ||
@client = ZendeskClient.get_client(logger) | ||
@organisations = ZendeskRequest.get_organisations(@client) | ||
rescue ZendeskError | ||
return render :"support/zendesk_error", :locals => {:error_string => error_string} | ||
end | ||
end | ||
|
||
def prepopulate_organisation_list | ||
begin | ||
@client = ZendeskClient.get_client(logger) | ||
@organisations = ZendeskRequest.get_organisations(@client) | ||
rescue ZendeskError | ||
return render :"support/zendesk_error", :locals => {:error_string => "zendesk_error_upon_new_form"} | ||
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
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 |
---|---|---|
@@ -1,26 +1,18 @@ | ||
require 'general_request_zendesk_ticket' | ||
|
||
class GeneralRequestsController < ApplicationController | ||
def new | ||
@request = GeneralRequest.new(:requester => Requester.new) | ||
prepopulate_organisation_list | ||
end | ||
class GeneralRequestsController < RequestsController | ||
|
||
def create | ||
@request = GeneralRequest.new(params[:general_request]) | ||
@request.user_agent = request.user_agent | ||
def new_request | ||
GeneralRequest.new(:requester => Requester.new) | ||
end | ||
|
||
load_client_and_organisations("zendesk_error_upon_submit") | ||
def zendesk_ticket_class | ||
GeneralRequestZendeskTicket | ||
end | ||
|
||
if @request.valid? | ||
ticket = ZendeskRequest.raise_ticket(@client, GeneralRequestZendeskTicket.new(@request)) | ||
if ticket | ||
redirect_to acknowledge_path | ||
else | ||
return render "support/zendesk_error", :locals => {:error_string => "zendesk_error_upon_submit"} | ||
end | ||
else | ||
render :new, :status => 400 | ||
end | ||
def parse_request_from_params | ||
user_request = GeneralRequest.new(params[:general_request]) | ||
user_request.user_agent = request.user_agent | ||
user_request | ||
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,15 @@ | ||
require 'new_feature_request_zendesk_ticket' | ||
|
||
class NewFeatureRequestsController < RequestsController | ||
def new_request | ||
NewFeatureRequest.new(:requester => Requester.new, :time_constraint => TimeConstraint.new) | ||
end | ||
|
||
def zendesk_ticket_class | ||
NewFeatureRequestZendeskTicket | ||
end | ||
|
||
def parse_request_from_params | ||
NewFeatureRequest.new(params[:new_feature_request]) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
require "zendesk_request" | ||
require "zendesk_client" | ||
|
||
class RequestsController < ApplicationController | ||
def new | ||
@request = new_request | ||
prepopulate_organisation_list | ||
end | ||
|
||
def create | ||
@request = parse_request_from_params | ||
if @request.valid? | ||
raise_ticket(zendesk_ticket_class.new(@request)) | ||
else | ||
prepopulate_organisation_list | ||
render :new, :status => 400 | ||
end | ||
end | ||
|
||
private | ||
|
||
def on_get(template) | ||
load_client_and_organisations("zendesk_error_upon_new_form") | ||
|
||
@formdata = {} | ||
render :"#{template}", :layout => "application" | ||
end | ||
|
||
def on_post(params, route) | ||
load_client_and_organisations("zendesk_error_upon_submit") | ||
@formdata = params | ||
|
||
if @errors.empty? | ||
ticket = ZendeskRequest.raise_zendesk_request(@client, params, route) | ||
if ticket | ||
redirect_to '/acknowledge' | ||
else | ||
return render :"support/zendesk_error", :locals => {:error_string => "zendesk_error_upon_submit"} | ||
end | ||
else | ||
render :"#{@template}", :layout => "application", :status => 400 | ||
end | ||
end | ||
|
||
def raise_ticket(ticket) | ||
load_client | ||
|
||
ticket = ZendeskRequest.raise_ticket(@client, ticket) | ||
|
||
if ticket | ||
redirect_to acknowledge_path | ||
else | ||
return render "support/zendesk_error", :locals => {:error_string => "zendesk_error_upon_submit"} | ||
end | ||
end | ||
|
||
def load_client_and_organisations(error_string) | ||
load_client | ||
load_organisations(error_string) | ||
end | ||
|
||
def load_client | ||
@client = ZendeskClient.get_client(logger) | ||
end | ||
|
||
def load_organisations(error_string) | ||
begin | ||
@organisations = ZendeskRequest.get_organisations(@client) | ||
rescue ZendeskError | ||
return render :"support/zendesk_error", :locals => {:error_string => error_string} | ||
end | ||
end | ||
|
||
def prepopulate_organisation_list | ||
load_client_and_organisations("zendesk_error_upon_new_form") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,8 @@ | ||
require 'tableless_model' | ||
require 'requester' | ||
require 'with_requester' | ||
|
||
class GeneralRequest < TablelessModel | ||
attr_accessor :requester, :url, :additional, :user_agent | ||
include WithRequester | ||
|
||
validates_presence_of :requester | ||
validate do |request| | ||
if request.requester and not request.requester.valid? | ||
errors[:base] << "Requester details are either not complete or invalid." | ||
end | ||
end | ||
|
||
def requester_attributes=(attr) | ||
self.requester = Requester.new(attr) | ||
end | ||
attr_accessor :url, :additional, :user_agent | ||
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,11 @@ | ||
require 'tableless_model' | ||
require 'with_requester' | ||
require 'with_time_constraint' | ||
|
||
class NewFeatureRequest < TablelessModel | ||
include WithRequester | ||
include WithTimeConstraint | ||
|
||
attr_accessor :user_need, :url_of_example, :inside_government | ||
validates_presence_of :user_need | ||
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,9 @@ | ||
require 'tableless_model' | ||
|
||
class TimeConstraint < TablelessModel | ||
attr_accessor :not_before_date, :needed_by_date, :time_constraint_reason | ||
|
||
validates_date :needed_by_date, :allow_nil => true, :allow_blank => true, :on_or_after => :today | ||
validates_date :not_before_date, :allow_nil => true, :allow_blank => true, :on_or_after => :today | ||
validates_date :not_before_date, :before => :needed_by_date, :unless => Proc.new { |c| c.needed_by_date.nil? || c.needed_by_date.blank? } | ||
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,17 @@ | ||
require 'requester' | ||
|
||
module WithRequester | ||
def self.included(base) | ||
base.validates_presence_of :requester | ||
base.validate do |request| | ||
if request.requester and not request.requester.valid? | ||
errors[:base] << "Requester details are either not complete or invalid." | ||
end | ||
end | ||
end | ||
attr_accessor :requester | ||
|
||
def requester_attributes=(attr) | ||
self.requester = Requester.new(attr) | ||
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,16 @@ | ||
require 'time_constraint' | ||
|
||
module WithTimeConstraint | ||
def self.included(base) | ||
base.validate do |request| | ||
if request.time_constraint and not request.time_constraint.valid? | ||
errors[:base] << "Time constraint details are invalid." | ||
end | ||
end | ||
end | ||
attr_accessor :time_constraint | ||
|
||
def time_constraint_attributes=(attr) | ||
self.time_constraint = TimeConstraint.new(attr) | ||
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
Oops, something went wrong.