Skip to content

Commit

Permalink
Disambiguate faculty/staff and students (#249)
Browse files Browse the repository at this point in the history
* Disambiguate faculty/staff and students.

* Fix tests and cleanup wording.

* Homogenize language.
  • Loading branch information
fatlotus authored and georgeteo committed May 31, 2016
1 parent d337edf commit 9cf5b98
Show file tree
Hide file tree
Showing 16 changed files with 160 additions and 73 deletions.
2 changes: 1 addition & 1 deletion caravel/controllers/custom_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __call__(self, **kwargs):

return Markup(
"<div><a href='{}' class='signin btn btn-success'>Sign in with "
"CNetID</a>{}</div>"
"Google Apps</a>{}</div>"
).format("/oshalogin", alternative)
# users.create_login_url(request.url)

Expand Down
9 changes: 5 additions & 4 deletions caravel/controllers/listings.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,12 @@ def new_listing():
return render_template("listing_form.html", form=form)


@app.route("/oshalogin")
@app.route("/nooshalogin")
@app.route("/oshalogin", methods=["GET", "POST"])
@app.route("/nooshalogin", methods=["GET", "POST"])
def login_page():
affiliation = request.args.get("affiliation", "")
email = request.args.get("email", "")
affiliation = request.form.get("affiliation", "")
affiliation = request.args.get("affiliation", affiliation)
email = request.args.get("email", request.form.get("email", ""))

if affiliation not in dict(model.Listing.AFFILIATIONS):
affiliation = ""
Expand Down
7 changes: 4 additions & 3 deletions caravel/model/affiliation.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ class AffiliationMixin(ndb.Model):
_aff = None

AFFILIATIONS = [
("bsd_hospital", "BSD/Hospital Staff"),
("osha_faculty_staff", "University Faculty/Staff"),
("osha_current_student", "Current Student"),
("bsd_hospital", "BSD/Hospital"),
("bfi_booth", "BFI/Booth"),
("osha_faculty_staff", "University (Non-BSD) Faculty/Staff"),
("osha_current_student", "University (Non-BSD) Student"),
("alumni", "Alumni"),
("hyde_parker", "Hyde Parker"),
("other", "Other")
Expand Down
14 changes: 13 additions & 1 deletion caravel/static/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ form .thumbnail {
}

/* enter email box */
.enter-email {
.enter-email, .apps-warning {
padding: 5px 10px;
white-space: nowrap;
display: none;
Expand All @@ -296,4 +296,16 @@ form .thumbnail {

.entering-email li:not(.enter-email) {
display: none;
}

.apps-warning {
display: none;
}

.warn-google-apps .apps-warning {
display: block;
}

.warn-google-apps li:not(.apps-warning) {
display: none;
}
33 changes: 27 additions & 6 deletions caravel/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,37 @@ <h1 class="branding">
<form method="post" action="/nooshalogin">
<input type="hidden" name="affiliation" value=""/>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
Enter email address (or <a id="cancel">cancel</a>)<br/>
Enter email address (or <a class="cancel">cancel</a>)<br/>
<input class="form-control" style="width:200px;display:inline-block;"
placeholder="email@address.com" type="email" name="email"/>
<input type="submit" class="btn btn-primary" value="Login"/>
<input type="submit" class="btn btn-success" value="Sign in with Email"/>
</form>
</li>
<li class="apps-warning">
<div>
<a class="btn btn-success">Sign in with Google Apps</a><br/>
<small>
If you see "Google Apps - Invalid Email,"<br/>
<a class="cancel">go back</a> and try "Affiliation: Other."
</small>
</div>
</li>
</ul>
</div>
<script>
$("#signin-dropdown li>a").click(function (e) {
var val = this.getAttribute("data-value");
if (!val.startsWith("osha_")) {
if (val.startsWith("osha_")) {
// Switch to "enter CNetID" mode.
$(this).closest(".btn-group").addClass("warn-google-apps");

// Save the input href.
$(".apps-warning a", $(this).closest("ul")).attr("href", this.href);

e.preventDefault();
return false;

} else {
// Switch to "enter email" mode.
$(this).closest(".btn-group").addClass("entering-email");

Expand All @@ -141,9 +160,11 @@ <h1 class="branding">
}
});

$("#signin-dropdown #cancel").click(function(e) {
$(this).closest(".btn-group").removeClass("entering-email");
console.log($(this).closest(".btn-group")[0]);
$("#signin-dropdown .cancel").click(function(e) {
var btn = $(this).closest(".btn-group")
btn.removeClass("entering-email");
btn.removeClass("warn-google-apps");

e.preventDefault();
return false;
});
Expand Down
2 changes: 1 addition & 1 deletion caravel/templates/listings/fullpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ <h3 class="panel-title">
</div>
<div class="panel-body">
<a class="btn btn-success" href="{{ login_url() }}">
Sign in with CNetID
Sign in with Google Apps
</a> to edit.
</div>
</div>
Expand Down
16 changes: 10 additions & 6 deletions caravel/tests/test_listings_bump_listing_expect.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
New Listing
Select affiliation to sign in...
BSD/Hospital Staff
University Faculty/Staff
Current Student
BSD/Hospital
BFI/Booth
University (Non-BSD) Faculty/Staff
University (Non-BSD) Student
Alumni
Hyde Parker
Other
Enter email address (or cancel )
Sign in with Google Apps
If you see "Google Apps - Invalid Email,"
go back and try "Affiliation: Other."
Listing ☆A
cars
Posted 2w ago .
Expand All @@ -15,11 +19,11 @@ Price: $3.10
ago, which means it may have fallen off the front page.
Body of ☆A
Manage Listing
Sign in with CNetID
Sign in with Google Apps
to edit.
Contact Seller
Affiliation
(Select Affiliation...) BSD/Hospital Staff University Faculty/Staff Current Student Alumni Hyde Parker Other
(Select Affiliation...) BSD/Hospital BFI/Booth University (Non-BSD) Faculty/Staff University (Non-BSD) Student Alumni Hyde Parker Other
Email
Sign in with CNetID or
Sign in with Google Apps or
Message
4 changes: 2 additions & 2 deletions caravel/tests/test_listings_edit_listing_expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ My Listings
Logout
Title
Seller
Sign in with CNetID or
Sign in with Google Apps or
Please sign in with your CNetID.
Alumni/BSD/Medicine/Medical School affiliates: if you are unable
to sign in with your CNetID, please enter your email in the box.
Expand Down Expand Up @@ -44,7 +44,7 @@ Available
Sold
Contact Seller
Affiliation
(Select Affiliation...) BSD/Hospital Staff University Faculty/Staff Current Student Alumni Hyde Parker Other
(Select Affiliation...) BSD/Hospital BFI/Booth University (Non-BSD) Faculty/Staff University (Non-BSD) Student Alumni Hyde Parker Other
Email
seller-a@uchicago.edu ( Logout )
Message
4 changes: 2 additions & 2 deletions caravel/tests/test_listings_new_listing_expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ Available
Sold
Contact Seller
Affiliation
(Select Affiliation...) BSD/Hospital Staff University Faculty/Staff Current Student Alumni Hyde Parker Other
(Select Affiliation...) BSD/Hospital BFI/Booth University (Non-BSD) Faculty/Staff University (Non-BSD) Student Alumni Hyde Parker Other
Email
Sign in with CNetID or
Sign in with Google Apps or
Message
---
New Listing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Available
Sold
Contact Seller
Affiliation
(Select Affiliation...) BSD/Hospital Staff University Faculty/Staff Current Student Alumni Hyde Parker Other
(Select Affiliation...) BSD/Hospital BFI/Booth University (Non-BSD) Faculty/Staff University (Non-BSD) Student Alumni Hyde Parker Other
Email
visitor@uchicago.edu ( Logout )
Message
Expand Down
12 changes: 8 additions & 4 deletions caravel/tests/test_listings_old_listing_expect.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
New Listing
Select affiliation to sign in...
BSD/Hospital Staff
University Faculty/Staff
Current Student
BSD/Hospital
BFI/Booth
University (Non-BSD) Faculty/Staff
University (Non-BSD) Student
Alumni
Hyde Parker
Other
Enter email address (or cancel )
Sign in with Google Apps
If you see "Google Apps - Invalid Email,"
go back and try "Affiliation: Other."
Listing ☆A
cars
Posted 9w ago .
Expand All @@ -16,5 +20,5 @@ so it does not show up in searches, and will not receive inquiries.
It has likely already been sold.
Body of ☆A
Manage Listing
Sign in with CNetID
Sign in with Google Apps
to edit.
4 changes: 2 additions & 2 deletions caravel/tests/test_listings_post_inquiry_expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Available
Sold
Contact Seller
Affiliation
(Select Affiliation...) BSD/Hospital Staff University Faculty/Staff Current Student Alumni Hyde Parker Other
(Select Affiliation...) BSD/Hospital BFI/Booth University (Non-BSD) Faculty/Staff University (Non-BSD) Student Alumni Hyde Parker Other
Email
Sign in with CNetID or
Sign in with Google Apps or
Message
---
Greetings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Available
Sold
Contact Seller
Affiliation
(Select Affiliation...) BSD/Hospital Staff University Faculty/Staff Current Student Alumni Hyde Parker Other
(Select Affiliation...) BSD/Hospital BFI/Booth University (Non-BSD) Faculty/Staff University (Non-BSD) Student Alumni Hyde Parker Other
Email
visitor@uchicago.edu ( Logout )
Message
Expand Down

0 comments on commit 9cf5b98

Please sign in to comment.