Skip to content

Commit

Permalink
add new fields to request form
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Rossi committed Sep 27, 2016
1 parent 6b50eba commit 212a370
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 58 deletions.
19 changes: 7 additions & 12 deletions lib/templates/new_request_notification.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,13 @@
</p>

<ul>
<li>
Name: <%= api_user.full_name %>
</li>
<li>
Email: <%= api_user.email %>
</li>
<li>
Company: <%= api_user.company %>
</li>
<li>
Reason for using the api: <%= api_user.reason %>
</li>
<li>Name: <%= api_user.full_name %></li>
<li>Email: <%= api_user.email %></li>
<li>Company: <%= api_user.company %></li>
<li>Type of User: <%= api_user.kind || "N/A" %></li>
<li>Has licence? <%= api_user.has_licence || "N/A" %></li>
<li>Licence Number: <%= api_user.licence_number || "N/A" %></li>
<li>Reason for using the api: <%= api_user.reason %></li>
</ul>

<p>To activate this user, follow <a href="<%= activation_url %>">this link</a> and insert your administration credentials.</p>
15 changes: 9 additions & 6 deletions web/controllers/requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ def send_notification(new_user)

def create_api_user params
ApiUser.create(
email: params["email"],
full_name: params["fullname"],
company: params["company"],
reason: params["reason"],
active: false,
token: ApiUser.new_token
email: params["email"],
full_name: params["fullname"],
company: params["company"],
reason: params["reason"],
licence_number: params["licence_number"],
has_licence: params["has_licence"],
kind: params["kind"],
token: ApiUser.new_token,
active: false
)
end
end
12 changes: 10 additions & 2 deletions web/public/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $(document).ready(function() {

$accordionEl.find(".js-trigger").click(function(ev) {
$switchEl.toggleClass('is-open is-closed');
$targetEl.toggleClass('u-hide');
$targetEl.toggle();
});
};

Expand All @@ -21,12 +21,20 @@ $(document).ready(function() {
var $targetEl = $dismissableEl.find(".js-target").addBack(".js-target");

$dismissableEl.find(".js-trigger").click(function(ev) {
$targetEl.addClass("u-hide");
$targetEl.hide();
ev.preventDefault();
});
};

dismissables.each(function(i, dismissableEl) {
dismissOnClick($(dismissableEl));
});

$(".js-licence-select").change(function(ev) {
if($(this).val() == "Yes") {
$(".js-licence-input").show();
} else {
$(".js-licence-input").hide();
}
});
});
19 changes: 7 additions & 12 deletions web/views/admin.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,13 @@
<div>
<h4 class="alert__title alert__title--info"> Token: <%= api_user.token %> </h4>
<ul class="alert__body">
<li>
Name: <%= api_user.full_name %>
</li>
<li>
Email: <%= api_user.email %>
</li>
<li>
Company: <%= api_user.company %>
</li>
<li>
Reason for using the api: <%= api_user.reason %>
</li>
<li>Name: <%= api_user.full_name %></li>
<li>Email: <%= api_user.email %></li>
<li>Company: <%= api_user.company %></li>
<li>Type of User: <%= api_user.kind %></li>
<li>Has licence? <%= api_user.has_licence %></li>
<li>Licence Number: <%= api_user.licence_number || "N/A" %></li>
<li>Reason for using the api: <%= api_user.reason %></li>
</ul>
</div>
</aside>
Expand Down
27 changes: 1 addition & 26 deletions web/views/request.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,7 @@
<div class="cover-story__story-border"></div>
<div class="cover-story__story-body cover-story__story-body--right">
<div class="cover-story__story-content">
<form class="s-form" method="POST" action="/request">
<%= Rack::Csrf.csrf_tag(env) %>
<fieldset>
<label for="email">Email</label>
<input class="big" name="email" required type="email">
</fieldset>

<fieldset>
<label for="fullname">Full name</label>
<input class="big" name="fullname" required type="text">
</fieldset>

<fieldset>
<label for="company">Company (Optional)</label>
<input class="big" name="company" type="text">
</fieldset>

<fieldset>
<label for="reason">Why would you like to use the Protected Planet API?</label>
<textarea name="reason" required></textarea>
</fieldset>

<button class="big-button" type="submit">
<i class="fa fa-paper-plane big-button__icon"></i>Submit request
</button>
</form>
<%= erb "request/_form".to_sym %>
</div>
</div>
</div>
Expand Down
59 changes: 59 additions & 0 deletions web/views/request/_form.rhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<form class="s-form" method="POST" action="/request">
<%= Rack::Csrf.csrf_tag(env) %>
<fieldset>
<label for="email">Email</label>
<input class="big" name="email" required type="email">
</fieldset>

<fieldset>
<label for="fullname">Full name</label>
<input class="big" name="fullname" required type="text">
</fieldset>

<fieldset>
<label for="company">Company (Optional)</label>
<input class="big" name="company" type="text">
</fieldset>

<fieldset>
<label for="kind">Type of User</label>
<span class="form__select-container">
<select class="big" id="kind" name="kind">
<option disabled selected value>Select an option</option>
<option value="Scientific Research">Scientific Research</option>
<option value="Private Sector">Private Sector</option>
<option value="Conservation Organisation">Conservation Organisation</option>
<option value="Government">Government</option>
<option value="Education">Education</option>
<option value="Other">Other</option>
</select>
</span>
</fieldset>

<fieldset>
<label for="has_licence">Do you have a licence to use the API?</label>
<span class="form__select-container">
<select class="js-licence-select big" id="has_licence" name="has_licence">
<option disabled selected value>Select an option</option>
<option value="Yes">Yes</option>
<option value="No, but I would like to test the API before requesting a licence">No, but I would like to test the API first</option>
<option value="No, but I would like to request one">No, but I would like to request one</option>
</select>
</span>
</fieldset>

<fieldset class="u-hide js-licence-input">
<label for="licence_number">Licence number</label>
<input class="big" name="licence_number" type="text">
</fieldset>

<fieldset>
<label for="reason">Please provide a brief description on how you intend to use the API</label>
<textarea placeholder="e.g. who is the audience, what type of service is being provided, how will the data be used: visualisation only, download, reposting" name="reason" required></textarea>
</fieldset>

<button class="big-button" type="submit">
<i class="fa fa-paper-plane big-button__icon"></i>Submit request
</button>
</form>

0 comments on commit 212a370

Please sign in to comment.