Skip to content

Commit

Permalink
Merge pull request #751 from euphorie/ale/2372/fix-last-modifier-id
Browse files Browse the repository at this point in the history
Fix the last modifier id for guest users that have been converted to registered users
  • Loading branch information
reinhardt authored Jul 15, 2024
2 parents 03c6d18 + 5ba0b1d commit 01c21dc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
3 changes: 3 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Changelog
- Fix the i18n labels
[ale-rt]

- Fix the last modifier id for guest users that have been converted to registered users
[ale-rt]


16.2.0 (2024-06-12)
-------------------
Expand Down
27 changes: 16 additions & 11 deletions src/euphorie/deployment/browser/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from euphorie.client.model import Session
from euphorie.client.model import SurveySession
from Products.Five import BrowserView
from transaction import commit

import logging

Expand All @@ -21,15 +22,19 @@ def __call__(self):
.filter(Account.id != SurveySession.account_id)
.filter(Account.account_type == "guest")
)
for guest_user, assessment in obsolete_guest_users:
assessment.last_modifier_id = assessment.account_id
logger.info("Updated session %s", assessment.id)
num_assessments = (
session.query(SurveySession)
.filter(SurveySession.account_id == guest_user.id)
.count()
)
if num_assessments == 0:
session.delete(guest_user)
logger.info("Deleted user %s", guest_user.id)

with session.no_autoflush:
for guest_user, assessment in obsolete_guest_users:
assessment.last_modifier_id = assessment.account_id
logger.info("Updated session %s", assessment.id)

num_assessments = (
session.query(SurveySession)
.filter(SurveySession.account_id == guest_user.id)
.count()
)
if num_assessments == 0:
session.delete(guest_user)
logger.info("Deleted user %s", guest_user.id)
commit()
return "Done"

0 comments on commit 01c21dc

Please sign in to comment.