Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMurn #9

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ LOGIN_URL=https://login.datasektionen.se
LOGIN_KEY=asdfasdfasdfsadfsadfasdf
PLS_URL=https://pls.datasektionen.se

DB_URL=postgresql://<user>:<pwd>@localhost:5432/durn
DATABASE_URL=postgresql://<user>:<pwd>@localhost:5432/durn
9 changes: 5 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# dUrn - the voting system
# smUrn - Digitala omröstningar

This is a implementation of a voting system for the Computer Science Chapter, with a backend written in golang and a frontend written in Typescript React.
This is a implementation of another voting system for the Computer Science Chapter, with a backend written in golang and a frontend written in Typescript React.



Expand All @@ -25,7 +25,8 @@ The system uses the following permissions in pls:
| `LOGIN_URL` | `https://login.datasektionen.se` | url for the login system and API |
| `LOGIN_KEY` | | API-key for the login system |
| `PLS_URL` | `https://pls.datasektionen.se` | url for the permissions system pls |
| `DATABASE_URL` | | postgres-url for connecting to the database instance |
| `PLS_SYSTEM_NAME` | `durn` | the system to check for permissions in pls |
| `DATABASE_URL` | | postgres-url for connecting to the database instance |


## How to run
Expand All @@ -44,4 +45,4 @@ The system uses the following permissions in pls:
2. Setup environment variables
3. Run `make prod` in root

The system also has a `dockerfile` setup for deployment.
The system also has a `dockerfile` setup for deployment.
36 changes: 3 additions & 33 deletions client/src/components/AdminElectionView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,49 +80,19 @@ export const AdminElectionView: React.FC<AdminElectionViewProps> = ({
<form onSubmit={onSubmit}>
<Grid>
<Grid.Col md={3}>
<div style={{ marginBottom: "3rem" }} >
<Text align="center" size="lg" color="gray.7" fw={700}>
Election starts
</Text>
<DateTimeInput
onChange={onOpenTimeChanged}
defaultDate={openTimeDefault}
/>
</div>

<div style={{ marginBottom: "2rem" }} >
<Text align="center" size="lg" color="gray.7" fw={700}>
Election ends
</Text>
<DateTimeInput
onChange={onCloseTimeChanged}
defaultDate={closeTimeDefault}
/>
</div>

<div style={{ marginBottom: "2rem" }} >
<Text align="center" size="lg" color="gray.7" fw={700}>
Mandates
Antal alternativ att välja
</Text>
<NumberInput width="3rem"
{...electionForm.getInputProps("mandates")}
min={1}
/>
</div>

<div style={{ marginBottom: "2rem" }} >
<Text align="center" size="lg" color="gray.7" fw={700}>
Secondary mandates
</Text>
<NumberInput
{...electionForm.getInputProps("extraMandates")}
min={0}
/>
</div>

<div>
<Text size="lg" fw={700} align="center">
Submitted votes
Antal röster
</Text>
<Text align="center">
{submittedVotes ?? "-"}
Expand Down Expand Up @@ -162,4 +132,4 @@ export const AdminElectionView: React.FC<AdminElectionViewProps> = ({
</form>
</Box>
</>;
}
}
4 changes: 2 additions & 2 deletions client/src/components/Authentication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "react-router-dom";

export const Login: React.FC = () => {
const loginURL = "https://login.datasektionen.se"
const loginURL = "https://sso.datasektionen.se/legacyapi"

const callback = encodeURIComponent(`${window.location.origin}/#/token/`)
const url = `${loginURL}/login?callback=${callback}`;
Expand Down Expand Up @@ -83,4 +83,4 @@ export const Token: React.FC = () => {
}, [token])

return <></>;
}
}
12 changes: 6 additions & 6 deletions client/src/components/CandidateList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ export const CandidateList: React.FC<CandidateListProps> = (
<td>
<TextInput
value={name}
placeholder="candidate name"
placeholder="Alternativ"
onChange={(element) => setName(element.target.value)}
/>
</td>
<td>
<TextInput
value={presentation}
placeholder="link to candidate presentation"
placeholder="beskrivning (optional)"
onChange={(element) => setPresentation(element.target.value)}
/>
</td>
Expand All @@ -83,7 +83,7 @@ export const CandidateList: React.FC<CandidateListProps> = (


<Text fw={700} c="gray.7" style={{ margin: "0.5rem", marginTop: "1rem" }} align="center">
Add new candidate
Lägg till alternativ
</Text>

<Table withBorder withColumnBorders>
Expand All @@ -108,12 +108,12 @@ export const CandidateList: React.FC<CandidateListProps> = (
<th style={{ width: 30 }}></th>
<th>
<Text style={{ margin: "1rem" }} align="center" fw={700}>
Name of the candidate
Alternativ
</Text>
</th>
<th>
<Text style={{ margin: "1rem" }} align="center" fw={700}>
Candidate presentation
Beskrivning
</Text>
</th>
</tr>
Expand Down Expand Up @@ -183,4 +183,4 @@ const CandidateRow: React.FC<CandidateRowProps> = (
</td>
</tr>
</>
};
};
24 changes: 13 additions & 11 deletions client/src/components/DisplayResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,17 @@ export const DisplaySchultzeResult: React.FC<DisplaySchultzeProps> = ( {
}

return <>
<h3><Center>Election Result</Center></h3>
<h3><Center>Röstresultat</Center></h3>

{firstSymbolic > 0 && <>
<Text align="center">
Ordinarie
SM föredrog följande alternativ
</Text>
<Table striped withColumnBorders>
<thead>
<tr>
<th style={{ width: "6rem" }}> Rank </th>
<th> Candidate </th>
<th> Alternativ </th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -214,13 +214,13 @@ export const DisplaySchultzeResult: React.FC<DisplaySchultzeProps> = ( {
{(ranking.length > election.mandates + election.extraMandates ||
firstSymbolic < ranking.length) && <>
<Text align="center">
Non-Elected
SM föredrog INTE följade alternativ
</Text>
<Table striped withColumnBorders>
<thead>
<tr>
<th style={{ width: "6rem" }}> Rank </th>
<th> Candidate </th>
<th> Alternativ </th>
</tr>
</thead>
<tbody>
Expand All @@ -245,7 +245,7 @@ export const DisplaySchultzeResult: React.FC<DisplaySchultzeProps> = ( {
</Table>

<br/>
<h3><Center>Voting data</Center></h3>
<h3><Center>Röstdata</Center></h3>
<DisplayVoteData
ranking={ranking}
voteMatrix={voteMatrix}
Expand Down Expand Up @@ -304,7 +304,10 @@ const DisplayVoteData: React.FC<DisplayVoteMatrixProps> = (
</>;

return <>
<b>Candidate index:</b>

<p><b> Totala antalet röster: </b> {votes} </p>

<b>Alternativindex:</b>
<List style={{margin: "1rem"}}>
{ranking.map((c, i) => (
<List.Item icon={<Text fw={700}>{labels[i]} </Text>}>
Expand All @@ -313,10 +316,9 @@ const DisplayVoteData: React.FC<DisplayVoteMatrixProps> = (
))}
</List>

<p><b> Total amount of votes: </b> {votes} </p>

<h4><Text align="center" fw={700}>
Vote matrix
Röstmatris
</Text></h4>
<DisplayMatrix matrix={voteMatrix} name="d" />
<br />
Expand All @@ -326,7 +328,7 @@ const DisplayVoteData: React.FC<DisplayVoteMatrixProps> = (

<br />
<h4><Text align="center" fw={700}>
Schultze result matrix
Schulzeresultatmatris
</Text></h4>
<DisplayMatrix matrix={schultzeMatrix} name="p" />
<br />
Expand All @@ -342,4 +344,4 @@ const DisplayVoteData: React.FC<DisplayVoteMatrixProps> = (
</Text>

</>
}
}
4 changes: 3 additions & 1 deletion client/src/components/ElectionInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const DisplayElectionInfo: React.FC<DisplayElectionInfoProps> = (
<div className={classes.electionTitle}>
<h3 className={classes.electionTitle}>{election.name}</h3>
</div>
{/*
<p className={classes.electionDescription}>
{election.description}
</p>
Expand All @@ -100,6 +101,7 @@ export const DisplayElectionInfo: React.FC<DisplayElectionInfoProps> = (
<p className={classes.candidateText}>
<b>{election.extraMandates}</b> Secondary mandates
</p> }
*/}
</div>
</>
}
}
Loading