Skip to content

Commit b4b62ae

Browse files
committed
Add business code.
1 parent f41591b commit b4b62ae

18 files changed

Lines changed: 490 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
mode: 'agent'
2+
model: GPT-4.1
3+
4+
# Django App Updates
5+
6+
- All Django project files are in the `octofit-tracker/backend/octofit_tracker` directory.
7+
8+
1. Update `settings.py` for MongoDB connection and CORS.
9+
2. Update `models.py`, `serializers.py`, `urls.py`, `views.py`, `tests.py`, and `admin.py` to support users, teams, activities, leaderboard, and workouts collections.
10+
3. Ensure `/` points to the api and `api_root` is present in `urls.py`. (See <attachments> above for file contents. You may not need to search or read the file again.)

octofit-tracker/backend/db.sqlite3

128 KB
Binary file not shown.

octofit-tracker/backend/manage.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
import os
4+
import sys
5+
6+
7+
def main():
8+
"""Run administrative tasks."""
9+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'octofit_tracker.settings')
10+
try:
11+
from django.core.management import execute_from_command_line
12+
except ImportError as exc:
13+
raise ImportError(
14+
"Couldn't import Django. Are you sure it's installed and "
15+
"available on your PYTHONPATH environment variable? Did you "
16+
"forget to activate a virtual environment?"
17+
) from exc
18+
execute_from_command_line(sys.argv)
19+
20+
21+
if __name__ == '__main__':
22+
main()

octofit-tracker/backend/octofit_tracker/__init__.py

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django.contrib import admin
2+
from .models import User, Team, Activity, Workout, Leaderboard
3+
4+
admin.site.register(User)
5+
admin.site.register(Team)
6+
admin.site.register(Activity)
7+
admin.site.register(Workout)
8+
admin.site.register(Leaderboard)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for octofit_tracker project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'octofit_tracker.settings')
15+
16+
application = get_asgi_application()

octofit-tracker/backend/octofit_tracker/management/__init__.py

Whitespace-only changes.

octofit-tracker/backend/octofit_tracker/management/commands/__init__.py

Whitespace-only changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from django.core.management.base import BaseCommand
2+
from octofit_tracker.models import User, Team, Activity, Workout, Leaderboard
3+
from django.utils import timezone
4+
5+
class Command(BaseCommand):
6+
help = 'Populate the octofit_db database with test data'
7+
8+
def handle(self, *args, **options):
9+
# Delete existing data
10+
Leaderboard.objects.all().delete()
11+
Activity.objects.all().delete()
12+
User.objects.all().delete()
13+
Team.objects.all().delete()
14+
Workout.objects.all().delete()
15+
16+
# Create teams
17+
marvel = Team.objects.create(name='Marvel')
18+
dc = Team.objects.create(name='DC')
19+
20+
# Create users
21+
tony = User.objects.create(name='Tony Stark', email='tony@marvel.com', team=marvel)
22+
steve = User.objects.create(name='Steve Rogers', email='steve@marvel.com', team=marvel)
23+
bruce = User.objects.create(name='Bruce Wayne', email='bruce@dc.com', team=dc)
24+
clark = User.objects.create(name='Clark Kent', email='clark@dc.com', team=dc)
25+
26+
# Create workouts
27+
w1 = Workout.objects.create(name='Super Strength', description='Heavy lifting workout', difficulty='Hard')
28+
w2 = Workout.objects.create(name='Flight Training', description='Aerobic and agility', difficulty='Medium')
29+
30+
# Create activities
31+
Activity.objects.create(user=tony, type='Running', duration=30, date=timezone.now().date())
32+
Activity.objects.create(user=steve, type='Cycling', duration=45, date=timezone.now().date())
33+
Activity.objects.create(user=bruce, type='Martial Arts', duration=60, date=timezone.now().date())
34+
Activity.objects.create(user=clark, type='Flying', duration=120, date=timezone.now().date())
35+
36+
# Create leaderboard
37+
Leaderboard.objects.create(user=tony, score=100)
38+
Leaderboard.objects.create(user=steve, score=90)
39+
Leaderboard.objects.create(user=bruce, score=110)
40+
Leaderboard.objects.create(user=clark, score=120)
41+
42+
self.stdout.write(self.style.SUCCESS('octofit_db populated with test data!'))
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Generated by Django 4.1.7 on 2025-11-27 07:36
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
initial = True
10+
11+
dependencies = [
12+
]
13+
14+
operations = [
15+
migrations.CreateModel(
16+
name='Team',
17+
fields=[
18+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19+
('name', models.CharField(max_length=100, unique=True)),
20+
],
21+
options={
22+
'db_table': 'teams',
23+
},
24+
),
25+
migrations.CreateModel(
26+
name='Workout',
27+
fields=[
28+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
29+
('name', models.CharField(max_length=100)),
30+
('description', models.TextField()),
31+
('difficulty', models.CharField(max_length=50)),
32+
],
33+
options={
34+
'db_table': 'workouts',
35+
},
36+
),
37+
migrations.CreateModel(
38+
name='User',
39+
fields=[
40+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
41+
('name', models.CharField(max_length=100)),
42+
('email', models.EmailField(max_length=254, unique=True)),
43+
('team', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='members', to='octofit_tracker.team')),
44+
],
45+
options={
46+
'db_table': 'users',
47+
},
48+
),
49+
migrations.CreateModel(
50+
name='Leaderboard',
51+
fields=[
52+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
53+
('score', models.IntegerField()),
54+
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='leaderboard_entries', to='octofit_tracker.user')),
55+
],
56+
options={
57+
'db_table': 'leaderboard',
58+
},
59+
),
60+
migrations.CreateModel(
61+
name='Activity',
62+
fields=[
63+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
64+
('type', models.CharField(max_length=100)),
65+
('duration', models.IntegerField()),
66+
('date', models.DateField()),
67+
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='activities', to='octofit_tracker.user')),
68+
],
69+
options={
70+
'db_table': 'activities',
71+
},
72+
),
73+
]

0 commit comments

Comments
 (0)