Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Notify users of credit card failures #2640

Merged
merged 3 commits into from
Aug 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions js/gittip/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
* @param {string} text Notification text
* @param {string} [type=notice] Notofication type (one of: notice, error, success)
*/
Gittip.notification = function(text, type) {
type = type || 'notice';
Gittip.notification = function(text, type, timeout) {
var type = type || 'notice';
var timeout = timeout || 10000;

var dialog = ['div', { 'class': 'notification notification-' + type }, [ 'div', text ]];
var $dialog = $([
Expand All @@ -23,5 +24,5 @@ Gittip.notification = function(text, type) {
}

$dialog.on('click', fadeOut);
setTimeout(fadeOut, 5000);
if (timeout > 0) setTimeout(fadeOut, timeout);
};
8 changes: 7 additions & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,17 @@ <h1>{{ title }}</h1>

{% endblock %}

{% if not user.ANON and user.participant.credit_card_expiring(request, response) %}
{% if not user.ANON and not request.line.uri.startswith('/credit-card.html') %}
<script>
{% if user.participant.last_bill_result %}
$(document).ready(function () {
Gittip.notification(["span", "Your credit card has failed! ", ['a', {'href': '/credit-card.html'}, 'Fix your card']], "error", -1)
});
{% elif user.participant.credit_card_expiring(request, response) %}
$(document).ready(function () {
Gittip.notification(["span", "Your credit card is about to expire! ", ['a', {'href': '/credit-card.html'}, 'Update card']], "error")
});
{% endif %}
</script>
{% endif %}
</body>
Expand Down