-
Notifications
You must be signed in to change notification settings - Fork 0
Add registration validation and more activities #2
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
Merged
Merged
Changes from all commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
d46a60b
Add requirements.txt with initial package dependencies
pmca31 8ecbf5e
Initialize Django project structure and create models, serializers, v…
pmca31 eeca2b5
Enhance Django settings for GitHub Codespaces support and add setup v…
pmca31 7c9643a
Add API root endpoint for GitHub Codespaces with dynamic URL generation
pmca31 eaa741b
feat: Initialize OctoFit Tracker frontend with routing and components
pmca31 7671696
fix: Update API URL construction in Users component for consistency
pmca31 8c56273
Initial plan
Copilot 18d283d
Initial plan
Copilot 511570d
Initial plan
Copilot 382ca52
fix: Add Codespaces support to test-teams-api.sh
Copilot 57c555a
Update octofit-tracker/backend/octofit_tracker/settings.py
pmca31 45a45fe
fix: Update App.test.js to match current OctoFit Tracker UI
Copilot a5dbe50
Initial plan
Copilot b2de384
Initial plan
Copilot b0b333a
refactor: Improve navbar test specificity using getByRole
Copilot b05622e
Initial plan
Copilot 11566ac
fix: Consolidate API root to /api/ path only, remove redundant custom…
Copilot 13ea265
Initial plan
Copilot ad20166
Initial plan
Copilot 8bf6fbc
Initial plan
Copilot 147c234
Initial plan
Copilot 997eed7
Initial plan
Copilot 4332fd6
Update octofit-tracker/backend/octofit_tracker/settings.py
pmca31 8c5d280
refactor: Use SimpleRouter with custom api_root at /api/ path
Copilot ccb29f0
feat: Add centralized API configuration with localhost fallback
Copilot 98ea23f
feat: Add centralized API configuration with localhost fallback
Copilot 2bc2c81
docs: Add clarifying comments to URL pattern ordering
Copilot fc3ee78
docs: Update .env.example and add API config README
Copilot 90e4d90
Merge pull request #6 from pmca31/copilot/sub-pr-2-yet-again
pmca31 bb79453
fix: Use relative path in verify_setup.sh instead of hard-coded absol…
Copilot 162dc58
refactor: Remove console.log from production API config
Copilot 3958c3e
fix: Use python3 instead of python in shell scripts for consistency
Copilot 7cd82e9
fix: Add directory navigation to copy-logo.sh for path independence
Copilot 3c037ae
feat: Implement configurable API base URL with localhost fallback
Copilot 08a5ea6
feat: Add centralized API configuration with localhost fallback
Copilot 2fc6903
docs: Add API configuration documentation
Copilot 14fb188
docs: Update FRONTEND_README.md with new API configuration
Copilot 7cfd796
feat: Add centralized API configuration with localhost fallback
Copilot 3323e53
fix: Comment out REACT_APP_CODESPACE_NAME in .env to avoid confusion
Copilot 6458d88
docs: Add clarifying comment about API_BASE_URL module load behavior
Copilot e4acb31
Merge branch 'build-octofit-app' into copilot/sub-pr-2-044f0a73-1df6-…
pmca31 aea3ff1
Merge pull request #13 from pmca31/copilot/sub-pr-2-044f0a73-1df6-4ef…
pmca31 934bc06
Merge branch 'build-octofit-app' into copilot/sub-pr-2-741bb43a-a0ac-…
pmca31 9e5fedb
Merge pull request #12 from pmca31/copilot/sub-pr-2-741bb43a-a0ac-4d3…
pmca31 7caf193
Merge pull request #3 from pmca31/copilot/sub-pr-2
pmca31 ead17e1
Merge pull request #4 from pmca31/copilot/sub-pr-2-again
pmca31 d8bc74f
Merge pull request #5 from pmca31/copilot/sub-pr-2-another-one
pmca31 e319987
Merge pull request #8 from pmca31/copilot/sub-pr-2-please-work
pmca31 dbea9cd
Merge pull request #10 from pmca31/copilot/sub-pr-2-c0f5406f-183c-43a…
pmca31 32cfffa
Merge pull request #9 from pmca31/copilot/sub-pr-2-5726c6bb-22bd-4260…
pmca31 6422ffc
Merge branch 'build-octofit-app' into copilot/sub-pr-2-246b387c-31c0-…
pmca31 8c4fbb8
Merge pull request #11 from pmca31/copilot/sub-pr-2-246b387c-31c0-47a…
pmca31 7028531
Merge branch 'build-octofit-app' into copilot/sub-pr-2-one-more-time
pmca31 6cb79f8
Merge pull request #7 from pmca31/copilot/sub-pr-2-one-more-time
pmca31 9c679d5
style: Update CORS settings and enhance table header styling with Boo…
pmca31 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| description: Update Django project files for octofit-tracker app | ||
| --- | ||
|
|
||
| # Django App Updates | ||
|
|
||
| - All Django project files are in the `octofit-tracker/backend/octofit_tracker` directory. | ||
|
|
||
| 1. Update `settings.py` for MongoDB connection and CORS. And make sure `octofit_tracker`, `rest_framework`, and `djongo` are in `INSTALLED_APPS`. | ||
| 2. Update `models.py`, `serializers.py`, `urls.py`, `views.py`, `tests.py`, and `admin.py` to support users, teams, activities, leaderboard, and workouts collections. | ||
| 3. Ensure `/` points to the api and `api_root` is present in `urls.py`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,179 @@ | ||
| # OctoFit Tracker - Codespace Setup & Testing Guide | ||
|
|
||
| ## Configuration Summary | ||
|
|
||
| The following files have been configured to work with GitHub Codespaces: | ||
|
|
||
| ### 1. Django Settings ([octofit-tracker/backend/octofit_tracker/settings.py](octofit-tracker/backend/octofit_tracker/settings.py)) | ||
|
|
||
| - **ALLOWED_HOSTS**: Dynamically configured to include: | ||
| - `localhost` | ||
| - `127.0.0.1` | ||
| - `${CODESPACE_NAME}-8000.app.github.dev` (when running in Codespaces) | ||
|
|
||
| - **Proxy Headers**: Configured for GitHub Codespaces HTTPS proxy | ||
| - `USE_X_FORWARDED_HOST = True` | ||
| - `SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')` | ||
|
|
||
| ### 2. VS Code Launch Configuration ([.vscode/launch.json](.vscode/launch.json)) | ||
|
|
||
| Pre-configured with: | ||
| - **Launch Django Backend**: Runs Django on `0.0.0.0:8000` | ||
| - **Launch React Frontend**: Runs React on port `3000` | ||
|
|
||
| ### 3. Port Forwarding ([.devcontainer/devcontainer.json](.devcontainer/devcontainer.json)) | ||
|
|
||
| - Port 8000: Django API (public) | ||
| - Port 3000: React frontend (public) | ||
| - Port 27017: MongoDB (private) | ||
|
|
||
| ## Starting the Server | ||
|
|
||
| ### Option 1: Using VS Code Debugger (Recommended) | ||
|
|
||
| 1. Open the **Run and Debug** panel (Ctrl+Shift+D or Cmd+Shift+D) | ||
| 2. Select "Launch Django Backend" from the dropdown | ||
| 3. Click the green play button or press F5 | ||
|
|
||
| The server will start with debugging enabled. | ||
|
|
||
| ### Option 2: Using Terminal | ||
|
|
||
| ```bash | ||
| # Activate virtual environment | ||
| source octofit-tracker/backend/venv/bin/activate | ||
|
|
||
| # Start Django server | ||
| cd octofit-tracker/backend | ||
| python manage.py runserver 0.0.0.0:8000 | ||
| ``` | ||
|
|
||
| ## API Endpoints | ||
|
|
||
| The REST API is available at: | ||
|
|
||
| **In GitHub Codespaces:** | ||
| ``` | ||
| https://${CODESPACE_NAME}-8000.app.github.dev/api/ | ||
| ``` | ||
|
|
||
| **Locally:** | ||
| ``` | ||
| http://localhost:8000/api/ | ||
| ``` | ||
|
|
||
| ### Available Endpoints | ||
|
|
||
| - `/api/users/` - User management | ||
| - `/api/teams/` - Team management | ||
| - `/api/activities/` - Activity tracking | ||
| - `/api/leaderboard/` - Leaderboard entries | ||
| - `/api/workouts/` - Workout suggestions | ||
|
|
||
| ## Testing the API | ||
|
|
||
| ### Manual Testing with curl | ||
|
|
||
| #### Test API Root | ||
| ```bash | ||
| # In Codespaces | ||
| curl https://${CODESPACE_NAME}-8000.app.github.dev/api/ | ||
|
|
||
| # Locally | ||
| curl http://localhost:8000/api/ | ||
| ``` | ||
|
|
||
| #### Test Specific Endpoints | ||
| ```bash | ||
| # Users endpoint | ||
| curl https://${CODESPACE_NAME}-8000.app.github.dev/api/users/ | ||
|
|
||
| # Activities endpoint | ||
| curl https://${CODESPACE_NAME}-8000.app.github.dev/api/activities/ | ||
|
|
||
| # Teams endpoint | ||
| curl https://${CODESPACE_NAME}-8000.app.github.dev/api/teams/ | ||
|
|
||
| # Leaderboard endpoint | ||
| curl https://${CODESPACE_NAME}-8000.app.github.dev/api/leaderboard/ | ||
|
|
||
| # Workouts endpoint | ||
| curl https://${CODESPACE_NAME}-8000.app.github.dev/api/workouts/ | ||
| ``` | ||
|
|
||
| ### Automated Testing Script | ||
|
|
||
| Run the automated test script: | ||
|
|
||
| ```bash | ||
| chmod +x test_api.sh | ||
| ./test_api.sh | ||
| ``` | ||
|
|
||
| This script will: | ||
| 1. Detect if running in Codespaces or locally | ||
| 2. Test all API endpoints | ||
| 3. Display HTTP status codes | ||
| 4. Show sample response data | ||
|
|
||
| ## Verifying Configuration | ||
|
|
||
| ### Check ALLOWED_HOSTS | ||
|
|
||
| ```bash | ||
| # Display current ALLOWED_HOSTS configuration | ||
| cd octofit-tracker/backend | ||
| source venv/bin/activate | ||
| python -c "import os; os.environ['CODESPACE_NAME'] = os.getenv('CODESPACE_NAME', 'test'); from octofit_tracker import settings; print('ALLOWED_HOSTS:', settings.ALLOWED_HOSTS)" | ||
| ``` | ||
|
|
||
| ### Check MongoDB Connection | ||
|
|
||
| ```bash | ||
| # Verify MongoDB is running | ||
| ps aux | grep mongod | grep -v grep | ||
|
|
||
| # Test MongoDB connection | ||
| mongosh --eval "db.adminCommand('ping')" | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Server Not Starting | ||
|
|
||
| 1. Check if MongoDB is running: `ps aux | grep mongod` | ||
| 2. Check if port 8000 is already in use: `lsof -i :8000` | ||
| 3. Check Python virtual environment: `which python` (should show venv path) | ||
|
|
||
| ### CORS Errors | ||
|
|
||
| The Django backend is configured with `CORS_ALLOW_ALL_ORIGINS = True` for development. | ||
|
|
||
| ### Connection Refused | ||
|
|
||
| 1. Verify the server is running on `0.0.0.0:8000` not `127.0.0.1:8000` | ||
| 2. Check port forwarding in VS Code (Ports tab in terminal panel) | ||
| 3. Ensure CODESPACE_NAME environment variable is set: `echo $CODESPACE_NAME` | ||
|
|
||
| ### 400 Bad Request or Invalid Host Header | ||
|
|
||
| This means ALLOWED_HOSTS is not configured correctly. Verify: | ||
| ```bash | ||
| echo $CODESPACE_NAME | ||
| # Should output your codespace name | ||
| ``` | ||
|
|
||
| The settings should automatically add `${CODESPACE_NAME}-8000.app.github.dev` to ALLOWED_HOSTS. | ||
|
|
||
| ## Next Steps | ||
|
|
||
| 1. ✅ Start the Django backend | ||
| 2. ✅ Test API endpoints with curl | ||
| 3. Configure and start the React frontend | ||
| 4. Test end-to-end functionality | ||
|
|
||
| ## Additional Resources | ||
|
|
||
| - [Django Settings Documentation](https://docs.djangoproject.com/en/4.1/ref/settings/) | ||
| - [Django REST Framework](https://www.django-rest-framework.org/) | ||
| - [GitHub Codespaces Port Forwarding](https://docs.github.com/en/codespaces/developing-in-codespaces/forwarding-ports-in-your-codespace) | ||
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/usr/bin/env python | ||
| """Django's command-line utility for administrative tasks.""" | ||
| import os | ||
| import sys | ||
|
|
||
|
|
||
| def main(): | ||
| """Run administrative tasks.""" | ||
| os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'octofit_tracker.settings') | ||
| try: | ||
| from django.core.management import execute_from_command_line | ||
| except ImportError as exc: | ||
| raise ImportError( | ||
| "Couldn't import Django. Are you sure it's installed and " | ||
| "available on your PYTHONPATH environment variable? Did you " | ||
| "forget to activate a virtual environment?" | ||
| ) from exc | ||
| execute_from_command_line(sys.argv) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| from django.contrib import admin | ||
| from .models import User, Team, Activity, Leaderboard, Workout | ||
|
|
||
|
|
||
| @admin.register(User) | ||
| class UserAdmin(admin.ModelAdmin): | ||
| list_display = ['name', 'email', 'team', 'created_at'] | ||
| list_filter = ['team', 'created_at'] | ||
| search_fields = ['name', 'email'] | ||
| ordering = ['-created_at'] | ||
|
|
||
|
|
||
| @admin.register(Team) | ||
| class TeamAdmin(admin.ModelAdmin): | ||
| list_display = ['name', 'description', 'created_at'] | ||
| search_fields = ['name', 'description'] | ||
| ordering = ['-created_at'] | ||
|
|
||
|
|
||
| @admin.register(Activity) | ||
| class ActivityAdmin(admin.ModelAdmin): | ||
| list_display = ['user_email', 'activity_type', 'duration', 'calories_burned', 'date'] | ||
| list_filter = ['activity_type', 'date'] | ||
| search_fields = ['user_email', 'activity_type'] | ||
| ordering = ['-date'] | ||
|
|
||
|
|
||
| @admin.register(Leaderboard) | ||
| class LeaderboardAdmin(admin.ModelAdmin): | ||
| list_display = ['rank', 'user_name', 'team', 'total_points', 'updated_at'] | ||
| list_filter = ['team'] | ||
| search_fields = ['user_name', 'user_email'] | ||
| ordering = ['rank'] | ||
|
|
||
|
|
||
| @admin.register(Workout) | ||
| class WorkoutAdmin(admin.ModelAdmin): | ||
| list_display = ['title', 'difficulty_level', 'duration', 'category'] | ||
| list_filter = ['difficulty_level', 'category'] | ||
| search_fields = ['title', 'description', 'category'] | ||
| ordering = ['title'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| """ | ||
| ASGI config for octofit_tracker project. | ||
|
|
||
| It exposes the ASGI callable as a module-level variable named ``application``. | ||
|
|
||
| For more information on this file, see | ||
| https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/ | ||
| """ | ||
|
|
||
| import os | ||
|
|
||
| from django.core.asgi import get_asgi_application | ||
|
|
||
| os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'octofit_tracker.settings') | ||
|
|
||
| application = get_asgi_application() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # Management commands package |
1 change: 1 addition & 0 deletions
1
octofit-tracker/backend/octofit_tracker/management/commands/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # Management commands |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR title mentions "registration validation", but this PR doesn't appear to introduce any registration/auth endpoints or validation logic (it focuses on models/viewsets and setup docs). Consider updating the PR title/description to match the actual scope, or adding the missing registration validation work if it was intended.