Skip to content

Commit 7fc3193

Browse files
Initial commit
0 parents  commit 7fc3193

29 files changed

+3848
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "Python 3",
3+
"image": "mcr.microsoft.com/vscode/devcontainers/python:3.13",
4+
"forwardPorts": [8000],
5+
"postCreateCommand": "bash ./.devcontainer/postCreate.sh",
6+
"customizations": {
7+
"vscode": {
8+
"extensions": [
9+
"GitHub.copilot",
10+
"ms-python.python",
11+
"ms-python.debugpy",
12+
"mongodb.mongodb-vscode"
13+
]
14+
}
15+
}
16+
}

.devcontainer/installMongoDB.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# Install MongoDB
4+
wget -qO - https://www.mongodb.org/static/pgp/server-7.0.asc | sudo apt-key add -
5+
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
6+
sudo apt-get update
7+
sudo apt-get install -y mongodb-org
8+
9+
# Create necessary directories and set permissions
10+
sudo mkdir -p /data/db
11+
sudo chown -R mongodb:mongodb /data/db
12+
13+
# Start MongoDB service
14+
sudo mongod --fork --logpath /var/log/mongodb/mongod.log
15+
16+
echo "MongoDB has been installed and started successfully!"
17+
mongod --version
18+
19+
# Run sample MongoDB commands
20+
echo "Current databases:"
21+
mongosh --eval "db.getMongo().getDBNames()"

.devcontainer/postCreate.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Prepare python environment
2+
pip install -r requirements.txt
3+
4+
# Prepare MongoDB Dev DB
5+
./.devcontainer/installMongoDB.sh

.github/steps/1-protect-your-code.md

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# Step 1: Protect your code
2+
3+
It's been a busy month at Mergington High! Your simple website for managing extra-curricular activities has really taken off. What started as a basic sign-up form for a few activities has grown into the go-to place for half the school activities. 📚✨
4+
5+
Principal Martinez was so impressed with your work that they announced at the last staff meeting that ALL clubs should start using the website. While this is exciting, you're a bit nervous - the last thing you want is an accidental change breaking the system right before the big Fall Activities Fair! 😰
6+
7+
When more teachers start helping with the Mergington High activities website, it's important to add some safeguards. Thankfully, GitHub provides several ways to protect your repository:
8+
9+
1. **Repository Rulesets** - These provide safeguards to limit:
10+
11+
- Pushing code directly to important branches
12+
- Deleting or renaming branches
13+
- Force pushing (which can overwrite history)
14+
- (and much more)
15+
16+
1. **`.gitignore`** - This special file tells Git which files it should NOT track, like:
17+
18+
- Temporary files that your code creates while running
19+
- Secret configuration files with sensitive information
20+
- System files that other developers don't need
21+
22+
> [!TIP]
23+
> Think of these settings like the editorial process of a school yearbook. Various student committees will take photos and write articles, then the yearbook president will make adjustments to make sure everything flows together properly. Finally, a teacher/advisor will sign off that all content is appropriate.
24+
25+
## ⌨️ Activity: (optional) Get to know our extracurricular activities site
26+
27+
<details>
28+
<summary>Show Steps</summary>
29+
30+
In other exercise, we have been developing the Extracurricular activities website. You can follow these steps to start up the development environment and try it out.
31+
32+
> ! **Important:** Opening a development environment and running the application is not necessary to complete this exercise. You can skip this activity if desired.
33+
34+
1. Right-click the below button to open the **Create Codespace** page in a new tab. Use the default configuration.
35+
36+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/{{full_repo_name}}?quickstart=1)
37+
38+
1. Wait some time for the environment to be prepared. It will automatically install all requirements and services.
39+
40+
1. Validate the **GitHub Copilot** and **Python** extensions are installed and enabled.
41+
42+
<img width="300" alt="copilot extension for VS Code" src="https://github.com/user-attachments/assets/ef1ef984-17fc-4b20-a9a6-65a866def468" /><br/>
43+
<img width="300" alt="python extension for VS Code" src="https://github.com/user-attachments/assets/3040c0f5-1658-47e2-a439-20504a384f77" />
44+
45+
1. Try running the the application. In the left sidebar, select the **Run and Debug** tab and then press the **Start Debugging** icon.
46+
47+
<details>
48+
<summary>📸 Show screenshot</summary><br/>
49+
50+
<img width="300" alt="run and debug" src="https://github.com/user-attachments/assets/50b27f2a-5eab-4827-9343-ab5bce62357e" />
51+
52+
</details>
53+
54+
<details>
55+
<summary>🤷 Having trouble?</summary><br/>
56+
57+
If the **Run and Debug** area is empty, try reloading VS Code: Open the command palette (`Ctrl`+`Shift`+`P`) and search for `Developer: Reload Window`.
58+
59+
<img width="300" alt="empty run and debug panel" src="https://github.com/user-attachments/assets/0dbf1407-3a97-401a-a630-f462697082d6" />
60+
61+
</details>
62+
63+
1. Use the **Ports** tab to find the webpage address, open it, and verify it is running.
64+
65+
<details>
66+
<summary>📸 Show screenshot</summary><br/>
67+
68+
<img width="350" alt="ports tab" src="https://github.com/user-attachments/assets/8d24d6b5-202d-4109-8174-2f0d1e4d8d44" />
69+
70+
![Screenshot of Mergington High School WebApp](https://github.com/user-attachments/assets/5e1e7c1e-1b0e-4378-a5af-a266763e6544)
71+
72+
</details>
73+
74+
</details>
75+
76+
## ⌨️ Activity: Add a branch ruleset
77+
78+
To get started, let's add some protections so that no one accidentally breaks the club registration system.
79+
80+
1. If necessary, open another tab and navigate to this repository. We will start on the **Settings** tab.
81+
82+
1. In the left navigation, expand the **Rules** area and select **Rulesets**.
83+
84+
1. Click the **New ruleset** dropdown and select **New branch ruleset**.
85+
86+
<img width="250" alt="image" src="https://github.com/user-attachments/assets/1e9fd519-1421-4d6b-b654-a3fe53a8fb75" />
87+
88+
1. Set the **Ruleset Name** as `Protect main` and change the **Enforcement status** to `Active`.
89+
90+
<img width="250" alt="image" src="https://github.com/user-attachments/assets/ce30fd34-39b5-4e22-b348-4af61fd05cd1" />
91+
92+
1. Find the **Targets** section and use the **Add target** dropdown to add 2 entries:
93+
94+
1. Add the **Include default branch** option to ensure protections aren't bypassed by switching the default branch.
95+
96+
<img width="250" alt="image" src="https://github.com/user-attachments/assets/217263cc-d5c2-4ac0-b03c-a72494e5c812" />
97+
98+
1. Use the **include by pattern** option and enter the pattern `main`.
99+
100+
<img width="250" alt="image" src="https://github.com/user-attachments/assets/968c9ed8-b051-44eb-af42-d99670ad31fd" />
101+
102+
<img width="250" alt="image" src="https://github.com/user-attachments/assets/ddc52767-d93e-4c9e-a77a-90c3b5c08fb5" />
103+
104+
1. Find the **Rules** section and ensure the following items are checked.
105+
106+
- [x] Restrict deletions
107+
- [x] Require a pull request before merging
108+
- Required approvals: `0`
109+
- [x] Require review from Code Owners
110+
- [x] Block force pushes
111+
112+
1. Scroll to the bottom and click the **Create** button to save the ruleset.
113+
114+
## ⌨️ Activity: Create a `.gitignore` file
115+
116+
We know many teachers use different tools, so let's make sure they don't accidentally commit unnecessary files.
117+
118+
1. At the top navigation, return to the **Code** tab and verify you are on the `main` branch.
119+
120+
1. Above the list of files, click the **Add file** dropdown and select **Create new file**.
121+
122+
<img width="300" alt="New file button" src="https://github.com/user-attachments/assets/8f3f8da8-1471-485a-9df5-8c03ecba2d8e"/>
123+
124+
1. Enter the file name `.gitignore`. We will ignore the template selector for now and make our own. Copy the below example content into it.
125+
126+
<img width="350" alt="preview of new file" src="https://github.com/user-attachments/assets/580d1a63-a264-4d44-8901-50ad708b8822"/>
127+
128+
```gitignore
129+
# Python backend for club management
130+
__pycache__/
131+
*.py[cod] # Python compiled files
132+
*$py.class
133+
*.so
134+
.Python
135+
env/
136+
.env # Where database passwords are stored
137+
venv/ # Virtual environment for testing
138+
.venv
139+
140+
# Teacher IDE settings
141+
.vscode/ # Ms. Rodriguez uses VS Code
142+
.idea/ # Mr. Chen uses PyCharm
143+
144+
# Local development & testing
145+
instance/
146+
.pytest_cache/
147+
.coverage # Test coverage reports
148+
htmlcov/
149+
150+
# Staff computer files
151+
.DS_Store # For teachers with Macs
152+
Thumbs.db # For teachers with Windows
153+
```
154+
155+
1. In the top right, select the **Commit changes...** button. Notice that it won't let us commit to the `main` branch! Our ruleset is working! Nice!
156+
157+
<img width="400" alt="image" src="https://github.com/user-attachments/assets/4e85948d-75c8-4c13-8ddd-4707bf9b0805" />
158+
159+
1. Enter `prepare-to-collaborate` for the branch name then click the **Propose changes** button. You will be forwarded to a new page to start a new pull request.
160+
161+
1. Set the title to `Prepare to collaborate` and click the **Create pull request** button. **Do NOT merge yet**, since we will be adding more collaboration related changes.
162+
163+
1. With the file committed, wait a moment for Mona to check your work, provide feedback, and share the next lesson.
164+
165+
> [!TIP]
166+
> GitHub and the community have built a repository with [sample `.gitignore` files](https://github.com/github/gitignore) for many situations. Make sure to check it out!
167+
168+
<details>
169+
<summary>🤷 Having trouble?</summary><br/>
170+
171+
Make sure you pushed the `.gitignore` file to `prepare-to-collaborate` branch. Exact naming for both matters!
172+
173+
</details>
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Step 2: Prepare to collaborate
2+
3+
Your simple school website has become quite popular! After showing it at the last staff meeting, Ms. Rodriguez from the Art Club and Mr. Chen from the Chess Club came up to you super excited. They have tons of ideas for new features!
4+
5+
- Ms. Rodriguez wants to add a photo gallery
6+
- Mr. Chen dreams of adding a tournament bracket system for the chess/sports activities! 🎨♟️
7+
8+
While you're thrilled about their enthusiasm, you realize you need to set up some guidelines before letting them start changing code. The last thing you want is conflicting changes breaking the registration system right before spring break!
9+
10+
Opening your project to other teachers at Mergington High means thinking about how everyone will collaborate together without breaking each other's code.
11+
12+
**Collaborators** are the people you have granted write access to the project through repository settings.
13+
14+
- Provide other people permissions to change project files while still protecting repository settings.
15+
- Personal repositories have simple permissions. Organization repositories allow flexible permissions such as read, write, maintain, and admin.
16+
17+
To help with collaboration, GitHub provides two special files:
18+
19+
1. **`CONTRIBUTING.md` file** - A "How to Help" guide. Some example content:
20+
21+
- How to prepare a developer setup of the extra-curricular activities website.
22+
- The process for suggesting changes.
23+
- The project's coding style preference, to keep things consistent.
24+
- How to ask for help when stuck.
25+
26+
1. **`CODEOWNERS` file** - Assign specific people or teams responsible for a portion of the project.
27+
28+
- When someone creates a pull request, GitHub will automatically ask the right person to review it.
29+
30+
## ⌨️ Activity: Create a welcoming contribution guide
31+
32+
The IT Club meeting is tomorrow, and you need to prepare for Ms. Rodriguez and Mr. Chen to join the project. Let's start a document to help them contribute effectively.
33+
34+
1. At the top navigation, return to the **Code** tab. Ensure you are on the `prepare-to-collaborate` branch.
35+
36+
<img width="350" alt="image showing the correct branch" src="https://github.com/user-attachments/assets/68cd1e7a-1b34-47eb-9f0b-095d47442b12" />
37+
38+
1. In the top directory, create a new file called `CONTRIBUTING.md` (case sensitive).
39+
40+
1. Add a welcoming message.
41+
42+
```md
43+
# Contributing to the Mergington High Extra-Curricular Activities Website
44+
45+
Thank you for your interest in helping improve our school's website!
46+
Whether you want to add your club's activities, fix a bug, or suggest
47+
new features, this guide will help you get started. 🎉
48+
```
49+
50+
1. Add instructions to help teachers quickly start developing.
51+
52+
```md
53+
## Development Setup
54+
55+
1. Clone the repository to your computer.
56+
2. Install Python requirements: `pip install -r requirements.txt`.
57+
3. Run the development server: `python src/app.py`.
58+
4. Visit http://localhost:8000 in your browser to see the website.
59+
60+
## Making Changes
61+
62+
1. Create a new branch for your changes.
63+
- Use descriptive names like `art-gallery-feature` or `fix-chess-signup`
64+
2. Make your changes and test them locally with sample student data.
65+
- Use the MongoDB extension to preview the included sample date.
66+
3. Push your branch and create a pull request.
67+
4. Wait for review and address any feedback.
68+
69+
## Code Style
70+
71+
- Follow PEP 8 for Python code (backend).
72+
- Use clear, descriptive variable names (student_name, start_time, etc.)
73+
- Add comments to describe blocks of logic.
74+
```
75+
76+
1. Add a section for getting help.
77+
78+
```md
79+
## Need help or have ideas?
80+
81+
- Check the open issues first.
82+
- If your problem is there, add a comment or up-vote.
83+
- If not there, create a new issue. Be as descriptive as possible.
84+
- Ask in our weekly IT Club office hours (Thursdays at lunch in Room 203).
85+
- For other general problems, email the tech team at [email protected]
86+
```
87+
88+
1. In the top right, use the **Commit changes...** button and commit your changes directly to `prepare-to-collaborate` branch.
89+
90+
## ⌨️ Activity: Assign code ownership
91+
92+
With others joining the fun, you want to stay involved on anything affecting architecture and core functionality. Let's assign you to the related files.
93+
94+
1. At the top navigation, return to the **Code** tab. Ensure you are on the `prepare-to-collaborate` branch.
95+
96+
1. In the top directory, create a new file called `CODEOWNERS` (case sensitive and no extension).
97+
98+
1. Add the following content:
99+
100+
```codeowners
101+
# Core functionality - changes here should be rare!
102+
/src/app.py @{{ login }}
103+
/src/backend/database.py @{{ login }}
104+
/src/backend/routers/auth.py @{{ login }}
105+
106+
# The frontend will need refactored soon to be more object oriented.
107+
/src/static/ @{{ login }}
108+
```
109+
110+
1. In the top right, use the **Commit changes...** button and commit your changes directly to `prepare-to-collaborate` branch.
111+
112+
1. With the files committed, wait a moment for Mona to check your work, provide feedback, and share the next lesson.
113+
114+
## ⌨️ Activity: (Optional) Add your first collaborator
115+
116+
Ready to let your colleague start working on that photo gallery feature? Let's do it!
117+
118+
> [!IMPORTANT]
119+
> This step is optional because it requires another person with a GitHub account to participate.
120+
121+
1. In the top navigation, select the **Settings** tab.
122+
123+
1. In the left navigation, select **Collaborators**.
124+
125+
1. Find the **Manage access** area and click the **Add people** button.
126+
127+
<img width="350" alt="" src="https://github.com/user-attachments/assets/686c32c6-11c2-4e69-bad1-39062d5b4376" />
128+
129+
1. Enter a friend/colleague's GitHub username or email then press the **Add to repository** button.
130+
131+
<img width="350" alt="" src="https://github.com/user-attachments/assets/d0eaf344-baf0-4a9c-9291-c11e7a9fdaa3" />
132+
133+
> [!IMPORTANT]
134+
> Personal repositories only have one collaboration role type. A "collaborator" receives **write** permissions but NOT **admin** permissions. If you need finer permissions, consider starting a free [organization](https://docs.github.com/en/organizations/collaborating-with-groups-in-organizations/about-organizations) and assigning [repository roles](https://docs.github.com/en/organizations/managing-user-access-to-your-organizations-repositories/managing-repository-roles/repository-roles-for-an-organization).

0 commit comments

Comments
 (0)