File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -307,15 +307,16 @@ def get_current_version_published_by_slug(
307307 Returns 404 if the bulletin doesn't exist or is not published.
308308 """
309309
310- # Get bulletin master without authentication
311- bulletin_master = bulletins_master_service ._get_by_field (field = "name_machine" , value = bulletinSlug )
312- if not bulletin_master :
310+ # There may be duplicated slugs in historical data, so pick a published
311+ # bulletin that also has a current_version_id.
312+ bulletin_masters = bulletins_master_service .get_all (
313+ filters = {"name_machine" : bulletinSlug , "status" : StatusBulletin .PUBLISHED }
314+ )
315+ if not bulletin_masters :
313316 raise HTTPException (status_code = 404 , detail = "Bulletin not found" )
314-
315- bulletin_master = bulletin_master [0 ]
316-
317- # Verify the bulletin is PUBLISHED (security check for public access)
318- if bulletin_master .status != StatusBulletin .PUBLISHED :
317+
318+ bulletin_master = next ((b for b in bulletin_masters if b .current_version_id ), None )
319+ if not bulletin_master :
319320 raise HTTPException (status_code = 404 , detail = "Bulletin not found" )
320321
321322 bulletin_id = str (bulletin_master .id )
You can’t perform that action at this time.
0 commit comments