diff --git a/OurUmbraco.Site/macroScripts/repository-view-project.cshtml b/OurUmbraco.Site/macroScripts/repository-view-project.cshtml index 0a29ba3f..4867c181 100644 --- a/OurUmbraco.Site/macroScripts/repository-view-project.cshtml +++ b/OurUmbraco.Site/macroScripts/repository-view-project.cshtml @@ -1,4 +1,6 @@ @using OurUmbraco.Project +@using OurUmbraco.Repository.Services +@using Umbraco.Core @using Umbraco.Web @{ System.Web.Helpers.AntiForgeryConfig.SuppressXFrameOptionsHeader = true; @@ -7,6 +9,7 @@ int projectId; if (int.TryParse(Request.QueryString["project_id"], out projectId) == false) { + //TODO: Exception probably ! return; } @@ -14,6 +17,11 @@ var callback = Request.QueryString["callback"]; var Project = ProjectsProvider.GetListing(projectId, false); + if (Project == null) + { + throw new InvalidOperationException("No project found with id " + projectId); + } + var node = new umbraco.NodeFactory.Node(projectId); var parentId = node.Parent.Id; var categoryName = node.Parent.Name; @@ -30,10 +38,26 @@ descCssClass = "wrap"; } + var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); + var packageRepoService = new PackageRepositoryService(umbracoHelper, umbracoHelper.MembershipHelper, ApplicationContext.Current.DatabaseContext); + //This doesn't matter what we set it to so long as it's below 7.5 since that is the version we introduce strict dependencies + var currUmbracoVersion = new Version(4, 0, 0); + var packageDetails = packageRepoService.GetDetails(Project.ProjectGuid, currUmbracoVersion); + + if (packageDetails == null) + { + throw new InvalidOperationException("No package found with id " + Project.ProjectGuid); + } + + if (packageDetails.ZipUrl.IsNullOrWhiteSpace()) + { + throw new InvalidOperationException("This package is not compatible with the Umbraco version " + currUmbracoVersion); + } + int currentReleaseFile = 0; if (int.TryParse(Project.CurrentReleaseFile, out currentReleaseFile)) { - var file = Project.PackageFile.Where(x => x.Id == currentReleaseFile).FirstOrDefault(); + var file = Project.PackageFile.FirstOrDefault(x => x.Id == currentReleaseFile); if (file != null) { var ct = "This project is compaitible with "; @@ -66,27 +90,33 @@ } }