public ActionResult About(string vanityUrl)
        {
            var customPage = MultiTenantHelpers.GetAllCustomPages()
                             .SingleOrDefault(x => x.CustomPageVanityUrl == vanityUrl);

            new CustomPageViewFeature().DemandPermission(CurrentPerson, customPage);
            var hasPermission = new CustomPageManageFeature().HasPermission(CurrentPerson, customPage).HasPermission;
            var viewData      = new DisplayPageContentViewData(CurrentPerson, customPage, hasPermission);

            return(RazorView <DisplayPageContent, DisplayPageContentViewData>(viewData));
        }
Ejemplo n.º 2
0
        public IndexViewData(FirmaSession currentFirmaSession) : base(currentFirmaSession, null)
        {
            PageTitle = "Custom Pages";

            GridSpec = new CustomPageGridSpec(new FirmaPageViewListFeature().HasPermissionByFirmaSession(currentFirmaSession))
            {
                ObjectNameSingular  = "Custom Page",
                ObjectNamePlural    = "Custom Pages",
                SaveFiltersInCookie = true
            };

            var hasCustomPageManagePermissions = new CustomPageManageFeature().HasPermissionByFirmaSession(currentFirmaSession);

            GridName    = "customPagesGrid";
            GridDataUrl = SitkaRoute <CustomPageController> .BuildUrlFromExpression(tc => tc.IndexGridJsonData());

            CustomPageUrl = SitkaRoute <CustomPageController> .BuildUrlFromExpression(x => x.CustomPageDetails(UrlTemplate.Parameter1Int));

            HasCustomPageManagePermissions = hasCustomPageManagePermissions;
            NewUrl = SitkaRoute <CustomPageController> .BuildUrlFromExpression(t => t.New());
        }
Ejemplo n.º 3
0
        public ActionResult ViewCustomPage(string route, string vanityUrl)
        {
            var customPage = MultiTenantHelpers.GetCustomPages()
                             .SingleOrDefault(x => string.Equals(x.CustomPageVanityUrl, vanityUrl, StringComparison.OrdinalIgnoreCase));

            if (vanityUrl.IsEmpty() || customPage == null)
            {
                // Search engines sometimes have stale routes; we re-map for them.
                // (This is really fairly coddled, but it could benefit humans too, theoretically.)
                string remappedVanityUrl = null;
                switch (vanityUrl)
                {
                case "MeetingsAndNotes":
                    remappedVanityUrl = "MeetingNotes";
                    break;

                case "AboutClackamasPartnership":
                    remappedVanityUrl = "About";
                    break;
                }

                // If we found a remapping, redirect permanently to it
                if (remappedVanityUrl != null)
                {
                    return(RedirectToAction(new SitkaRoute <CustomPageController>(x => x.ViewCustomPage(route, remappedVanityUrl))));
                }

                // Otherwise, we just redirect to the site's main page, and put up a warning in case this was actually a human doing the navigation.
                SetWarningForDisplay($"Could not find vanity URL /{route}: \"{vanityUrl}\"");
                return(RedirectToAction(new SitkaRoute <HomeController>(x => x.Index())));

                // Since we either return the requested vanity URL, OR redirect to SOMETHING, search engines should
                // stop bashing their heads eventually here.
            }
            new CustomPageViewFeature().DemandPermission(CurrentFirmaSession, customPage);
            var hasPermission = new CustomPageManageFeature().HasPermission(CurrentFirmaSession, customPage).HasPermission;
            var viewData      = new DisplayPageContentViewData(CurrentFirmaSession, customPage, hasPermission);

            return(RazorView <DisplayPageContent, DisplayPageContentViewData>(viewData));
        }
Ejemplo n.º 4
0
        public IndexViewData(Person currentPerson) : base(currentPerson, null)
        {
            PageTitle = "Manage Custom Pages";

            GridSpec = new CustomPageGridSpec(new FirmaPageViewListFeature().HasPermissionByPerson(currentPerson))
            {
                ObjectNameSingular  = "Custom Page",
                ObjectNamePlural    = "Custom Pages",
                SaveFiltersInCookie = true
            };

            var hasCustomPageManagePermissions = new CustomPageManageFeature().HasPermissionByPerson(currentPerson);

            if (hasCustomPageManagePermissions)
            {
                var contentUrl = SitkaRoute <CustomPageController> .BuildUrlFromExpression(t => t.New());

                GridSpec.CreateEntityModalDialogForm = new ModalDialogForm(contentUrl, $"Create a new Custom Page");
            }
            GridName    = "customPagesGrid";
            GridDataUrl = SitkaRoute <CustomPageController> .BuildUrlFromExpression(tc => tc.IndexGridJsonData());

            CustomPageUrl = SitkaRoute <CustomPageController> .BuildUrlFromExpression(x => x.CustomPageDetails(UrlTemplate.Parameter1Int));
        }