Skip to content

Commit 3d8f869

Browse files
Merge pull request #20 from HackNCState/kkozturk/add-remaining-core
Add core features
2 parents 8364879 + 4bad967 commit 3d8f869

56 files changed

Lines changed: 4195 additions & 762 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ i hope this all works if not let me know
77
### Prerequisites
88

99
- `service-account.json` file with access to the Google Sheets API (let me know if you need access)
10+
- `CLIENT_SECRET` value for Discord OAuth2 (let me know if you need this)
1011
- Your Discord username in the Registration Google Sheet (so you can log in)
1112

1213
### 1. Tooling
@@ -21,21 +22,21 @@ i hope this all works if not let me know
2122
1. Create a Python virtual environment:
2223

2324
```bash
24-
python -m venv .venv
25+
python -m venv functions/venv
2526
```
2627

2728
2. Activate the virtual environment:
2829
- On Windows:
2930

3031
```powershell
31-
.venv\Scripts\activate
32+
functions\venv\Scripts\activate
3233
```
3334
3435
- On macOS/Linux:
3536
36-
```bash
37-
source .venv/bin/activate
38-
```
37+
```bash
38+
source functions/venv/bin/activate
39+
```
3940
4041
3. Install the required Python packages:
4142
@@ -51,6 +52,14 @@ i hope this all works if not let me know
5152

5253
5. This isn't best practice but we're using a service account file to allow you to access the spreadsheet data locally. Let me know and I'll share the file with you. Place it in the root of the project as `service-account.json`.
5354

55+
6. You'll also need a file `functions/.env.local` with the following content:
56+
57+
```env
58+
CLIENT_SECRET=<???>
59+
```
60+
61+
Let me know and I'll share the client secret with you.
62+
5463
### 3. Running Locally
5564

5665
1. Run the backend emulator suite:
@@ -69,6 +78,9 @@ i hope this all works if not let me know
6978
firebase emulators:start --project=hackncsu-today
7079
```
7180
81+
The emulator will ask you to configure some parameters. I set defaults for these
82+
so you can just hit enter to accept them.
83+
7284
2. Run the frontend:
7385
7486
```bash

firestore.rules

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ rules_version = '2';
22

33
service cloud.firestore {
44
match /databases/{database}/documents {
5-
6-
// Helper function to check for organizer role
5+
6+
// Helper function to check for organizer role
77
function isOrganizer() {
88
return request.auth.token.isOrganizer == true;
99
}
@@ -22,10 +22,6 @@ service cloud.firestore {
2222
// Team members can read the entire team document.
2323
allow read: if request.auth.uid in resource.data.memberIds;
2424

25-
// Team members can only update the 'checklist' field.
26-
allow update: if request.auth.uid in resource.data.memberIds &&
27-
request.resource.data.diff(resource.data).affectedKeys().hasOnly(['checklist']);
28-
2925
// Prevent members from creating or deleting teams (only organizers can do that via the global rule)
3026
allow create, delete: if false;
3127
}

functions/api.py

Lines changed: 0 additions & 121 deletions
This file was deleted.

functions/auth/models.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
from dataclasses import dataclass, field
2-
from typing import Optional
3-
2+
from typing import Literal, Optional
43

54
@dataclass
65
class User:
76
id: str
87
"""Unique identifier for the user. Probably their Discord ID"""
98

10-
role: str # 'participant' | 'organizer'
9+
role: Literal['participant', 'organizer'] # 'participant' | 'organizer'
1110
username: str
1211

1312
# registration info (required for participant data structure)
@@ -19,10 +18,9 @@ class User:
1918
dietaryRestrictions: Optional[str] = None
2019
rfidUUID: Optional[str] = None
2120

22-
# init event info
21+
# init event info (there may be more defined in the frontend...just because these are the ones used in auth)
2322
teamId: Optional[str] = None # this will be unset (undefined) until team assignment
2423
attendedEvents: list[str] = field(default_factory=list)
25-
isOrganizer: bool = False
2624

2725
attrs: list[str] = field(default_factory=list)
2826
"""Additional per-user attributes for future use."""

functions/auth/oauth_callback.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
) # set this via command: firebase functions:secrets:set CLIENT_SECRET
1919
REDIRECT_URI = StringParam(
2020
"REDIRECT_URI",
21-
default="https://us-central1-hackncsu-today.cloudfunctions.net/oauth_callback",
21+
default="http://127.0.0.1:5001/hackncsu-today/us-central1/oauth_callback",
2222
description="The redirect URI for Discord OAuth2.",
23-
) # set to http://127.0.0.1:5001/hackncsu-today/us-central1/oauth_callback in .env.local for local testing
23+
) # set to https://us-central1-hackncsu-today.cloudfunctions.net/oauth_callback for prod deploys
2424
FRONTEND_AUTH_URI = StringParam(
2525
"FRONTEND_AUTH_URI",
26-
default="https://today.hackncstate.org/auth",
26+
default="http://localhost:8080/auth ",
2727
description="The frontend URI to redirect to after authentication is complete.",
28-
) # set to http://localhost:8080/auth in .env.local for local testing
28+
) # set to https://today.hackncstate.org/auth for prod deploys
2929
# set to https://hackncsu-today--dev-maisszg5.web.app/auth for dev deploys
3030

3131
SPREADSHEET_URL = StringParam(
@@ -154,14 +154,17 @@ def _get_registration(uid: str, username: str) -> User:
154154
checked_in_idx = _get_col_index_from_headers(
155155
checkin_headers, CHECKED_IN_COL_C.value
156156
)
157-
checked_in = _get_cell_from_row(checkin_row, checked_in_idx)
157+
checked_in = _get_cell_from_row(checkin_row, checked_in_idx).upper()
158158

159159
# participant did not check in
160-
if str(checked_in).upper() != "TRUE":
160+
if checked_in == "NO":
161161
raise ValueError(
162162
"not_checked_in",
163163
)
164164

165+
# if checked in friday
166+
friday_checked_in = checked_in == "FRIDAY"
167+
165168
shirt_size_idx = _get_col_index_from_headers(
166169
reg_headers, SHIRT_SIZE_COL_R.value
167170
)
@@ -214,6 +217,8 @@ def _get_registration(uid: str, username: str) -> User:
214217
dietaryRestrictions=dietary_restrictions,
215218
shirtSize=shirt_size,
216219
rfidUUID=rfid_uuid,
220+
# mark if they checked in on friday as having attended the career fair event
221+
attendedEvents=["career_fair_friday"] if friday_checked_in else [],
217222
)
218223

219224

0 commit comments

Comments
 (0)