Skip to content

Commit e9ba112

Browse files
update code and fix bug
1 parent 5bb9022 commit e9ba112

44 files changed

Lines changed: 1958 additions & 1324 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1-
# -----------------------------
2-
# Global
3-
# -----------------------------
1+
# ==============================
2+
# OS Files
3+
# ==============================
44
.DS_Store
55
Thumbs.db
66
Desktop.ini
7+
ehthumbs.db
8+
9+
# ==============================
10+
# IDE / Editor
11+
# ==============================
712
.vscode/
813
.idea/
9-
*.log
14+
*.swp
15+
*.swo
1016
*.tmp
1117
*.temp
1218
*.bak
1319
*.orig
1420
*.rej
1521

16-
# Local scratch docs / notes
17-
PROJECT_DETAILS.txt
18-
19-
# -----------------------------
22+
# ==============================
2023
# Secrets / Environment
21-
# -----------------------------
24+
# ==============================
2225
**/.env
23-
**/.env.*
2426
!**/.env.example
2527

26-
# -----------------------------
28+
# ==============================
2729
# Python
28-
# -----------------------------
30+
# ==============================
2931
**/__pycache__/
3032
**/*.py[cod]
3133
**/*.pyo
@@ -34,27 +36,45 @@ PROJECT_DETAILS.txt
3436
**/.coverage
3537
**/htmlcov/
3638
**/.ruff_cache/
39+
**/.mypy_cache/
40+
**/.hypothesis/
41+
**/dist/
42+
**/build/
43+
**/*.egg
44+
**/.eggs/
3745
**/venv/
3846
**/.venv/
3947
**/env/
4048

41-
# SQLite / local db
49+
# SQLite database
4250
**/*.db
4351
**/*.sqlite3
52+
Backend/instance/
4453

45-
# Celery runtime
54+
# Celery
4655
**/celerybeat-schedule
4756
**/celerybeat.pid
4857

49-
# Backend generated storage artifacts
58+
# Migrations auto-generated
59+
Backend/migrations/versions/*.py
60+
61+
# ==============================
62+
# Generated Storage Files
63+
# ==============================
5064
Backend/storage/images/*
5165
Backend/storage/documents/*
5266
!Backend/storage/images/.gitkeep
5367
!Backend/storage/documents/.gitkeep
5468

55-
# -----------------------------
56-
# Node / Next.js
57-
# -----------------------------
69+
# ==============================
70+
# Logs
71+
# ==============================
72+
*.log
73+
logs/
74+
75+
# ==============================
76+
# Node / Next.js / Frontend
77+
# ==============================
5878
Frontend/node_modules/
5979
Frontend/.next/
6080
Frontend/out/
@@ -67,7 +87,17 @@ Frontend/yarn-debug.log*
6787
Frontend/yarn-error.log*
6888
Frontend/pnpm-debug.log*
6989

70-
# Optional package manager locks (uncomment per team preference)
71-
# Frontend/package-lock.json
72-
# Frontend/yarn.lock
73-
# Frontend/pnpm-lock.yaml
90+
# ==============================
91+
# Docker (local only)
92+
# ==============================
93+
# Uncomment if you don't want docker files on GitHub
94+
# Backend/Dockerfile
95+
# Backend/docker-compose.yml
96+
97+
# ==============================
98+
# Misc
99+
# ==============================
100+
PROJECT_DETAILS.txt
101+
*.zip
102+
*.tar.gz
103+
Backend/package-lock.json

Backend/README.md

Lines changed: 0 additions & 186 deletions
This file was deleted.

Backend/app/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
"""AI Assignment Generator — v2.0"""
2-
__version__ = "2.0.0"
2+
3+
from app.factory import create_app
4+
5+
__version__ = "2.0.0"
6+
7+
# Create app instance for Flask to discover
8+
app = create_app()

Backend/app/api/assignment_api.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ def generate_assignment():
8585
word_count=data["word_count"],
8686
citation_style=data["citation_style"],
8787
template=data["template"],
88+
student_name=data.get("student_name", ""),
89+
roll_number=data.get("roll_number", ""),
90+
department=data.get("department", ""),
8891
status=AssignmentStatus.PENDING.value,
8992
progress_percent=0,
9093
)
@@ -205,6 +208,31 @@ def download_assignment(assignment_id: str):
205208
return send_file(abs_path, mimetype=mimetype, as_attachment=True, download_name=name)
206209

207210

211+
@assignment_bp.route("/<string:assignment_id>/update-info", methods=["PATCH"])
212+
@jwt_required()
213+
def update_assignment_info(assignment_id: str):
214+
"""Update student name and roll number."""
215+
user_id = get_jwt_identity()
216+
assignment = db.session.get(Assignment, assignment_id)
217+
218+
if not assignment:
219+
return jsonify({"success": False, "message": "Assignment not found."}), 404
220+
if assignment.user_id != user_id:
221+
return jsonify({"success": False, "message": "Access denied."}), 403
222+
223+
import bleach
224+
data = request.get_json() or {}
225+
if "student_name" in data:
226+
assignment.student_name = bleach.clean(str(data["student_name"])[:200], tags=[], strip=True)
227+
if "roll_number" in data:
228+
assignment.roll_number = bleach.clean(str(data["roll_number"])[:100], tags=[], strip=True)
229+
if "department" in data:
230+
assignment.department = bleach.clean(str(data["department"])[:200], tags=[], strip=True)
231+
232+
db.session.commit()
233+
return jsonify({"success": True, "message": "Info updated."}), 200
234+
235+
208236
@assignment_bp.route("/<string:assignment_id>/sections/<string:section_id>", methods=["PATCH"])
209237
@jwt_required()
210238
def update_section(assignment_id: str, section_id: str):
@@ -289,11 +317,11 @@ def regenerate_documents(assignment_id: str):
289317
# Gather existing images
290318
images = [
291319
GeneratedImage(
292-
section_title=img.caption.split(": ", 1)[-1] if ": " in img.caption else "",
293-
image_path=os.path.abspath(img.image_url) if img.image_url else "",
294-
caption=img.caption,
320+
section_title=img.caption.split(": ", 1)[-1] if img.caption and ": " in img.caption else "",
321+
image_path=img.image_url if img.image_url and os.path.exists(img.image_url) else "",
322+
caption=img.caption or "",
295323
prompt=img.prompt or "",
296-
success=bool(img.image_url and os.path.exists(os.path.abspath(img.image_url))),
324+
success=bool(img.image_url and os.path.exists(img.image_url)),
297325
)
298326
for img in assignment.images
299327
]
@@ -305,10 +333,16 @@ def regenerate_documents(assignment_id: str):
305333
docx_path = doc_gen.generate_docx(
306334
content=content, images=images,
307335
template=assignment.template, assignment_id=assignment.id,
336+
student_name=assignment.student_name or "",
337+
roll_number=assignment.roll_number or "",
338+
department=assignment.department or "",
308339
)
309340
pdf_path = doc_gen.generate_pdf(
310341
content=content, images=images,
311342
template=assignment.template, assignment_id=assignment.id,
343+
student_name=assignment.student_name or "",
344+
roll_number=assignment.roll_number or "",
345+
department=assignment.department or "",
312346
)
313347

314348
assignment.docx_path = docx_path

0 commit comments

Comments
 (0)