fixed error message and validation
[sgn.git] / lib / SGN / Controller / KinaseClones.pm
blobeac0ad88a5b64cad3817089d9171c073ccacae78
1 package SGN::Controller::KinaseClones;
3 use Moose;
4 use namespace::autoclean;
5 use CXGN::People;
7 BEGIN { extends 'Catalyst::Controller' }
9 =head1 NAME
11 SGN::Controller::KinaseClones - controller to request kinase clones
13 =cut
15 #Creates a blank form
16 sub form :Path('/kinases/clones/form') :Args(0) {
17 my ($self, $c) = @_;
19 $c->stash->{contact_form_human_question} = $c->config->{contact_form_human_question};
20 $c->stash->{contact_form_human_answer_correct} = 1; # do not show warning on initial screen
21 $c->stash->{template} = '/kinases/clones/order.mas';
25 sub submit :Path('/kinases/clones/submit') :Args(0) {
26 my ($self, $c) = @_;
27 my ($name, $email, $body, $address, $organization, $contact_form_human_answer) = map { $c->request->param($_) } qw/name email body address organization contact_form_human_answer /;
29 if ($contact_form_human_answer eq $c->config->{contact_form_human_answer} and $name and $email and $address and $organization and $body || $ENV{SGN_TEST_MODE}) {
31 my $host = $c->request->hostname();
32 my $client_ip = $c->request->address();
34 $body = <<END_HEREDOC;
36 This message was sent from SGN TOKN Clones Request form
38 From:
39 $name <$email>
41 Address:
42 $address
44 Organization:
45 $organization
47 Message:
48 $body
51 END_HEREDOC
53 # add the client IP address so we can block abusers
56 $c->stash->{email} = {
57 to => $c->config->{tokn_email},
58 from => $c->config->{tokn_email},
59 subject => "TOKN Clone Request via SGN",
60 body => $body,
63 $c->forward('View::Email');
65 $c->stash->{message} = "Thank you. Your message has been sent.";
66 $c->stash->{template} = "/generic_message.mas";
67 } else {
69 my %info_fields = (
70 name => $name,
71 email => $email,
72 address => $address,
73 subject => "TOKN Clone Request via SGN",
74 organization => $organization,
75 body => $body
77 foreach my $category (keys %info_fields) {
78 $c->stash->{filled}->{$category} = $info_fields{$category};
81 $c->stash->{name} = $name;
82 $c->stash->{email} = $email;
83 $c->stash->{address} = $address;
84 $c->stash->{subject} = "TOKN Clone Request via SGN";
85 $c->stash->{organization} = $organization;
86 $c->stash->{body} = $body;
87 $c->stash->{contact_form_human_question} = $c->config->{contact_form_human_question};
88 $c->stash->{contact_form_human_answer} = $contact_form_human_answer;
89 $c->stash->{template} = '/kinases/clones/order.mas';
91 #_build_form_page($self, $c, $name, $email, $c->config->{contact_form_human_question}, $contact_form_human_answer, 0, $subject, $body);
95 __PACKAGE__->meta->make_immutable;