Skip to content

Commit 7cc5239

Browse files
committed
Merge branch 'refactor/backend' of github.com:Agamya-Samuel/wikicontest into ft/add-alembic-support
2 parents 16820a6 + 18e5f3d commit 7cc5239

File tree

6 files changed

+26
-23
lines changed

6 files changed

+26
-23
lines changed

.github/workflows/pylint.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ jobs:
3434
if [ -f requirements.txt ]; then python -m pip install -r requirements.txt; fi
3535
python -m pip install pylint
3636
37-
- name: Run pylint on app.py
37+
- name: Run pylint on main.py
3838
working-directory: backend
39-
run: python -m pylint --fail-under=9 app.py
39+
run: python -m pylint --fail-under=9 main.py
4040

4141
- name: Run pylint on models
4242
working-directory: backend
43-
run: python -m pylint --fail-under=9 models/
43+
run: python -m pylint --fail-under=9 app/models/
4444

4545
- name: Run pylint on routes
4646
working-directory: backend
47-
run: python -m pylint --fail-under=9 routes/
47+
run: python -m pylint --fail-under=9 app/routes/

backend/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ backend/
6060
├── logs/ # Application logs
6161
├── docs/ # Documentation
6262
│ ├── ALEMBIC_USAGE_GUIDE.md # Detailed Alembic usage guide
63-
├── run.py # Main entry point for running the app
63+
├── main.py # Main entry point for running the app
6464
├── alembic.ini # Alembic configuration file
6565
├── Makefile # Makefile for common commands
6666
├── requirements.txt # Python dependencies
@@ -144,7 +144,7 @@ make help
144144

145145
1. **Start the Flask development server:**
146146
```bash
147-
python run.py
147+
python main.py
148148
```
149149

150150
Or using Flask directly:

backend/app/routes/contest_routes.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def create_contest():
177177
marks_setting_accepted=marks_accepted,
178178
marks_setting_rejected=marks_rejected,
179179
jury_members=jury_members,
180-
allowed_submission_type=allowed_submission_type
180+
allowed_submission_type=allowed_submission_type
181181
)
182182

183183
contest.save()
@@ -367,16 +367,16 @@ def update_contest(contest_id): # pylint: disable=too-many-return-statements
367367
contest.set_rules(rules_payload)
368368
else:
369369
contest.set_rules({'text': ''})
370-
370+
371371
if "allowed_submission_type" in data:
372-
new_type = data.get("allowed_submission_type", "both")
372+
new_type = data.get("allowed_submission_type", "both")
373373

374-
# Validate only allowed values
375-
if new_type not in ["new", "expansion", "both"]:
374+
# Validate only allowed values
375+
if new_type not in ["new", "expansion", "both"]:
376376
return jsonify({"error": "Invalid allowed_submission_type"}), 400
377377

378-
contest.allowed_submission_type = new_type
379-
378+
contest.allowed_submission_type = new_type
379+
380380
# --- Dates ---
381381
if 'start_date' in data:
382382
parsed = parse_date_or_none(data.get('start_date'))

backend/run.py renamed to backend/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66
For production, use a WSGI server like gunicorn or uwsgi.
77
88
Usage:
9-
python run.py
9+
python main.py
1010
"""
1111

12-
from app import app, db
12+
# Third-party imports should come before local imports
1313
from sqlalchemy import inspect, text
1414
from sqlalchemy.exc import SQLAlchemyError, ProgrammingError, OperationalError
1515

16+
# Local application imports
17+
from app import app, db
18+
1619
def migrate_database():
1720
"""
1821
Run database migrations to add new columns if they don't exist.

backend/migrations/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ python migrations/add_size_at_start_to_submissions.py
4949

5050
```bash
5151
# The application runs all migrations automatically on startup
52-
python run.py
52+
python main.py
5353
```
5454

5555
## Migration Safety

docs/RUN_DEVELOPMENT.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Open a terminal and run:
1212

1313
```bash
1414
cd backend
15-
python app.py
15+
python main.py
1616
```
1717

1818
Flask will start on `http://localhost:5000`
@@ -63,7 +63,7 @@ This creates a `dist/` directory with production files.
6363

6464
```bash
6565
cd backend
66-
python app.py
66+
python main.py
6767
```
6868

6969
Flask will automatically detect and serve the built Vue.js files from `frontend/dist/`.
@@ -96,7 +96,7 @@ Create `start-dev.ps1`:
9696

9797
```powershell
9898
# Start Flask backend
99-
Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd backend; python app.py"
99+
Start-Process powershell -ArgumentList "-NoExit", "-Command", "cd backend; python main.py"
100100
101101
# Wait a moment
102102
Start-Sleep -Seconds 2
@@ -116,7 +116,7 @@ Create `start-dev.sh`:
116116

117117
# Start Flask backend in background
118118
cd backend
119-
python app.py &
119+
python main.py &
120120
BACKEND_PID=$!
121121

122122
# Wait a moment
@@ -140,15 +140,15 @@ Run with: `./start-dev.sh`
140140
### Port Already in Use
141141

142142
**Flask (port 5000):**
143-
- Change port in `backend/app.py`: `app.run(port=5001)`
143+
- Change port in `backend/main.py`: `app.run(port=5001)`
144144

145145
**Vue.js (port 5173):**
146146
- Change port in `frontend/vite.config.js`: `server: { port: 5174 }`
147147

148148
### API Requests Failing
149149

150150
- Ensure Flask is running on port 5000
151-
- Check CORS configuration in `backend/app.py`
151+
- Check CORS configuration in `backend/app/__init__.py`
152152
- Verify proxy settings in `frontend/vite.config.js`
153153

154154
### Module Not Found Errors
@@ -169,7 +169,7 @@ npm install
169169

170170
For daily development, use **Option 1** (separate servers):
171171

172-
1. Terminal 1: `cd backend && python app.py`
172+
1. Terminal 1: `cd backend && python main.py`
173173
2. Terminal 2: `cd frontend && npm run dev`
174174
3. Open browser: http://localhost:5173
175175

0 commit comments

Comments
 (0)