5.3 Society Invite Link Generation
You can view the walkthrough video here:
https://www.youtube.com/embed/JO-732wtZTw
The homepage has two main components and many subcomponents.
- The Elections in Progress table is a list of every election in progress on the site.
- The Closed Elections table is a list of all elections closed on the site.
Every election can be searched through at the top of the Elections in Progress table using the search bar. The search bar has two filters, each swapped by clicking the rotate icon next to the current filter.
The Name Filter searches through the names of the elections and displays matching elections.
The Election ID Filter takes numbers as input and matches to one election.
The table can be manually reloaded using the Refresh button to the far right of the search bar. The table can be completely collapsed by clicking the Hide button next to refresh, to free up some screen space. All tables on the site have a button to collapse the table.
Each election in the table displays six different columns of data.
- Election ID
- Election Name
- Society Name (if any)
- Total Candidates in the Election
- Election current status
- A button to view the election
Clicking the view button on an election will bring you to the dedicated election page for that election.
The election page displays a Candidate Table and a Voting Form.
The candidate table has three different fields:
- Name of Candidate
- Position Applying For
- Votes Acquired
If the election is linked to a society, the name of the society is displayed beneath the title of the candidate table.
The Voting Form displays the current state of the election and the date & time for the start and end of the election. Elections can be in one of four states:
- Awaiting Start
- Pending Start
- Active
- Closed
When an election is created, is to automatically set to the Awaiting Start state. The start and end dates have not been specified yet, and it is not possible to vote for candidates.
When the election start and end dates are set by the owner of the election, the election changes state. If the start date is later than the current date, the election is set to the Pending Start state. Whilst the election is pending, you can add and remove candidates, and change the name of the election. Votes cannot be casted whilst the election is pending.
If the start date of the election is set before the current date, the election will be Active immediately. Once the election is Active, the owner loses the ability to edit the election and users can start voting. The election will end when the end date is reached.
If an election reaches its end date, the system automatically closes the election and derives a winner. You can still see the start and end dates of the election. The voting form is replaced with the winner of the election, and the person you voted for if you voted in the election. There can be multiple winners of an election if two or more candidates have the same amount of votes when it ends.
You can select a candidate from the drop down menu and click vote to process the vote. Once a vote has been made, you will not be able to vote for anyone else in this election. The voting form will automatically change and display the name of the person you voted for.
If the election is in the Awaiting Start State and you are the owner of the election, you will see four different components to edit the details of the election.
- Change Election Name
- Add Candidates to Election
- Delete Candidates from Election
- Set Start and End date of Election
Candidates can be added and removed from the election using the two forms provided. The name of the election can also be changed.
The start date can be set to Now or Specific Date. The date can be entered by first changing "Now" in the drop down select to "Specific date" and using the user interface popup to select a time and date.
The end date can be entered the same way as the start date, simply click on the date to change it using the popup interface.
You can navigate to the accounts page by clicking the user icon in the far right of the navigation bar. If this is your first time on the site, you will be prompted to enter a name.
After entering a name, the accounts page is loaded. This page has three main components.
- Account Information
- Create an Election Form
- Your Elections
This component displays the users name, the date they joined the site, societies they own and their metamask account number.
This component allows the user to create new elections. The input requires an election name and has an optional drop down menu for specifying a certain society. If a society is selected, only users that are a member of that society will be able to vote.
This component is a table that displays every election that your account has created. When you create an election it will be placed in the Awaiting Start state and can be made Active by clicking the Setup button in the last column of the table. This will bring you to the elections dedicated page described above. The table can be hidden using the Hide Table button beneath. The table can be refreshed using the Refresh button below.
You can navigate to the societies page by clicking the multi user icon in the far right of the navigation bar. This page has four main components.
- Society Memberships
- Societies you Manage
- Society Creation Form
- Society Invite Link Generation Form
You can view all the societies you are a member of under the Society Memberships component. The orange exit button will leave the societies group and you will have to be invited back to rejoin.
You can view the societies that you have created under the Societies you Manage component. The orange link button copies a link to your clipboard. If users enter the link into their search bar, they will automatically join the society. The orange cross button will delete the society.
If you want the invite link to expire, you can set the expire time for any society you own in the Society Invite Link Generation component. Clicking create will automatically copy the link to your clipboard.
In order to prevent invite codes from being used by unwanted members, you may set a max-use amount between 1 and 20. After the invite code has been used this number of times it will no longer function.
New societies can be created on the accounts page using the Society Creation Form component. You can set the name of the society and an email to link the society to the owner. Only the person that created the society will have control over its features. Adding an email is optional.
To run unit tests on the Solidity contract, first make sure you are in the code directory. Then execute the following command:
truffle test
This executes the unit tests located in the test directory. Truffle uses the Mocha testing framework and Chai for assertions on the Solidity smart contract. The tests will run and check that essential system functionality is operational, for example creating elections, adding candidates and voting.