Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

Commit

Permalink
Route for updating config
Browse files Browse the repository at this point in the history
  • Loading branch information
brianloveswords committed Oct 15, 2012
1 parent ab00b5e commit 94d54a5
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
17 changes: 17 additions & 0 deletions routes/issuer.js
@@ -1,5 +1,22 @@
var Issuer = require('../models/issuer');

exports.update = function update(req, res) {
var form = req.body;
var issuer = req.issuer || new Issuer();

Object.keys(form).forEach(function (key) {
issuer[key] = form[key];
});

issuer.save(function (err, result) {
if (err)
return res.send(err);
req.flash('info', 'Configuration saved');
res.redirect('/');
});
};


/**
* (Middleware) Get issuer configuration.
*/
Expand Down
3 changes: 2 additions & 1 deletion views/admin/base.html
Expand Up @@ -32,7 +32,8 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="/">ClopenBadger</a>
<a class="brand" href="/">
ClopenBadger{% if issuer %}: {{ issuer.name }} {{ issuer.org }} {% endif %}</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="/">Home</a></li>
Expand Down
35 changes: 29 additions & 6 deletions views/admin/config.html
Expand Up @@ -5,16 +5,27 @@
<legend>Issuer Details</legend>
<div>
<label for="issuer-name">Name</label>
<input type="text" name="name" id="issuer-name" placeholder="Widgets, Inc.">
<input type="text"
name="name"
id="issuer-name"
placeholder="Widgets, Inc."
maxlength="128"
value="{{issuer.name | undef}}"
required>
<span class="help-block">
Name of the issuer. This should be the top-level name of your
institution, e.g. "Mozilla"
</span>
</div>

<div>
<label for="issuer-org">Organization</label>
<input type="text" name="org" id="issuer-org" placeholder="Organization (optional)">
<label for="issuer-org">Organization (optional)</label>
<input type="text"
name="org"
id="issuer-org"
maxlength="128"
value="{{issuer.org | undef}}"
placeholder="Organization">
<span class="help-block">
Organization for your issuer. This should be the organization
or group with your institution, e.g. "Webmaker"
Expand All @@ -23,7 +34,13 @@

<div>
<label for="issuer-origin">Origin</label>
<input type="text" name="origin" id="issuer-origin" placeholder="http://example.org">
<input type="text"
name="origin"
id="issuer-origin"
value="{{issuer.origin | undef}}"
placeholder="http://example.org"
pattern="^(https?):\/\/[^\s\/$.?#].[^\s\/]*\/?$"
required>
<span class="help-block">
Website origin. It should be the protocol, domain (with any
subdomains), optional port, and that's it. Something like
Expand All @@ -33,8 +50,14 @@
</div>

<div>
<label for="issuer-contact">Contact</label>
<input type="text" name="contact" id="issuer-contact" placeholder="badges@example.org">
<label for="issuer-contact">Contact Email</label>
<input type="text"
name="contact"
id="issuer-contact"
value="{{issuer.contact | undef}}"
placeholder="badges@example.org"
pattern="[a-z0-9!#$%&'*+\/=?\^_`{|}~\-]+(?:\.[a-z0-9!#$%&'*+\/=?\^_`{|}~\-]+)*@(?:[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?"
required>
<span class="help-block">
Contact at your organization for any badge-related issues. It's
probably best to make this email something that won't change, so
Expand Down

0 comments on commit 94d54a5

Please sign in to comment.