You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`mongodb-org-shell` is already installed; use `mongosh` to interact with MongoDB.
11
12
13
+
# Database Initialization & Population
14
+
1. Ensure the MongoDB service is running.
15
+
2. Configure Django in `octofit-tracker/backend/octofit_tracker/settings.py` to connect to the `octofit_db` database using Djongo, with no authentication.
16
+
3. Make sure `octofit_tracker`, `rest_framework`, and `djongo` are in `INSTALLED_APPS`.
17
+
4. Enable CORS in `settings.py` to allow all origins, methods, and headers. Allow all hosts.
18
+
5. Install and configure CORS middleware components.
19
+
6. Run `makemigrations` and `migrate` in the Python virtual environment.
20
+
7. Initialize the `octofit_db` database and create collections for users, teams, activities, leaderboard, and workouts.
21
+
8. Ensure a unique index on the `email` field for the user collection (e.g., `db.users.createIndex({ "email": 1 }, { unique: true })`).
22
+
9. Populate the database with test data for all collections using the Django management command in `octofit-tracker/backend/octofit_tracker/management/commands/populate_db.py` (help message: 'Populate the octofit_db database with test data').
23
+
10. Verify the database and collections were created and populated successfully using `mongosh`.
24
+
11. List the collections in the `octofit_db` database and show sample documents from each.
12
25
13
-
To init and populate the octofit_db database follow these steps.
14
-
1. Make sure the mongodb service is running.
15
-
2. Initialize the mongodb octofit_db database.
16
-
3. Create a correct table structure for users, teams, activities, leaderboard, and workouts collections.
17
-
4. Make sure there is a unique ID for the primary key for the user collection.
> Let's install, start, and verify mongodb-org service for Ubuntu 22.
38
-
>
39
-
> 1. Start mongo db manually
40
-
> 2. Verify mongodb is running manually
41
-
>
42
-
>```
43
-
44
32
1. Now that we have created the app directory structure, setup a Python virtual environment, and Copilot agent mode helped write a `requirements.txt` to install all project dependencies, let's check our changes in to our `build-octofit-app` branch.
45
33
46
34
1. With our new changes complete, please **commit** and **push** the changes to branch `build-octofit-app`.
Copy file name to clipboardExpand all lines: .github/steps/3-django-project-setup.md
+5-44Lines changed: 5 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ In this activity we will leverage a feature in vscode called prompt files. A pro
33
33
> [!IMPORTANT]
34
34
> - Don't start the Python Django app in the way that GitHub Copilot agent mode suggests hit **cancel**.
35
35
36
-
### :keyboard: Activity: Initializeand create the octofit_db MongoDB database
36
+
### :keyboard: Activity: Initialize, create, and populate the octofit_db MongoDB database
37
37
38
38
Let's continue to leverage a prompt file that has been created by the IT department for us to initialize and create the octofit_db MongoDB database. Copy/paste the following prompt in the GitHub Copilot Chat and select the "Agent" instead of "Ask" or "Edit" from the drop down where you are inserting the prompt.
39
39
@@ -53,26 +53,10 @@ Now let's create a prompt file of our own that we can share with other staff to
53
53
> ```prompt
54
54
> Let's add the following to a prompt file called `update-octofit-tracker-app.prompt.md` in the `.github/prompts` directory and add mode: 'agent' and model: GPT-4.1 to the prompt file.
55
55
>
56
-
> ## Use the existing Python virtual environment
57
-
>
58
-
> - Use the existing Python virtual environment we already created in directory octofit-tracker/backend/venv.
59
-
> - Do not create a new Python virtual environment as part of this process.
> 1. Update the octofit-tracker/backend/octofit_tracker/settings.py file to include the MongoDB database connections for octofit_db and djongo with no authentication.
65
-
> 2. Update the octofit-tracker/backend/octofit_tracker/models.py file to include the models for users, teams, activities, leaderboard, and workouts collections.
66
-
> 3. Update the octofit-tracker/backend/octofit_tracker/serializers.py file to include the serializers for users, teams, activities, leaderboard, and workouts collections.
67
-
> 4. Update the octofit-tracker/backend/octofit_tracker/urls.py file to include the URLs for users, teams, activities, leaderboard, and workouts collections.
68
-
> 5. Update the octofit-tracker/backend/octofit_tracker/views.py file to include the views for users, teams, activities, leaderboard, and workouts collections.
69
-
> 6. Update the octofit-tracker/backend/octofit_tracker/tests.py file to include the tests for users, teams, activities, leaderboard, and workouts collections.
70
-
> 7. Update the octofit-tracker/backend/octofit_tracker/admin.py file to include the admin for users, teams, activities, leaderboard, and workouts collections.
71
-
> 8. Make sure api_root is in octofit-tracker/backend/octofit_tracker/urls.py
72
-
> 9. Enable CORS in the octofit-tracker/backend/octofit_tracker/settings.py file to allow cross-origin requests from the frontend React app and allow all origins, methods, and headers.
73
-
> 10. Allow all hosts in the settings.py file.
74
-
> 11. Install CORS middleware components.
75
-
> 12. Make sure there are apps for octofit_tracker, rest_framework, and djongo in the INSTALLED_APPS setting.
56
+
> # Django App Updates
57
+
> 1. Update `settings.py` for MongoDB connection and CORS.
58
+
> 2. Update `models.py`, `serializers.py`, `urls.py`, `views.py`, `tests.py`, and `admin.py` to support users, teams, activities, leaderboard, and workouts collections.
59
+
> 3. Ensure `api_root` is present in `urls.py`.
76
60
> ```
77
61
78
62
> [!TIP]
@@ -95,29 +79,6 @@ Copy/paste the following prompt in the GitHub Copilot Chat and select the "Agent
95
79
96
80
> ❕ **Important:** Don't start the Python Django app in the way that GitHub Copilot agent mode suggests hit **cancel**.
97
81
98
-
### :keyboard: Activity: Populate the octofit_db database with test data from Django project/app files
> Let's populate the octofit_db database with test data.
104
-
>
105
-
> - Create test data for users, teams, activities, leaderboard, and workouts collections.
106
-
>
107
-
> - Activate the Python existing virtual environment octofit-tracker/backend/venv/bin/activate.
108
-
>
109
-
> 1. Run makemigrations and migrate the database in a Python virtual environment.
110
-
> 2. Populate the octofit_db database with test data for users, teams, activities, leaderboard, and workouts collections based on test data in our instructions to octofit-tracker/backend/octofit_tracker/management/commands/populate_db.py.
111
-
> 3. Help message in populate_db.py contains 'Populate the octofit_db database with test data'
112
-
> 4. Verify the test data is populated in the octofit_db database.
113
-
>
114
-
> ```
115
-
116
-
> ❕ **Important:**
117
-
- Don't start the Python Django app in the way that GitHub Copilot agent mode suggests hit **cancel**.
118
-
- If there is no `Continue` button, just pull the left side of the GitHub Copilot Chat panel over to the left, and it should appear.
119
-
- If this doesn't work, you may need to copy and paste the response in the terminal if there is no `Continue` button.
120
-
121
82
1. Now that we have created the database structure, updated our Django project files, and populated the database, let's check our changes into our `build-octofit-app` branch.
122
83
123
84
1. With our new changes complete, please **commit** and **push** the changes to GitHub.
Copy file name to clipboardExpand all lines: .github/steps/4-setup-django-rest-framework.md
+4-9Lines changed: 4 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,20 +14,15 @@ Copy and paste the following prompt(s) in the GitHub Copilot Chat and select the
14
14
> - Keep files created and updated by Copilot agent mode until it is finished.
15
15
> - Agent mode has the ability to evaluate your code base and execute commands and add/refactor/delete parts of your code base and automatically self heal if it or you makes a mistake in the process.
16
16
17
-
### :keyboard: Activity: Setup Django REST Framework, restart the server, and test the API
18
-
19
-
> [!NOTE]
20
-
> - Make sure to replace [REPLACE-THIS-WITH-YOUR-CODESPACE-NAME] with your codespace name.
21
-
> - ex. redesigned-spork-g6pj46rr9hpp6x
22
-
> - You can get the codespace name by running the following command in the terminal: `echo $CODESPACE_NAME`.
17
+
### :keyboard: Activity: Setup Django REST Framework and test the REST API endpoints
> Let's setup codespace for the URL, start the server via VS Code launch.json, and test the API.
28
-
>
29
-
> 1. Create an environment variable `OCTOFIT_API_BASE_URL` with the value `[REPLACE-THIS-WITH-YOUR-CODESPACE-NAME]-8000.app.github.dev` for use in your API endpoints in `settings.py`, `urls.py`, and `views.py`.
30
-
> 2. Update `urls.py` to use the value of the environment variable `OCTOFIT_API_BASE_URL` in your REST API URL endpoints (e.g., `https://${OCTOFIT_API_BASE_URL}`) for Django, to avoid certificate HTTPS issues.
23
+
>
24
+
> 1. Create an environment variable OCTOFIT_API_BASE_URL by executing this command in your terminal: `export OCTOFIT_API_BASE_URL="$CODESPACE_NAME-8000.app.github.dev"`
25
+
> 2. Update views.py and urls.py to replace the return for the REST API URL endpoints with the environment variable OCTOFIT_API_BASE_URL https://$OCTOFIT_API_BASE_URL for Django and avoid certificate HTTPS issues.
31
26
> 3. Make sure the Django backend works on your codespace URL (i.e., the value of `OCTOFIT_API_BASE_URL`) by updating `ALLOWED_HOSTS` in `octofit-tracker/backend/octofit_tracker/settings.py`.
Copy file name to clipboardExpand all lines: .github/steps/5-setup-frontend-react-framework.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,8 @@ Copy and paste the following prompt(s) in the GitHub Copilot Chat and select the
49
49
> ```prompt
50
50
> Let's update the octofit-tracker frontend React components.
51
51
>
52
-
> - Update the following components to include the React framework to point to the backend API:
52
+
> - Create an environment variable OCTOFIT_API_BASE_URL by executing this command in your terminal: `export OCTOFIT_API_BASE_URL="$CODESPACE_NAME-8000.app.github.dev"`
53
+
> - Update the following components to include the React framework to point to the backend REST API:
53
54
> - src/App.js
54
55
> - src/index.js
55
56
> - src/components/Activities.js
@@ -58,7 +59,7 @@ Copy and paste the following prompt(s) in the GitHub Copilot Chat and select the
58
59
> - src/components/Users.js
59
60
> - src/components/Workouts.js
60
61
> - In each component replace the fetch url with the codespace url
0 commit comments