* Option to upgrade/downgrade user member level
This commit is contained in:
Sebastian Marcet 2014-12-03 15:58:28 -03:00
parent 309a0f6f95
commit df7c1a5f90
9 changed files with 108 additions and 194 deletions

View File

@ -22,8 +22,6 @@ class AffiliationController extends Page_Controller
'ListAffiliations',
'ListOrganizations',
'AffiliationsCount',
'Downgrade2CommunityMember',
'Upgrade2FoundationMember',
);
function init()
@ -201,22 +199,4 @@ class AffiliationController extends Page_Controller
echo json_encode('ERROR');
}
public function Downgrade2CommunityMember(){
if ($CurrentMember = Member::currentUser()) {
$CurrentMember->convert2SiteUser();
echo json_encode('OK');
exit();
}
echo json_encode('ERROR');
}
public function Upgrade2FoundationMember(){
if ($CurrentMember = Member::currentUser()) {
$CurrentMember->upgradeToFoundationMember();
echo json_encode('OK');
exit();
}
echo json_encode('ERROR');
}
}

View File

@ -37,6 +37,8 @@ class EditProfilePage_Controller extends Page_Controller
'marketplace',
'speaker',
'EditSpeakerProfileForm',
'downgrade2communitymember',
'upgrade2foundationmember',
);
/**
@ -77,10 +79,8 @@ class EditProfilePage_Controller extends Page_Controller
Requirements::javascript("themes/openstack/javascript/jquery.ui.datepicker.validation.package-1.0.1/jquery.ui.datepicker.validation.js");
Requirements::javascript("themes/openstack/javascript/jquery.validate.custom.methods.js");
Requirements::javascript("registration/javascript/affiliations.js");
Requirements::javascript('themes/openstack/javascript/current.user.infobox.jquery.js');
Requirements::javascript('registration/javascript/edit.profile.page.js');
$this->course_repository = new SapphireCourseRepository;
$this->training_repository = new SapphireTrainingServiceRepository;
@ -676,4 +676,26 @@ class EditProfilePage_Controller extends Page_Controller
public function ResignUrl(){
return $this->Link('resign');
}
public function downgrade2communitymember(){
$CurrentMember = Member::currentUser();
if ($CurrentMember && isset($_GET['confirmed'])) {
$CurrentMember->convert2SiteUser();
$this->setMessage('Success', 'You have downgraded your membership to Community Member.');
$this->redirect('profile/');
} else if ($CurrentMember) {
return $this->renderWith(array('EditProfilePage_downgrade2communitymember', 'Page'));
}
}
public function upgrade2foundationmember(){
$CurrentMember = Member::currentUser();
if ($CurrentMember && isset($_GET['confirmed'])) {
$CurrentMember->upgradeToFoundationMember();
$this->setMessage('Success', 'You have upgraded your membership to Foundation Member.');
$this->redirect('profile/');
} else if ($CurrentMember) {
return $this->renderWith(array('EditProfilePage_upgrade2foundationmember', 'Page'));
}
}
}

View File

@ -256,6 +256,4 @@ jQuery(document).ready(function($) {
});
}
$('body').user_infobox();
});

View File

@ -0,0 +1,19 @@
<div class="container">
<% require themedCSS(profile-section) %>
<h1>Downgrade To Community Member</h1>
<% if CurrentMember %>
<p>If you select this option, you will be revoking your right to vote in elections and to commit code to OpenStack via Gerrit. Additionally, any administrative rights to the Marketplace Admin or Company Admin will be revoked.</p>
<p><a href="{$Top.Link}downgrade2communitymember/?confirmed=1" class="roundedButton">Yes, Agree</a> &nbsp; <a
href="{$Top.Link}" class="roundedButton">Cancel</a></p>
<% else %>
<p>In order to edit your community profile, you will first need to <a
href="/Security/login/?BackURL=%2Fprofile%2F">login as a member</a>. Don't have an account? <a
href="/join/">Join The Foundation</a></p>
<p><a class="roundedButton" href="/Security/login/?BackURL=%2Fprofile%2F">Login</a> <a href="/join/"
class="roundedButton">Join
The Foundation</a></p>
<% end_if %>
</div></div>

View File

@ -4,7 +4,7 @@
<h1>$Title</h1>
<% if CurrentMember.isFoundationMember %>
<% include CurrentUserInfoBox LogOutLink=$Top.LogoutUrl, ResignLink=$Top.ResignUrl %>
>
<% include ProfileNav %>
<% if CurrentElection %>

View File

@ -6,13 +6,21 @@
<% if CurrentMember %>
<p>Are you sure you want to resign your membership to the OpenStack Foundation? This action will <strong>completely remove your account</strong> and cannot be undone.</p>
<p><a href="{$Top.Link}resign/?confirmed=1" class="roundedButton">Yes, I want to resign</a> &nbsp; <a href="{$Top.Link}" class="roundedButton">Cancel</a></p>
<p>Are you sure you want to resign your membership to the OpenStack Foundation? This action will <strong>completely
remove your account</strong> and cannot be undone.</p>
<p><a href="{$Top.Link}resign/?confirmed=1" class="roundedButton">Yes, I want to resign</a> &nbsp; <a
href="{$Top.Link}" class="roundedButton">Cancel</a></p>
<% else %>
<p>In order to edit your community profile, you will first need to <a href="/Security/login/?BackURL=%2Fprofile%2F">login as a member</a>. Don't have an account? <a href="/join/">Join The Foundation</a></p>
<p><a class="roundedButton" href="/Security/login/?BackURL=%2Fprofile%2F">Login</a> <a href="/join/" class="roundedButton">Join The Foundation</a></p>
<p>In order to edit your community profile, you will first need to <a
href="/Security/login/?BackURL=%2Fprofile%2F">login as a member</a>. Don't have an account? <a
href="/join/">Join The Foundation</a></p>
<p><a class="roundedButton" href="/Security/login/?BackURL=%2Fprofile%2F">Login</a> <a href="/join/"
class="roundedButton">Join
The Foundation</a></p>
<% end_if %>
</div></div>
</div></div>

View File

@ -0,0 +1,28 @@
<div class="container">
<% require themedCSS(profile-section) %>
<h1>Upgrade To Foundation Member</h1>
<% if CurrentMember %>
<h2>1. Read over the terms of becoming an OpenStack Foundation Individual Member.</h2>
<div class="termsBox">
<p>This Individual Member Agreement (IM Agreement) between me and the OpenStack Foundation (the Foundation) governs my rights and obligations as an Individual Member of the Foundation and is effective on the date that I sign below. I agree that:</p>
<p>1. My rights and obligations as an Individual Member are defined in the Certificate of Incorporation and Bylaws (including policies which are exhibits to the bylaws, including the Community Code of Conduct) of the Foundation located at <a href="http://openstack.org/legal/">http://www.openstack.org/legal/</a> on the date that I submitted the Individual Member Application (IM Application) , as they may be amended from time to time (the Certificate, Bylaws, and the Community Code of Conduct respectively). The changes to the Certificate, Bylaws and Community Code of Conduct shall be effective when posted at <a href="/legal/">http://www.openstack.org/legal/</a> and I will regularly check the Certificate, Bylaws and Community Code of Conduct to ensure that I understand my obligations. I will become an Individual Member effective on the date provided in the Bylaws;</p>
<p>2. The information that I provided in the IM Application is complete and accurate on the date of submission and I will continue to update such information to ensure that it remains complete and accurate. In particular, I will promptly update any change in my Affiliate status as defined in the Bylaws and my email contact address;</p>
<p>3. I will comply with the obligations of Individual Members in the Certificate, Bylaws and the Community Code of Conduct;</p>
<p>4. I consent to making available to the public my name, my Statement of Interest (as provided in the IM Application) and Affiliate status. In addition, I consent to the use of other information in the IM Application as provided in the Bylaws; and</p>
<p>5. I consent to communication by electronic means to my email contact address. My membership may be terminated for breach of this IM Agreement or my obligations under the Certificate, Bylaws and Community Code of Conduct. Upon such breach, the Foundation shall provide notice to me at my email contact address describing the alleged breach and the thirty day period permitted for response. If I do not respond within such thirty (30) day period, I will automatically cease to be an Individual Member.</p>
<p>6. This IM Agreement is governed by the laws of the State of Delaware, but not including its conflict of law principles. This IM Agreement is personal to me and may not be transferred to any other party, whether by operation of law or otherwise. This IM Agreement (including the IM Application, Certificate, Bylaws and Community Code of Conduct) constitutes the entire agreement between the parties concerning membership in the Foundation and supersedes all written or oral prior agreements or understandings with respect thereto. No modification, extension or waiver of or under this IM Agreement is valid unless it is made in a writing which identifies itself as an amendment to this IM Agreement and that writing is signed by an authorized representative of each party. No waiver will constitute, or be construed as, a waiver of any other obligation or condition of this IM Agreement.</p>
</div>
<p><a href="{$Top.Link}upgrade2foundationmember/?confirmed=1" class="roundedButton">Yes, Agree</a> &nbsp; <a
href="{$Top.Link}" class="roundedButton">Cancel</a></p>
<% else %>
<p>In order to edit your community profile, you will first need to <a
href="/Security/login/?BackURL=%2Fprofile%2F">login as a member</a>. Don't have an account? <a
href="/join/">Join The Foundation</a></p>
<p><a class="roundedButton" href="/Security/login/?BackURL=%2Fprofile%2F">Login</a> <a href="/join/"
class="roundedButton">Join
The Foundation</a></p>
<% end_if %>
</div></div>

View File

@ -1,124 +0,0 @@
/**
* Copyright 2014 Openstack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
(function( $ ){
var settings = {};
var downgrade_btn = null;
var upgrade_btn = null;
var confirm_downgrade_dialog = null;
var confirm_upgrade_dialog = null;
var methods = {
init: function(options){
settings = $.extend({}, options );
downgrade_btn = $('.downgrade-2-community-member');
upgrade_btn = $('.upgrade-2-foundation-member');
downgrade_btn.click(function(event){
event.preventDefault();
event.stopPropagation();
confirm_downgrade_dialog.dialog( "open");
return false;
});
upgrade_btn.click(function(event){
event.preventDefault();
event.stopPropagation();
confirm_upgrade_dialog.dialog( "open");
return false;
});
confirm_upgrade_dialog = $('#dialog-confirm-upgrade').dialog({
resizable: false,
autoOpen: false,
height:520,
width:620,
modal: true,
buttons: {
"Agree": function() {
$.ajax(
{
type: "GET",
url: 'userprofile/Upgrade2FoundationMember',
dataType: "json",
timeout:5000,
retryMax: 2,
complete: function (jqXHR,textStatus) {
window.location.reload();
},
error: function (jqXHR, textStatus, errorThrown) {
alert( "Request failed: " + textStatus );
}
}
);
$(this).dialog( "close" );
},
"Disagree": function() {
$( this ).dialog( "close" );
}
}
});
confirm_downgrade_dialog = $('#dialog-confirm-downgrade').dialog({
resizable: false,
autoOpen: false,
height:220,
width:520,
modal: true,
buttons: {
"Agree": function() {
$.ajax(
{
type: "GET",
url: 'userprofile/Downgrade2CommunityMember',
dataType: "json",
timeout:5000,
retryMax: 2,
complete: function (jqXHR,textStatus) {
window.location.reload();
},
error: function (jqXHR, textStatus, errorThrown) {
alert( "Request failed: " + textStatus );
}
}
);
$(this).dialog( "close" );
},
"Disagree": function() {
$( this ).dialog( "close" );
}
}
});
}
};
$.fn.user_infobox = function(methodOrOptions) {
if ( methods[methodOrOptions] ) {
return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
// Default to "init"
return methods.init.apply( this, arguments );
} else {
$.error( 'Method ' + method + ' does not exist on jQuery.user_infobox' );
}
};
// End of closure.
}( jQuery ));

View File

@ -1,45 +1,28 @@
<div class="loggedInBox">
<div class="row">
<div class="col-md-4" style="height: 35px;line-height: 35px;"><span style="display:inline-block; vertical-align:middle;">You are logged in as: <strong>$CurrentMember.Name</strong></span></div>
<div class="col-md-1"><a class="roundedButton" href="{$LogOutLink}">Logout</a></div>
<div class="col-md-7"><a class="roundedButton" href="{$ResignLink}">Resign Membership</a></div>
<div class="col-md-8 text-right">
<a class="roundedButton" href="{$ResignLink}">Resign Membership</a>
<% if $CurrentMember.isFoundationMember %>
<a class="roundedButton downgrade-2-community-member" href="$Top.Link(downgrade2communitymember)">Change to Community Member</a>
<% else_if $CurrentMember.isCommunityMember %>
<a class="roundedButton upgrade-2-foundation-member" href="$Top.Link(upgrade2foundationmember)">Make me a Foundation Member</a>
<% end_if %>
</div>
</div>
<div class="row">
<% if $CurrentMember.isFoundationMember %>
<div class="col-md-4" style="height: 35px;line-height: 35px;">
<div class="col-md-12" style="height: 35px;line-height: 35px;">
<span style="display:inline-block; vertical-align:middle;">Current Member Level: <strong>Foundation Member</strong></span>
</div>
<div class="col-md-8">
<a class="roundedButton downgrade-2-community-member" href="{$Downgrade2CommunityMemberLink}">Change to Community Member</a>
</div>
<% else_if $CurrentMember.isSpeaker %>
<div c class="col-md-12" style="height: 35px;line-height: 35px;">
<span style="display:inline-block; vertical-align:middle;">Current Member Level: <strong>Speaker</strong></span>
</div>
<% else_if $CurrentMember.isCommunityMember %>
<div c class="col-md-4" style="height: 35px;line-height: 35px;">
<div c class="col-md-12" style="height: 35px;line-height: 35px;">
<span style="display:inline-block; vertical-align:middle;">Current Member Level: <strong>Community Member</strong></span>
</div>
<div class="col-md-6">
<a class="roundedButton upgrade-2-foundation-member" href="{$Upgrade2FoundationMemberLink}">Make me a Foundation Member</a>
</div>
<% end_if %>
</div>
</div>
<div id="dialog-confirm-downgrade" title="Change to Community Member?" style="display: none;">
<p>
<span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>If you select this option, you will be revoking your right to vote in elections and to commit code to OpenStack via Gerrit.</p>
</div>
<div id="dialog-confirm-upgrade" title="Change to Foundation Member?" style="display: none;">
<h2>1. Read over the terms of becoming an OpenStack Foundation Individual Member.</h2>
<div class="termsBox">
<p>This Individual Member Agreement (IM Agreement) between me and the OpenStack Foundation (the Foundation) governs my rights and obligations as an Individual Member of the Foundation and is effective on the date that I sign below. I agree that:</p>
<p>1. My rights and obligations as an Individual Member are defined in the Certificate of Incorporation and Bylaws (including policies which are exhibits to the bylaws, including the Community Code of Conduct) of the Foundation located at <a href="http://openstack.org/legal/">http://www.openstack.org/legal/</a> on the date that I submitted the Individual Member Application (IM Application) , as they may be amended from time to time (the Certificate, Bylaws, and the Community Code of Conduct respectively). The changes to the Certificate, Bylaws and Community Code of Conduct shall be effective when posted at <a href="/legal/">http://www.openstack.org/legal/</a> and I will regularly check the Certificate, Bylaws and Community Code of Conduct to ensure that I understand my obligations. I will become an Individual Member effective on the date provided in the Bylaws;</p>
<p>2. The information that I provided in the IM Application is complete and accurate on the date of submission and I will continue to update such information to ensure that it remains complete and accurate. In particular, I will promptly update any change in my Affiliate status as defined in the Bylaws and my email contact address;</p>
<p>3. I will comply with the obligations of Individual Members in the Certificate, Bylaws and the Community Code of Conduct;</p>
<p>4. I consent to making available to the public my name, my Statement of Interest (as provided in the IM Application) and Affiliate status. In addition, I consent to the use of other information in the IM Application as provided in the Bylaws; and</p>
<p>5. I consent to communication by electronic means to my email contact address. My membership may be terminated for breach of this IM Agreement or my obligations under the Certificate, Bylaws and Community Code of Conduct. Upon such breach, the Foundation shall provide notice to me at my email contact address describing the alleged breach and the thirty day period permitted for response. If I do not respond within such thirty (30) day period, I will automatically cease to be an Individual Member.</p>
<p>6. This IM Agreement is governed by the laws of the State of Delaware, but not including its conflict of law principles. This IM Agreement is personal to me and may not be transferred to any other party, whether by operation of law or otherwise. This IM Agreement (including the IM Application, Certificate, Bylaws and Community Code of Conduct) constitutes the entire agreement between the parties concerning membership in the Foundation and supersedes all written or oral prior agreements or understandings with respect thereto. No modification, extension or waiver of or under this IM Agreement is valid unless it is made in a writing which identifies itself as an amendment to this IM Agreement and that writing is signed by an authorized representative of each party. No waiver will constitute, or be construed as, a waiver of any other obligation or condition of this IM Agreement.</p>
</div>
</div>