コード例 #1
0
    def menu_create_application(self):
        self.change_frame('bkend_create_cand_app_frm','Create Candidate')

        # Create position, append to list the remaining available
        positions = classDesign.Position()
        available_positions = self.format_for_combo(
            positions.list_positions_open_for_apps()
        )

        # Create election instance, append to list the election times
        elections = classDesign.Election()
        current_election = elections.list_formatted()

        # Create candidate instance, append to list the candidate names
        candidates = classDesign.Candidate()
        available_candidates = self.format_for_combo(candidates.list())

        # Set choices in combo boxes to lists created.
        self.ui_builder.get_object(
            'bkend_create_cand_app_election_cmbobx'
        ).configure(values=current_election)

        self.ui_builder.get_object(
            'bkend_create_cand_app_cand_cmbobx'
        ).configure(values=available_candidates)

        self.ui_builder.get_object(
            'bkend_create_cand_app_pos_cmbobx'
        ).configure(values=available_positions)
コード例 #2
0
    def vote_select_position(self):
        try:

            # Create election instance, append to list the election times
            elections = classDesign.Election()
            current_election = elections.get_current_election()[0][0]

            self.voting_position = self.get_cmbo_id(
                'stdnt_vote_pos_pos_cmbobx'
            )
        except IndexError:
            # If error (none selected) change label text to error message.
            self.ui_builder.get_object(
                'stdnt_vote_pos_error_lbl'
            ).configure(text="Please enter data for all fields.")
        else:
            # If not except, continue.
            if "" not in (self.voting_position, current_election):
                # If input fields on the page are not empty.
                self.change_frame('stdnt_vote_frm','Voting')

                # Get list of candidates that have an application for position.
                position = classDesign.Position()
                candidate_data = position.list_for_position(
                    self.voting_position
                )

                if not candidate_data:
                    # List returned empty, no candidates.
                    self.ui_builder.get_object(
                        'stdnt_vote_error_lbl'
                    ).configure(text="Error: No candidates.")
                else:
                    candidate_formatted = []
                    for candidate in candidate_data:
                        candidate_temp = classDesign.Candidate(id=candidate[1])
                        candidate_formatted.append(
                            str(candidate[1])
                            + " - "
                            + str(candidate_temp.get_candidate_name())
                        )

                    # Write formatted list to the combobox.
                    self.ui_builder.get_object(
                        'stdnt_vote_first_choice_cmbobx'
                    ).configure(values=candidate_formatted)

                    self.candidate_list = candidate_formatted
コード例 #3
0
    def menu_view_results(self):
        self.change_frame('bkend_sel_results_pos_frm','Select Position')
        # Create election instance, append to list the election times
        elections = classDesign.Election()
        current_election = elections.list_formatted()

        # Create combo box of positions currently available to vote.
        positions = classDesign.Position()
        position_list = self.format_for_combo(positions.list_all_positions())

        # Set choices in combo boxes to lists created.
        self.ui_builder.get_object(
            'bkend_sel_results_pos_election_cmbobx'
        ).configure(values=current_election)

        self.ui_builder.get_object(
            'bkend_sel_results_pos_pos_cmbobx'
        ).configure(values=position_list)
コード例 #4
0
    def fill_vote_page(self):
        self.change_frame('stdnt_vote_pos_sel_frm','Select Position')

        # Create election instance, append to list the election times
        elections = classDesign.Election()
        current_election = elections.list_formatted()

        # Create combo box of positions currently available to vote.
        positions = classDesign.Position()

        position_list = self.format_for_combo(
            positions.list_available_voting_positions(
                self.logged_in_student
            )
        )

        # Set choices in combo boxes to lists created.
        self.ui_builder.get_object(
            'stdnt_vote_pos_election_lbl'
        ).configure(text=current_election[0])

        self.ui_builder.get_object(
            'stdnt_vote_pos_pos_cmbobx'
        ).configure(values=position_list)
コード例 #5
0
    def return_to_student(self):
        results_formatted = ""
        # When returning to student login, if voted, display message.
        if(self.session_voting != []):
            for vote in self.session_voting:
                # Get the name of the position voted for.
                position = classDesign.Position(
                    position_id_query=vote[0]
                ).get_position_title_by_id()
                
                # Get the names of the candidates voted for in each position.
                first_pref_candidate = classDesign.Candidate(
                    id=vote[1]
                ).get_candidate_name()
                
                # If voter only voted for one position, skip names.
                if(vote[2] is not None):
                    second_pref_candidate = classDesign.Candidate(
                        id=vote[2]
                    ).get_candidate_name()
                    
                    third_pref_candidate = classDesign.Candidate(
                        id=vote[3]
                    ).get_candidate_name()
                    
                    fourth_pref_candidate = classDesign.Candidate(
                        id=vote[4]
                    ).get_candidate_name()
                else:
                    second_pref_candidate = "Not Selected"
                    third_pref_candidate = "Not Selected"
                    fourth_pref_candidate = "Not Selected"
                    
                # Format into clean list for print and messagebox.
                results_formatted += "Voted Position: " \
                    + position \
                    + " -- First Choice: " \
                    + first_pref_candidate \
                    + " -- Second Choice: " \
                    + second_pref_candidate \
                    + " -- Third Choice: " \
                    + third_pref_candidate \
                    + " -- Fourth Choice: " \
                    + fourth_pref_candidate \
                    + "\n"

            self.change_frame('stdnt_vote_receipt_frm','Vote Receipt')
            
            self.ui_builder.get_object(
                'stdnt_vote_receipt_contents_lbl'
            ).configure(text='You\'ve voted! Your votes:\n' + results_formatted)
            
            # Print receipt to console in addition to screen.
            print(results_formatted)
            
            # Clear session voting log.
            self.session_voting = []
                    
        else:
            messagebox.showinfo("Vote Receipt", "No votes submitted.")
            self.change_frame('stdnt_login_frm','Student Login')
コード例 #6
0
    def startup_select_student(self):
        self.change_frame('stdnt_login_frm','Login')
        
        # Description function call - from Aiden in the hackathon.
		position_display = classDesign.Position()