public function CurrentMemberHasAcceoted()
 {
     $CurrentUserCandidate = Candidate::get()->filter(array('ElectionID' => $this->ID, 'MemberID' => Member::currentUser()->ID))->first();
     if ($CurrentUserCandidate) {
         return $CurrentUserCandidate->HasAcceptedNomination;
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     //$votes = Response::json(Vote::all());
     $candidates = Candidate::get();
     return View::make('tasks.index_candidates', compact('candidates'));
     //return Response::json(Candidate::all());
     //return View::make('tasks.index', compact('votes'));
 }
Esempio n. 3
0
 function save($object = '', $related_field = '')
 {
     if (!$this->exists()) {
         $o = new Candidate();
         $o->select_max('position');
         $o->get();
         if (count($o->all) != 0) {
             $max = $o->position + 1;
             $this->position = $max;
         } else {
             $this->postion = 1;
         }
     }
     return parent::save($object, $related_field);
 }
Esempio n. 4
0
 function profile()
 {
     // Grab member ID from the URL
     $MemberID = Convert::raw2sql($this->request->param("ID"));
     // Check to see if the ID is numeric
     if (is_numeric($MemberID)) {
         // Check to make sure there's a member with the current id
         if ($Profile = $this->findMember($MemberID)) {
             $CurrentElection = $this->CurrentElection();
             if ($CurrentElection) {
                 $Candidate = Candidate::get()->filter(array('MemberID' => $MemberID, 'ElectionID' => $CurrentElection->ID))->first();
                 $data["Candidate"] = $Candidate;
                 $data["CurrentElection"] = $CurrentElection;
             }
             $data["Profile"] = $Profile;
             // A member is looking at own profile
             if (Member::currentUserID() == $MemberID) {
                 $data["OwnProfile"] = true;
             }
             //return our $Data to use on the page
             return $this->Customise($data);
         }
     }
     return $this->httpError(404, 'Sorry that member could not be found');
 }
Esempio n. 5
0
 /**
  * @return ICandidate|null
  */
 public function getCurrentCandidate()
 {
     $res = null;
     $election = ElectionSystem::get()->first();
     if ($election && $election->CurrentElectionID != 0) {
         $current_election = $election->CurrentElection();
         if (!is_null($current_election)) {
             $candidate = Candidate::get()->filter(array('MemberID' => $this->getIdentifier(), 'ElectionID' => $current_election->ID))->first();
             $res = $candidate;
             if (!is_null($candidate)) {
                 UnitOfWork::getInstance()->setToCache($candidate);
                 UnitOfWork::getInstance()->scheduleForUpdate($candidate);
             }
         }
     }
     return $res;
 }
 function Candidates()
 {
     return Candidate::get()->filter(array('HasAcceptedNomination' => TRUE))->sort('LastName ASC');
 }
Esempio n. 7
0
 function saveCandidateApplicationForm($data, $form)
 {
     $currentMember = Member::currentUser();
     // A user is logged in
     if ($currentMember) {
         // Load the election system
         $Elections = ElectionSystem::get()->first();
         $CurrentElection = $Elections->CurrentElection();
         if ($Candidate = Candidate::get()->filter(array('MemberID' => $currentMember->ID, 'ElectionID' => $CurrentElection->ID))->first()) {
             // Candidate profile exists
             // Clean up entries ////////////////
             // Set up HTML Purifier
             $config = HTMLPurifier_Config::createDefault();
             // Remove any CSS or inline styles
             $config->set('CSS.AllowedProperties', array());
             $purifier = new HTMLPurifier($config);
             // Clean Bio field
             if ($data["Bio"]) {
                 $currentMember->Bio = $purifier->purify($data["Bio"]);
                 $currentMember->write();
             }
             // Clean RelationshipToOpenStack field
             if ($toClean = $data["RelationshipToOpenStack"]) {
                 $Candidate->RelationshipToOpenStack = $purifier->purify($toClean);
             }
             // Clean Experience field
             if ($toClean = $data["Experience"]) {
                 $Candidate->Experience = $purifier->purify($toClean);
             }
             // Clean BoardsRole field
             if ($toClean = $data["BoardsRole"]) {
                 $Candidate->BoardsRole = $purifier->purify($toClean);
             }
             // Clean HasAcceptedNomination field
             if ($toClean = $data["TopPriority"]) {
                 $Candidate->TopPriority = $purifier->purify($toClean);
             }
             $Candidate->write();
             $questions = array('Bio' => 'Bio', 'RelationshipToOpenStack' => 'RelationshipToOpenStack', 'Experience' => 'Experience', 'BoardsRole' => 'BoardsRole', 'TopPriority' => 'TopPriority');
             // Must answer all questions, but can save work as they go, so we're going to check here rather than set up validators
             if (strlen($data['Bio']) < 4 || strlen($data['RelationshipToOpenStack']) < 4 || strlen($data['Experience']) < 4 || strlen($data['BoardsRole']) < 4 || strlen($data['TopPriority']) < 4) {
                 $Candidate->HasAcceptedNomination = FALSE;
                 $form->saveInto($Candidate);
                 $Candidate->write();
                 $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();
             $form->clearMessage();
             $this->redirect($this->Link() . 'election/');
         } else {
             $form->clearMessage();
             $form->sessionMessage('There was an error saving your edits.', "bad");
             $this->redirectBack();
         }
     }
 }
 function getNominee()
 {
     return Candidate::get()->filter('MemberID', $this->CandidateID)->first();
 }