(a) If the petition is denied, the minor has a right to file a petition for a writ of mandate.
(b) If the petition is sustained, the parents or guardian have a right to file a petition for a writ of mandate if they have appeared in the proceeding and opposed the granting of the petition.