@@ -972,29 +972,29 @@ async def submit(
972972
973973 now = datetime .now ()
974974
975- # Record the changeset row.
976- cs = TaskingChangeset (
977- task_id = task .id , # type: ignore[arg-type]
978- project_id = project_id ,
979- lock_id = lock .id , # type: ignore[arg-type]
980- user_auth_uid = str (current_user .user_uuid ),
981- osm_changeset_id = body .osm_changeset_id ,
982- submitted_at = now ,
983- )
984- self .session .add (cs )
985- await self .session .flush ()
986-
987- await self ._audit (
988- event_type = AuditEventType .CHANGESET_SUBMITTED ,
989- project_id = project_id ,
990- task_id = task .id ,
991- actor_uuid = current_user .user_uuid ,
992- details = {
993- "taskNumber" : task .task_number ,
994- "osmChangesetId" : body .osm_changeset_id ,
995- "done" : body .done ,
996- },
997- )
975+ # # Record the changeset row.
976+ # cs = TaskingChangeset(
977+ # task_id=task.id, # type: ignore[arg-type]
978+ # project_id=project_id,
979+ # lock_id=lock.id, # type: ignore[arg-type]
980+ # user_auth_uid=str(current_user.user_uuid),
981+ # osm_changeset_id=body.osm_changeset_id,
982+ # submitted_at=now,
983+ # )
984+ # self.session.add(cs)
985+ # await self.session.flush()
986+
987+ # await self._audit(
988+ # event_type=AuditEventType.CHANGESET_SUBMITTED,
989+ # project_id=project_id,
990+ # task_id=task.id,
991+ # actor_uuid=current_user.user_uuid,
992+ # details={
993+ # "taskNumber": task.task_number,
994+ # "osmChangesetId": body.osm_changeset_id,
995+ # "done": body.done,
996+ # },
997+ # )
998998
999999 if not body .done :
10001000 # Slide lock expiry from submitted_at + lock_timeout_hours.
@@ -1111,5 +1111,49 @@ async def submit(
11111111 refreshed = await self ._get_task (project_id , task_number )
11121112 return await self ._to_task_response (refreshed )
11131113
1114+ async def submit_changeset (
1115+ self ,
1116+ workspace_id : int ,
1117+ project_id : int ,
1118+ task_number : int ,
1119+ current_user : UserInfo ,
1120+ changesetId : int ,
1121+ ) -> int :
1122+ project = await self ._get_project (workspace_id , project_id )
1123+ task = await self ._get_task (project_id , task_number )
1124+ lock = await self ._get_active_lock (task .id ) # type: ignore[arg-type]
1125+ if lock is None or lock .user_auth_uid != str (current_user .user_uuid ):
1126+ raise ForbiddenException ("Caller does not hold the active lock" )
1127+ now = datetime .now ()
1128+
1129+ # Record the changeset row.
1130+ cs = TaskingChangeset (
1131+ task_id = task .id , # type: ignore[arg-type]
1132+ project_id = project_id ,
1133+ lock_id = lock .id , # type: ignore[arg-type]
1134+ user_auth_uid = str (current_user .user_uuid ),
1135+ osm_changeset_id = changesetId ,
1136+ submitted_at = now ,
1137+ )
1138+ self .session .add (cs )
1139+ await self .session .flush ()
1140+ # Get the id of the newly inserted changeset row
1141+ changeset_row_id = cs .id # type: ignore[assignment]
1142+ print (f"Inserted changeset row with ID: { changeset_row_id } " )
1143+
1144+ # Audit record for changeset submission
1145+ await self ._audit (
1146+ event_type = AuditEventType .CHANGESET_SUBMITTED ,
1147+ project_id = project_id ,
1148+ task_id = task .id ,
1149+ actor_uuid = current_user .user_uuid ,
1150+ details = {
1151+ "taskNumber" : task .task_number ,
1152+ "osmChangesetId" : changesetId ,
1153+ },
1154+ )
1155+ await self .session .commit ()
1156+ return cs .id # Return the ID of the newly inserted changeset row
1157+
11141158
11151159__all__ = ["TaskingTaskRepository" ]
0 commit comments