Skip to content

Commit 025a3db

Browse files
authored
Merge pull request #91 from github-samples/project-updates
Project updates
2 parents 597ecd2 + b36b0c3 commit 025a3db

File tree

10 files changed

+78
-78
lines changed

10 files changed

+78
-78
lines changed

.devcontainer/devcontainer.json

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,43 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/python
13
{
2-
"name": "Tailspin Toys Dev Container",
3-
"image": "mcr.microsoft.com/devcontainers/universal:latest",
4-
"postCreateCommand": "./scripts/setup-env.sh",
5-
"customizations": {
6-
"vscode": {
7-
"extensions": [
8-
"ms-dotnettools.csharp",
9-
"GitHub.copilot",
10-
"GitHub.copilot-chat",
11-
"ms-python.vscode-pylance",
12-
"svelte.svelte-vscode",
13-
"astro-build.astro-vscode"
14-
]
15-
}
16-
},
17-
"features": {
18-
"ghcr.io/devcontainers/features/dotnet:2": {
19-
"version": "9.0"
20-
}
21-
}
4+
"name": "Python 3",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
7+
"features": {
8+
"ghcr.io/devcontainers/features/node:1": {},
9+
"ghcr.io/schlich/devcontainer-features/playwright:0": {},
10+
"ghcr.io/devcontainers-extra/features/typescript:2": {}
11+
},
12+
"postCreateCommand": "./scripts/setup-env.sh",
13+
"customizations": {
14+
"vscode": {
15+
"extensions": [
16+
"ms-dotnettools.csharp",
17+
"GitHub.copilot",
18+
"GitHub.copilot-chat",
19+
"ms-python.vscode-pylance",
20+
"svelte.svelte-vscode",
21+
"astro-build.astro-vscode"
22+
]
23+
}
24+
},
25+
26+
// Features to add to the dev container. More info: https://containers.dev/features.
27+
// "features": {},
28+
29+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
30+
"forwardPorts": [
31+
4321,
32+
5100
33+
],
34+
35+
// Use 'postCreateCommand' to run commands after the container is created.
36+
// "postCreateCommand": "pip3 install --user -r requirements.txt",
37+
38+
// Configure tool-specific properties.
39+
// "customizations": {},
40+
41+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
42+
// "remoteUser": "root"
2243
}

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ updates:
2121
dependency-type: production
2222
update-types:
2323
- patch
24+
- package-ecosystem: "devcontainers"
25+
directory: "/"
26+
schedule:
27+
interval: weekly

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
"devcontainer",
1010
"devcontainers",
1111
"docstrings",
12+
"dotnettools",
1213
"isouter",
1314
"prebuild",
15+
"pylance",
16+
"schlich",
1417
"SDLC"
1518
],
1619
"github.copilot.nextEditSuggestions.enabled": true,

client/package-lock.json

Lines changed: 6 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build": "astro build",
88
"preview": "astro preview",
99
"astro": "astro",
10-
"test:e2e": "npx playwright test"
10+
"test:e2e": "npx playwright install && npx playwright test"
1111
},
1212
"dependencies": {
1313
"@astrojs/node": "^9.3.0",

server/app.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import os
22
from flask import Flask
3-
from models import init_db
43
from routes.games import games_bp
5-
from utils.database import init_db
4+
from models import db
5+
from utils.database import get_connection_string
66

77
# Get the server directory path
88
base_dir: str = os.path.abspath(os.path.dirname(__file__))
99

1010
app: Flask = Flask(__name__)
1111

12-
# Initialize the database with the app
13-
init_db(app)
12+
# Configure and initialize the database
13+
app.config['SQLALCHEMY_DATABASE_URI'] = get_connection_string()
14+
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
15+
db.init_app(app)
16+
17+
# Create tables
18+
with app.app_context():
19+
db.create_all()
1420

1521
# Register blueprints
1622
app.register_blueprint(games_bp)

server/models/__init__.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,4 @@
55
# Import models after db is defined to avoid circular imports
66
from .category import Category
77
from .game import Game
8-
from .publisher import Publisher
9-
10-
def init_db(app, testing: bool = False):
11-
"""Initialize the database
12-
13-
Args:
14-
app: The Flask application instance
15-
testing: If True, allows reinitialization for testing
16-
"""
17-
if testing:
18-
# For testing, we want to be able to reinitialize
19-
db.init_app(app)
20-
else:
21-
try:
22-
db.init_app(app)
23-
except RuntimeError:
24-
# Database already initialized
25-
pass
26-
27-
# Create tables when initializing
28-
with app.app_context():
29-
db.create_all()
8+
from .publisher import Publisher

server/tests/test_games.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import json
33
from typing import Dict, List, Any, Optional
44
from flask import Flask, Response
5-
from models import Game, Publisher, Category, db, init_db
5+
from models import Game, Publisher, Category, db
66
from routes.games import games_bp
77

88
class TestGamesRoutes(unittest.TestCase):
@@ -52,7 +52,7 @@ def setUp(self) -> None:
5252
self.client = self.app.test_client()
5353

5454
# Initialize in-memory database for testing
55-
init_db(self.app, testing=True)
55+
db.init_app(self.app)
5656

5757
# Create tables and seed data
5858
with self.app.app_context():

server/utils/database.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,6 @@
11
import os
2-
from models import init_db as models_init_db
32

4-
def init_db(app, connection_string=None, testing=False):
5-
"""
6-
Initializes the database with the given Flask app and connection string.
7-
If no connection string is provided, a default SQLite connection string is used.
8-
9-
Args:
10-
app: The Flask application instance
11-
connection_string: Optional database connection string
12-
testing: If True, allows reinitialization for testing
13-
"""
14-
if connection_string is None:
15-
connection_string = __get_connection_string()
16-
app.config['SQLALCHEMY_DATABASE_URI'] = connection_string
17-
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
18-
models_init_db(app, testing=testing)
19-
20-
def __get_connection_string():
3+
def get_connection_string() -> str:
214
"""
225
Returns the connection string for the database.
236
"""

server/utils/seed_database.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
import random
44
from flask import Flask
55
from models import db, Category, Game, Publisher
6-
from utils.database import init_db
6+
from utils.database import get_connection_string
77

88
def create_app():
99
"""Create and configure Flask app for database operations"""
1010
app = Flask(__name__)
1111

12-
# Initialize the database with the app
13-
init_db(app)
12+
# Configure and initialize the database
13+
app.config['SQLALCHEMY_DATABASE_URI'] = get_connection_string()
14+
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
15+
db.init_app(app)
16+
17+
# Create tables
18+
with app.app_context():
19+
db.create_all()
1420

1521
return app
1622

0 commit comments

Comments
 (0)