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

email-prefs #145

Merged
merged 3 commits into from Aug 27, 2013
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 17 additions & 4 deletions app/http/public/css/account.less
Expand Up @@ -78,12 +78,24 @@

.field-label {
display: inline-block;
color: @midgrey;
width: 110px;
margin-right: 20px;
color: lighten(@grey, 30%);
width: 30%;
padding-right: 5%;
}

.user-info-list {
.wm-email-pref-list {
vertical-align: top;
width: 60%;
display: inline-block;
position: relative;
> li > input[type="checkbox"] {
margin: 0 15px 0 0;
padding: 0;
}
}


.no-list-styling {
margin: 0;
padding: 0;
list-style: none;
Expand All @@ -94,3 +106,4 @@ iframe {
width: 100%;
height: 300px;
}

20 changes: 20 additions & 0 deletions app/http/views/js/account.js
Expand Up @@ -27,6 +27,8 @@
$( ".wm-email" ).text( email );
$( ".wm-username" ).text( username );
$( "#user-avatar" ).css( "background-image", "url(https://secure.gravatar.com/avatar/" + data.emailHash + "?s=200&d=https%3A%2F%2Fstuff.webmaker.org%2Favatars%2Fwebmaker-avatar-200x200.png)" );

$( "#sendEventCreationEmailsCheckbox" ).prop( "checked", data.sendEventCreationEmails );
};

navigator.idSSO.app.onlogout = function() {
Expand Down Expand Up @@ -56,4 +58,22 @@
}, 3000);
}
});

$( "#sendEventCreationEmailsCheckbox" ).change(function(e) {
var checked = $( this ).prop( "checked" ) ? 1 : 0;

$.ajax({
type: "PUT",
url: "/user/" + personaEmail,
data: {
sendEventCreationEmails: checked
},
success: function( data, textStatus ) {
console.log( data, textStatus );
},
error: function( jqXHR, textStatus, errorThrown ) {
console.log( textStatus, errorThrown );
}
});
});
});
4 changes: 4 additions & 0 deletions app/http/views/js/console.js
Expand Up @@ -13,6 +13,7 @@
isSuspended: $( "#isSuspended" ),
sendNotifications: $( "#sendNotifications" ),
sendEngagements: $( "#sendEngagements" ),
sendEventCreationEmails: $( "#sendEventCreationEmails" ),
newUser: $( "#newUser" ),
submit: $( "#submit" ),
clear: $( "#clear" ),
Expand Down Expand Up @@ -77,6 +78,7 @@
jQuery.isSuspended.prop( "checked", "" );
jQuery.sendNotifications.prop( "checked", "" );
jQuery.sendEngagements.prop( "checked", "" );
jQuery.sendEventCreationEmails.prop( "checked", "" );
jQuery.newUser.prop( "value", "true" );
jQuery.error.html( "" );

Expand Down Expand Up @@ -114,6 +116,7 @@
userData.isSuspended = jQuery.isSuspended.prop( "checked" ) === false ? false : true;
userData.sendNotifications = jQuery.sendNotifications.prop( "checked" ) === false ? false : true;
userData.sendEngagements = jQuery.sendEngagements.prop( "checked" ) === false ? false : true;
userData.sendEventCreationEmails = jQuery.sendEventCreationEmails.prop( "checked" ) === false ? false : true;

// New user or old?
var method = jQuery.newUser.attr( "value" ) === "false" ? "put" : "post",
Expand Down Expand Up @@ -166,6 +169,7 @@
jQuery.isSuspended.prop( "checked", user.isSuspended === true ? true : false );
jQuery.sendNotifications.prop( "checked", user.sendNotifications === true ? true : false );
jQuery.sendEngagements.prop( "checked", user.sendEngagements === true ? true : false );
jQuery.sendEventCreationEmails.prop( "checked", user.sendEventCreationEmails === true ? true : false );

// Hidden field
jQuery.newUser.prop( "value", "false" );
Expand Down
13 changes: 10 additions & 3 deletions app/http/views/site/account.html
Expand Up @@ -34,10 +34,19 @@
</div>
<div class="g-5">
<h1>{{ gettext('Hi') }} <span class="wm-username"></span>!</h1>
<ul class="user-info-list">
<ul class="no-list-styling">
<li><span class="field-label">{{ gettext('Username') }}</span><span class="wm-username"></span></li>
<li><span class="field-label">{{ gettext('Email') }}</span><span class="wm-email"></span></li>
<li><span class="field-label">{{ gettext('Send me emails when') }}:</span>
<ul class="wm-email-pref-list no-list-styling">
<li>
<input type="checkbox" id="sendEventCreationEmailsCheckbox">
<label for="sendEventCreationEmailsCheckbox">{{ gettext('I create an event') }}</label>
</li>
</ul>
</li>
</ul>

<p><a id="delete-account">{{ gettext('Delete account?') }}</a></p>
</div>
</div>
Expand All @@ -52,8 +61,6 @@ <h2>{{ gettext('Are you sure you want to leave?') }}</h2>
</div>
<div class="ui-wrapper ui-body" id="logout-message">{{ gettext('Your user account was deleted!') }}</div>
<div class="ui-wrapper ui-body" id="wrong-email">{{ gettext("Looks like that isn't your email") }}</div>
</div>
</div>
<script src="/js/ext/require.js" data-main="/js/account"></script>

{% if ga_account %}
Expand Down
3 changes: 2 additions & 1 deletion app/http/views/site/console.html
Expand Up @@ -100,7 +100,8 @@ <h4>User Account</h4>
<td><p class="pull-right">Communications</p></td>
<td>
<input type="checkbox" value="true" id="sendEngagements" /> Engagements<br />
<input type="checkbox" value="true" id="sendNotifications" /> Notifications
<input type="checkbox" value="true" id="sendNotifications" /> Notifications<br />
<input type="checkbox" value="true" id="sendEventCreationEmails" /> Send event creation emails<br />
</td>
</tr>
<tr>
Expand Down
5 changes: 5 additions & 0 deletions app/models/user/sqlModel.js
Expand Up @@ -76,6 +76,10 @@ module.exports = function( sequelize, DataTypes ) {
type: DataTypes.BOOLEAN,
defaultValue: false
},
sendEventCreationEmails: {
type: DataTypes.BOOLEAN,
defaultValue: true
},
wasMigrated: {
type: DataTypes.BOOLEAN,
defaultValue: false
Expand All @@ -96,6 +100,7 @@ module.exports = function( sequelize, DataTypes ) {
isSuspended: obj.isSuspended,
sendNotifications: obj.sendNotifications,
sendEngagements: obj.sendEngagements,
sendEventCreationEmails: obj.sendEventCreationEmails,
// wasMigrated: obj.wasMigrated,
createdAt: obj.createdAt,
updatedAt: obj.updatedAt,
Expand Down
4 changes: 3 additions & 1 deletion locale/en_US/messages.json
Expand Up @@ -7,5 +7,7 @@
"Enter your email to confirm:": "Enter your email to confirm:",
"Delete me forever": "Delete me forever",
"Your user account was deleted!": "Your user account was deleted!",
"Looks like that isnt your email": "Looks like that isn't your email"
"Looks like that isnt your email": "Looks like that isn't your email",
"Send me emails when": "Send me emails when",
"I create an event": "I create an event"
}
2 changes: 2 additions & 0 deletions migrations/082713-add-sendEventCreationEmails.sql
@@ -0,0 +1,2 @@
/* Add the isCollaborator column to the login server database, default to true */
ALTER TABLE Users ADD COLUMN sendEventCreationEmails TINYINT(1) NOT NULL DEFAULT 1;