* user profile QA fixes
This commit is contained in:
Sebastian Marcet 2014-12-01 16:43:44 -03:00
parent a34fa2ecbc
commit 55c168ebc4
14 changed files with 75 additions and 90 deletions

View File

@ -48,8 +48,11 @@ final class PasswordManager {
* @throws PasswordMismatchException
*/
public function changePassword($token, $password, $password_confirmation){
if(empty($token)) throw new InvalidResetPasswordTokenException;
$member = Member::member_from_autologinhash($token);
$member = Member::currentUser();
if(!$member) {
if (empty($token)) throw new InvalidResetPasswordTokenException;
$member = Member::member_from_autologinhash($token);
}
if(!$member) throw new InvalidResetPasswordTokenException;
if(empty($password)) throw new EmptyPasswordException;
if($password !== $password_confirmation) throw new PasswordMismatchException;

View File

@ -48,7 +48,7 @@ final class CustomChangePasswordForm extends ChangePasswordForm {
}
catch(InvalidResetPasswordTokenException $ex1){
Session::clear('AutoLoginHash');
Controller::curr()->redirect('loginpage');
Controller::curr()->redirect('login');
}
catch(EmptyPasswordException $ex2){
$this->clearMessage();

View File

@ -63,11 +63,25 @@ class CustomPasswordController extends Security {
'Form' => $this->ChangePasswordForm(),
));
}
else{
else if(isset($_REQUEST['t']) && isset($_REQUEST['m'])){
$new_hash = $this->password_manager->verifyToken((int)@$_REQUEST['m'], @$_REQUEST['t']);
Session::set('AutoLoginHash', $new_hash);
return $this->redirect($this->Link('changepassword'));
}
else if(Member::currentUser()) {
// Logged in user requested a password change form.
$customisedController = $controller->customise(array(
'Content' => '<p>'
. _t('Security.CHANGEPASSWORDBELOW', 'You can change your password below.') . '</p>',
'Form' => $this->ChangePasswordForm()));
}
else{
self::permissionFailure(
$this,
_t('Security.ERRORPASSWORDPERMISSION', 'You must be logged in in order to change your password!')
);
return;
}
}
catch(InvalidPasswordResetLinkException $ex1){
$customisedController = $controller->customise(

View File

@ -25,7 +25,7 @@ class CandidateApplicationForm extends HoneyPotForm {
new TextAreaField('TopPriority',"What do you think the top priority of the Board should be in 2015?")
);
$actionButton = new FormAction('save', 'Save Candidate Application');
$actionButton = new FormAction('saveCandidateApplicationForm', 'Save Candidate Application');
//$actionButton->addExtraClass('btn green-btn');
$actions = new FieldList(

View File

@ -141,7 +141,7 @@ class MemberListPage_Controller extends Page_Controller
// Check to see if the candidate ID is numeric and if the person is logged in
if ($this->validateNomation($CandidateID) == 'VALID') {
$Nominee = Member::get()->filter(array('ID' => $CandidateID));
$Nominee = Member::get()->filter(array('ID' => $CandidateID))->first();
$results["Success"] = TRUE;
$results["Candidate"] = $Nominee;
$results["NominateLink"] = $this->Link() . "saveNomination/" . $CandidateID;
@ -149,7 +149,7 @@ class MemberListPage_Controller extends Page_Controller
} elseif ($this->validateNomation($CandidateID) == 'ALREADY NOMINATED') {
$Nominee = Member::get()->filter(array('ID' => $CandidateID));
$Nominee = Member::get()->filter(array('ID' => $CandidateID))->first();
$CurrentElection = $this->CurrentElection();
@ -162,7 +162,7 @@ class MemberListPage_Controller extends Page_Controller
} elseif ($this->validateNomation($CandidateID) == 'LIMIT EXCEEDED') {
$Nominee = Member::get()->filter(array('ID' => $CandidateID));
$Nominee = Member::get()->filter(array('ID' => $CandidateID))->first();
$results["Success"] = FALSE;
$results["LimitExceeded"] = TRUE;
@ -223,7 +223,7 @@ class MemberListPage_Controller extends Page_Controller
// 6. Make sure that the person nominating is a foundation member
$CurrentMember = Member::currentUser();
If (!$CurrentMember->inGroup(5, TRUE)) {
If (!$CurrentMember->isFoundationMember()) {
return 'INVALID VOTER';
}
@ -235,7 +235,8 @@ class MemberListPage_Controller extends Page_Controller
function saveNomination()
{
$CandidateID = $this->request->param("OtherID");
// Grab candidate ID from the URL
$CandidateID = $this->request->param("ID");
$NominationStatus = $this->validateNomation($CandidateID);
// Check to see if this is a valid nomination
@ -275,30 +276,20 @@ class MemberListPage_Controller extends Page_Controller
fclose($file);
// Email the member
// In dev and testing, send the nomination emails to the person who did the nomination
$To = $currentMember->Email;
// In live mode, send the email to the candidate
if (Director::isLive()) $To = $Candidate->Member()->Email;
$Subject = "You have been nominated in the " . $CurrentElection->Title;
$email = EmailFactory::getInstance()->buildEmail(CANDIDATE_NOMINATION_FROM_EMAIL, $To, $Subject);
$email->setTemplate('NominationEmail');
// Gather Data to send to template
$data["Candidate"] = $Candidate;
$data["Election"] = $CurrentElection;
$email->populateTemplate($data);
$email->send();
$this->setMessage('Success', "You've just nominated " . $Candidate->Member()->FirstName . ' for the OpenStack Board.');
$this->redirect('/community/members/candidateStats/' . $Candidate->Member()->ID);
$this->redirect($this->Link('candidateStats/' . $Candidate->Member()->ID));
} elseif ($NominationStatus = 'ALREADY NOMINATED') {
$this->setMessage('Error', "Oops, you have already nominated this person.");
@ -350,7 +341,7 @@ class MemberListPage_Controller extends Page_Controller
{
// Grab candidate ID from the URL
$CandidateID = $this->request->param("OtherID");
$CandidateID = $this->request->param("ID");
// Check to see if the candidate is valid
if (is_numeric($CandidateID) && $this->findMember($CandidateID)) {

View File

@ -211,11 +211,7 @@ class EditProfileForm extends SafeXSSForm {
$fields->push(new LiteralField('break', '<hr/>'));
$fields->push($password = new ConfirmedPasswordField('Password',
'Password'
));
$password->setCanBeEmpty(true);
$fields->push(new LiteralField('changepassword','<a href="/Security/changepassword">Click here to change your password</a>'));
// Create action

View File

@ -225,11 +225,6 @@ class EditProfilePage_Controller extends Page_Controller
}
}
function FoundationMember()
{
// see if the member is in the foundation group
if (Member::currentUser() && Member::currentUser()->inGroup('foundation-members')) return TRUE;
}
function CompanyAdmin()
{
@ -339,7 +334,7 @@ class EditProfilePage_Controller extends Page_Controller
}
// Save an edited candidate
function save($data, $form)
function saveCandidateApplicationForm($data, $form)
{
@ -408,18 +403,19 @@ class EditProfilePage_Controller extends Page_Controller
$form->saveInto($Candidate);
$Candidate->write();
$this->setMessage('Success', 'Your edits have been saved but you will need to provide full answers to all these questions to be eligible as a candidate.');
$form->clearMessage();
$form->sessionMessage( "Your edits have been saved but you will need to provide full answers to all these questions to be eligible as a candidate.","bad");
$this->redirectBack();
return;
}
$Candidate->HasAcceptedNomination = TRUE;
$Candidate->write();
$this->setMessage('Success', 'Congratulations. You have accepted your nomination as a candidate. Good luck in the election!');
$form->clearMessage();
$this->redirect($this->Link() . 'election/');
} else {
$this->setMessage('Error', 'There was an error saving your edits.');
$form->clearMessage();
$form->sessionMessage('There was an error saving your edits.',"bad");
$this->redirectBack();
}

View File

@ -65,8 +65,6 @@ jQuery(document).ready(function($) {
City:{required: true},
State:{required: true},
Postcode:{required: true},
'Password[_Password]': {required: true,minlength: 5},
'Password[_ConfirmPassword]': {required: true,minlength: 5,equalTo: '#Password-_Password'},
'Affiliations':{checkAffiliations:true},
'Gender':{required:true}
},

View File

@ -1,18 +1,12 @@
<div class="container">
<% require javascript(sapphire/thirdparty/tinymce/tiny_mce.js) %>
<% require javascript(themes/openstack/javascript/simple-tinymce.js) %>
<% require javascript(framework/thirdparty/tinymce/tiny_mce.js) %>
<% require javascript(themes/openstack/javascript/simple-tinymce.js) %>
<% require themedCSS(profile-section) %>
<% if FoundationMember %>
<% if CurrentMember.isFoundationMember %>
<h1>Accept Nomination</h1>
<p>To accept nominations and be listed as a candidate for the OpenStack election, please answer the questions below.</p>
<h2>Candidate Application Form</h2>
$CandidateApplicationForm
<% 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>

View File

@ -1,12 +1,8 @@
<div class="container">
$SetCurrentTab(2)
<% require themedCSS(profile-section) %>
<h1>$Title</h1>
<% if FoundationMember %>
<h1>$Title</h1>
<% if CurrentMember.isFoundationMember %>
<% include ProfileNav %>
@ -66,4 +62,5 @@
<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%2Felection%2F">Login</a> <a href="/join/" class="roundedButton">Join The Foundation</a></p>
<% end_if %>
</div></div>
</div>
</div>

View File

@ -1,31 +1,25 @@
<div class="container">
<% require javascript(framework/thirdparty/tinymce/tiny_mce.js) %>
<% require javascript(themes/openstack/javascript/simple-tinymce.js) %>
$SetCurrentTab(7)
<% require themedCSS(profile-section) %>
<h1>$Title</h1>
<% if CurrentMember %>
<% if Saved %>
$SetCurrentTab(7)
<div class="span-24 last siteMessage" id="SuccessMessage">
<p>Your Profile has been saved!</p>
</div>
<% end_if %>
<% include ProfileNav %>
$EditSpeakerProfileForm
<% 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>
<% require themedCSS(profile-section) %>
<h1>$Title</h1>
<% if CurrentMember %>
<% if Saved %>
<div class="span-24 last siteMessage" id="SuccessMessage">
<p>Your Profile has been saved!</p>
</div>
<% end_if %>
<% include ProfileNav %>
$EditSpeakerProfileForm
<% 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>
<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

@ -3,7 +3,7 @@
</div>
<h2 class="profile-tabs">
<a href="{$Link}" <% if CurrentTab=1 %>class="active"<% end_if %> >Your Details</a>
<% if FoundationMember %>
<% if CurrentMember.isFoundationMember %>
<a href="{$Link}election" <% if CurrentTab=2 %>class="active"<% end_if %> >Election</a>
<% end_if %>
<a href="{$Link}agreements" <% if CurrentTab=3 %>class="active"<% end_if %> >Legal Agreements</a>

View File

@ -5,14 +5,16 @@
<h1>Please confirm your nomination</h1>
<p>Are you sure you would officially like to nominate <strong>$Candidate.FirstName $Candidate.Surname</strong> to the OpenStack Board?</p>
<p><a class="roundedButton" href="$NominateLink">Yes, Nominate $Candidate.FirstName</a> &nbsp; <a class="roundedButton" href="{$Link}profile/$Candidate.ID">No</a></p>
<% else %>
<% if NominatedByMe %>
<h1>You have already nominated $Candidate.FirstName $Candidate.Surname.</h1>
<p><a class="roundedButton" href="{$Election.Link}CandidateList/">See Nominations</a> <a class="roundedButton" href="{$Link}">See All Members</a></p>
<% with Candidate %>
<h1>You have already nominated $FirstName $Surname.</h1>
<% end_with %>
<p><a class="roundedButton" href="{$Election.Link}CandidateList/">See Nominations</a> <a class="roundedButton" href="{$Link}">See All Members</a></p>
<% else_if LimitExceeded %>
<h1>This candidate has already received 10 nominations.</h1>
<p>That's all the nominations that are required to appear on the election ballot. You may want to nominate someone else who you think would be a good candidate.</p>