Skip to content

Commit

Permalink
Fix adding objects to database, fixes LibreTexts#167, LibreTexts#169
Browse files Browse the repository at this point in the history
  • Loading branch information
ykazakov committed Oct 9, 2024
1 parent a50edc9 commit fd8467e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ngshare/database/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def init_db(db, storage_path):
ua = User('abigail')
ul = User('lawrence')
ue = User('eric')
db.add(uk)
db.add(ua)
db.add(ul)
db.add(ue)
course1 = Course('course1', [uk])
course2 = Course('course2', [ua])
db.add(course1)
Expand Down Expand Up @@ -132,6 +136,8 @@ def test_legacy():
assignment = Assignment("ps1", course)
submission = Submission(student, assignment)
db.add(course)
db.add(assignment)
db.add(submission)
db.commit()
print(submission)

Expand Down
2 changes: 2 additions & 0 deletions ngshare/ngshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ def post(self, course_id, assignment_id):
assignment = Assignment(assignment_id, course)
files = self.get_argument('files', None)
self.json_files_unpack(files, assignment.files)
self.db.add(assignment)
self.db.commit()
self.json_success()

Expand Down Expand Up @@ -857,6 +858,7 @@ def post(self, course_id, assignment_id):
submission = Submission(self.user, assignment)
files = self.get_body_argument('files', None)
self.json_files_unpack(files, submission.files)
self.db.add(submission)
self.db.commit()
self.json_success(timestamp=self.strftime(submission.timestamp))

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_version(rel_path):
],
python_requires='>=3.8',
install_requires=[
'SQLAlchemy>=1.3.12,<2.0',
'SQLAlchemy>=1.3.12',
'alembic>=1.3.2',
'tornado>=6.0.3',
'jupyterhub>=1.1.0',
Expand Down

0 comments on commit fd8467e

Please sign in to comment.