# -*- encoding: utf-8 -*- from System.IO import File, Path attributesToValidate = ["Firstname", "Lastname", "Name", "Info1"] def __onStart(WorkflowType): for item in Script.GetIntelliflow().ItemsOnAir: if item.Server.Type.ToString() == "Program" and item.Scene.Name == Script.Scene.Name: Script.ClearTransition() return False if WorkflowType.ToString() != "PreviewToProgram": validTabs = ["last battle", "current heat", "historic"] selectedTab = SurfInfo.GetSelectedTab() if selectedTab.lower() not in validTabs: Core.StatusManager.Add("Select a valid battle or heat") return False surferRow = SurfInfo.GetProfile() if not surferRow or not surferRow.SurferPlayer: Core.StatusManager.Add("No data available.\nPlease import data and/or \nselect a surfers before \nshowing this slide") return False invalidAttributes = [] for attributeToValidate in attributesToValidate: if not hasattr(surferRow.SurferPlayer, attributeToValidate) or getattr(surferRow.SurferPlayer, attributeToValidate) == None: invalidAttributes.append(attributeToValidate) if invalidAttributes: Core.StatusManager.Add("Surfer Id '%s' has no valid attributes: %s" % (surferRow.SurferPlayer.IdSurfer, ", ".join(invalidAttributes))) return False photosDirectory = Path.Combine("R:\\", "Projects", wTvisionRE.Project, "Images", "Photos") photoPath = Path.Combine(photosDirectory, "%s.jpg"%surferRow.SurferPlayer.Name) if not File.Exists(photoPath): if str(MsgBox.Show("Missing Photos", "Missing Surfer photo in %s:\n%s\nContinue anyway?" % (photosDirectory, "%s.jpg"%surferRow.SurferPlayer.Name), MsgBox.ButtonsCombo.YesNo)) != "Yes": return False if not ProjectSettings.ContainsKey("SocialNetwork Logo") or not ProjectSettings["SocialNetwork Logo"]: Core.StatusManager.Add("ProjectSettings doesn't contain 'SocialNetwork Logo' key or value") return False ######################## FILL DATA ######################## def __getData(viewBag): surferProfile = SurfInfo.GetProfile() if not surferProfile or not surferProfile.SurferPlayer: return False if SurfInfo.GetSelectedTab() == "Historic": result = SurfInfo.GetHeatInfoHistoric() else: result = SurfInfo.GetFullHeatResult() surferPlayer = surferProfile.SurferPlayer surfer = next((item for item in list(result.HeatInfo.Lines) if item.Player.IdSurfer == surferPlayer.IdSurfer), None) if not surfer: Core.StatusManager.Add("Surfer not found") return False viewBag.SetImage("lgCompetition", "/Images/CompetitionLogos/%s.png" % ProjectSettings["Competition Logo"]) photosDirectory = Path.Combine("R:\\", "Projects", wTvisionRE.Project, "Images", "Photos") photoPath = Path.Combine(photosDirectory, "%s.jpg"%surferPlayer.Name) if File.Exists(photoPath): viewBag.SetImage("lgPhoto", "/Images/Photos/%s.jpg"%surferPlayer.Name) else: viewBag.SetImage("lgPhoto", "/Images/Photos/NoPhoto.png") viewBag.SetImage("lgShirtColor", "/Images/ShirtColor/" + (surfer.Color if surfer.Color else "vaz") + ".png") viewBag.SetString("tSurferName", surferPlayer.Firstname.upper()) viewBag.SetString("tSurferSurname", surferPlayer.Lastname.upper()) viewBag.SetString("tTeam", surferProfile.SurferPlayer.Info1.ToString().upper()) socialNetwork = surferProfile.SurferPlayer.Instagram if socialNetwork: viewBag.SetTranslatedText("tSocialNetwork", "{{@}}.{{SocialNetwork}}%s"%socialNetwork) viewBag.SetVisibility("vSocialNetworkVisibility", True) else: viewBag.SetString("tSocialNetwork", "") viewBag.SetVisibility("vSocialNetworkVisibility", False) viewBag.SetImage("lgSocialNetwork", "/Images/SocialNetwork/%s.png" % ProjectSettings["SocialNetwork Logo"])