Exemplo n.º 1
0
        public static string GetSpreadsheetListHtml(bool all = false, int?id = null)
        {
            var table = all
        ? ElectionSpreadsheets.GetAllListData()
        : ElectionSpreadsheets.GetListDataByCompleted(false);

            if (table.Count == 0)
            {
                return("<div>No spreadsheets found</div>");
            }

            // get a dictionary of election descriptions
            var dictionary =
                Elections.GetElectionDescriptions(table.Select(recordStates =>
                                                               recordStates.ElectionKey));

            // append jurisdictions
            var mods = new List <KeyValuePair <string, string> >();

            foreach (var kvp in dictionary)
            {
                if (!Elections.IsStateElection(kvp.Key))
                {
                    var stateCode    = Elections.GetStateCodeFromKey(kvp.Key);
                    var jurisdiction = Elections.IsCountyElection(kvp.Key)
            ? Counties.GetCounty(stateCode, Elections.GetCountyCodeFromKey(kvp.Key))
            : LocalDistricts.GetLocalDistrict(stateCode, Elections.GetLocalKeyFromKey(kvp.Key));
                    mods.Add(new KeyValuePair <string, string>(kvp.Key, jurisdiction));
                }
            }

            foreach (var kvp in mods)
            {
                dictionary[kvp.Key] += ", " + kvp.Value;
            }

            return(Join(Empty,
                        table.OrderByDescending(r => r.UploadTime).Select(r =>
                                                                          $"<div data-completed=\"{r.Completed.ToString().ToLower()}\"" +
                                                                          $" data-id=\"{r.Id}\" data-rows=\"{r.Rows}\"" +
                                                                          $"{(r.Id == id ? " class=\"selected\"" : Empty)}>" +
                                                                          $"{r.Filename} ({r.UploadTime:d}: {dictionary[r.ElectionKey]}" +
                                                                          $"{(r.ElectionScope == "A" ? " et. al." : Empty)}" +
                                                                          $"{(r.JurisdictionScope == "S" ? ", state level only" : Empty)})</div>")));
        }
Exemplo n.º 2
0
        private void AddLocalsMenu(Control ul)
        {
            // County Admins always see a local menu
            // Masters and State Admins see it if they are on a County or Local Admin page
            string stateCode  = null;
            string countyCode = null;

            if (SecurePage.IsCountyAdminUser ||
                ((SecurePage.IsMasterUser || SecurePage.IsStateAdminUser) &&
                 (SecurePage.IsCountyAdminPage || SecurePage.IsLocalAdminPage)))
            {
                stateCode  = SecurePage.GetViewStateStateCode();
                countyCode = SecurePage.GetViewStateCountyCode();
            }
            if ((stateCode != null) && (countyCode != null))
            {
                AddMenuItem(ul, Counties.GetCounty(stateCode, countyCode),
                            GetLocalsMenu(
                                "/admin?state={StateCode}&county={CountyCode}&local={LocalCode}",
                                stateCode, countyCode));
            }
        }
Exemplo n.º 3
0
        private void BuildMainMenu(Control parent)
        {
            var ul = new HtmlUl();

            _Root = ul;
            parent.Controls.Add(ul);
            ul.Attributes.Add("class", "main-admin-menu");

            if (SecurePage.IsMasterUser)
            {
                AddMenuItem(ul, "Master Panel", "/master/");
                AddJurisdictionsMenu(ul);
                AddMenuItem(ul, "States", GetStatesMenu());
                AddCountiesMenu(ul);
                AddLocalsMenu(ul);
                AddElectionsMenu(ul);
                AddMasterOfficesMenu(ul);
                AddMenuItem(ul, "Parties", GetPartiesMenu());
                AddMenuItem(ul, "Politicians", GetPoliticiansMenu());
                AddPoliticianMenu(ul);
                AddMenuItem(ul, "Issues", GetIssuesMenu());
                AddMenuItem(ul, "Master Only", GetSiteAdminMenu());
                AddMenuItem(ul, "Help", GetMasterHelpMenu());
            }
            else if (SecurePage.IsStateAdminUser)
            {
                AddMenuItem(ul, SecurePage.UserStateCode + " State Admin", "/admin/");
                AddCountiesMenu(ul);
                AddLocalsMenu(ul);
                AddJurisdictionsMenu(ul);
                AddElectionsMenu(ul);
                AddMenuItem(ul, "Offices", GetOfficesMenu());
                AddMenuItem(ul, "Issues", "/admin/issues.aspx");
                AddMenuItem(ul, "Parties", "/admin/parties.aspx");
                AddMenuItem(ul, "Politicians", "/admin/politicians.aspx");
                AddMenuItem(ul, "Help", GetAdminHelpMenu());
            }
            else if (SecurePage.IsCountyAdminUser)
            {
                AddMenuItem(ul,
                            Counties.GetCounty(SecurePage.UserStateCode, SecurePage.UserCountyCode) +
                            " Admin", "/admin/");
                AddLocalsMenu(ul);
                AddJurisdictionsMenu(ul);
                AddElectionsMenu(ul);
                AddMenuItem(ul, "Offices", GetOfficesMenu());
                AddMenuItem(ul, "Help", GetAdminHelpMenu());
            }
            else if (SecurePage.IsLocalAdminUser)
            {
                AddMenuItem(ul,
                            LocalDistricts.GetLocalDistrictByStateCodeLocalKey(SecurePage.UserStateCode,
                                                                               SecurePage.UserLocalKey) + " Admin", "/admin/");
                AddJurisdictionsMenu(ul);
                AddElectionsMenu(ul);
                AddMenuItem(ul, "Offices", GetOfficesMenu());
                AddMenuItem(ul, "Help", GetAdminHelpMenu());
            }
            else if (SecurePage.IsPoliticianUser)
            {
                AddPoliticianMenuItems(ul);
            }
            else if (SecurePage.IsPartyUser)
            {
                AddMenuItem(ul, "Help", GetPartyHelpMenu());
            }

            // remove an empty menu
            if (ul.Controls.Count == 0)
            {
                parent.Controls.Remove(ul);
            }
        }