Skip to content

Commit b751542

Browse files
committed
sync/plone: Change path of deleted lectures
Changing the path gets the out the way of any tutorials, without breaking DB integrity.
1 parent 16fdd82 commit b751542

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tutorweb/quizdb/sync/plone.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,19 @@ def compareLgs(dbLec, globalSettings):
127127

128128
def removePloneLecture(lectureObj):
129129
"""Mark this lecture as inactive"""
130-
pass # TODO:
130+
dbHost = getDbHost()
131+
plonePath = '/'.join(lectureObj.getPhysicalPath())
132+
try:
133+
dbLec = Session.query(db.Lecture).with_lockmode('update') \
134+
.filter(db.Lecture.hostId == dbHost.hostId) \
135+
.filter(db.Lecture.plonePath == plonePath).one()
136+
except NoResultFound:
137+
return
138+
dbLec.plonePath = ''.join((
139+
datetime.datetime.utcnow().strftime('/deleted-%Y-%m-%d--%H:%M:%S'),
140+
dbLec.plonePath,
141+
))
142+
Session.flush()
131143

132144
def _toUTCDateTime(t):
133145
"""Convert Zope DateTime into UTC datetime object"""

0 commit comments

Comments
 (0)