Skip to content
This repository was archived by the owner on Mar 19, 2023. It is now read-only.

Commit 3a63cf5

Browse files
authored
Version 2.8
Dominion2
2 parents 725b887 + 76141dd commit 3a63cf5

File tree

101 files changed

+5713
-4874
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+5713
-4874
lines changed

Site/Code/Extensions.cs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,9 @@ public static string CleanedForJavascriptStrings(this string input)
598598
/// <returns> </returns>
599599
public static string SerializedAsJsonString(this object input)
600600
{
601-
return new JavaScriptSerializer().Serialize(input);
601+
return new JavaScriptSerializer {
602+
MaxJsonLength = int.MaxValue
603+
}.Serialize(input);
602604
}
603605

604606
/// <summary>
@@ -615,7 +617,8 @@ public static JsonResult AsJsonResult(this object input,
615617
ContentType = "text/plain",
616618
// allow client full control over reading response (don't send as JSON type)
617619
Data = input,
618-
JsonRequestBehavior = behavior
620+
JsonRequestBehavior = behavior,
621+
MaxJsonLength = int.MaxValue
619622
};
620623
return jsonResult;
621624
}
@@ -718,21 +721,6 @@ public static string Plural(this int input, string plural, string single, string
718721
}
719722
}
720723

721-
// public static IEnumerable<Vote> AsVotes(this IEnumerable<VoteInfo> inputs)
722-
// {
723-
// return inputs.Select(VoteInfo => new Vote
724-
// {
725-
// C_RowId = VoteInfo.VoteId,
726-
// BallotGuid = VoteInfo.BallotGuid,
727-
// C_RowVersion = null,
728-
// InvalidReasonGuid = VoteInfo.VoteIneligibleReasonGuid,
729-
// PersonCombinedInfo = VoteInfo.PersonCombinedInfoInVote,
730-
// PersonGuid = VoteInfo.PersonGuid,
731-
// PositionOnBallot = VoteInfo.PositionOnBallot,
732-
// SingleNameElectionCount = VoteInfo.SingleNameElectionCount,
733-
// StatusCode = VoteInfo.VoteStatusCode
734-
// });
735-
// }
736724

737725
/// <Summary>Return the string without accents.</Summary>
738726
/// <remarks>

Site/Code/Resources/TemplateLoader.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ public enum File
1818
// This enum is manually created and maintained. Add a new item when needed, matching file names
1919
ElectionListItem,
2020
LocationSelectItem,
21-
SingleVoteLine,
2221
EditPerson,
23-
NormalVoteLine,
2422
RollCallLine,
2523
}
2624

Site/Content/Site.css

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Site/Content/Site.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,10 @@ input[type="submit"]:hover, input[type="file"]:hover, button.Primary:hover {
755755
display: none;
756756
}
757757

758+
.input-medium {
759+
width: 120px;
760+
}
761+
758762
input[type="text"].input-validation-error, input[type="password"].input-validation-error {
759763
border: solid 1px #e80c4d;
760764
}

Site/Controllers/BallotsController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ public JsonResult BallotsForLocation(int id)
7373
}.AsJsonResult();
7474
}
7575

76-
public JsonResult SaveVote(int pid, int vid, int count, string invalid)
76+
public JsonResult SaveVote(int pid, int vid, string invalid = "", int count = 0, int lastVid = 0, bool verifying = false)
7777
{
7878
var invalidGuid = invalid.AsNullableGuid();
79-
return CurrentBallotModel.SaveVote(pid, vid, count, invalidGuid);
79+
return CurrentBallotModel.SaveVote(pid, vid, invalidGuid, lastVid, count, verifying);
8080
}
8181

8282
public JsonResult DeleteVote(int vid)

Site/Controllers/BeforeController.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public ActionResult RollCall()
2626
return View(new RollCallModel());
2727
}
2828

29+
public JsonResult PeopleForFrontDesk() {
30+
return new PeopleModel().FrontDeskPersonLines().AsJsonResult();
31+
}
32+
2933
public JsonResult VotingMethod(int id, string type, int last, bool forceDeselect)
3034
{
3135
return new PeopleModel().RegisterVotingMethod(id, type, last, forceDeselect);

Site/Controllers/ElectionsController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public JsonResult SelectElection(Guid guid, Guid? oldComputerGuid)
2727
{
2828
return new
2929
{
30-
Locations = ContextItems.LocationModel.MyLocations.OrderBy(l => l.SortOrder).Select(l => new { l.Name, l.C_RowId }),
30+
Locations = ContextItems.LocationModel.AllLocations.OrderBy(l => l.SortOrder).Select(l => new { l.Name, l.C_RowId }),
3131
Selected = true,
3232
ElectionName = UserSession.CurrentElectionName,
3333
ElectionGuid = UserSession.CurrentElectionGuid,

Site/Controllers/PeopleController.cs

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
using System;
12
using System.Linq;
23
using System.Web.Mvc;
34
using TallyJ.Code;
45
using TallyJ.Code.Session;
56
using TallyJ.CoreModels;
7+
using TallyJ.EF;
68

79
namespace TallyJ.Controllers
810
{
@@ -19,21 +21,54 @@ public ActionResult Index()
1921
return null;
2022
}
2123

22-
public JsonResult GetPeople(string search, bool includeMatches = false, bool forBallot = true)
24+
25+
public JsonResult GetAll()
2326
{
2427
var currentElection = UserSession.CurrentElection;
2528
if (currentElection == null)
2629
{
2730
return new
28-
{
29-
Error = "Election not selected"
30-
}.AsJsonResult();
31+
{
32+
Error = "Election not selected"
33+
}.AsJsonResult();
3134
}
3235

33-
var model = new PeopleSearchModel();
34-
return model.Search2(search, includeMatches, forBallot);
36+
var isSingleNameElection = currentElection.IsSingleNameElection;
37+
var votes = new VoteCacher(Db).AllForThisElection;
38+
39+
return new
40+
{
41+
people = new PersonCacher(Db).AllForThisElection.Select(p => new
42+
{
43+
Id = p.C_RowId,
44+
//p.PersonGuid,
45+
Name = p.FullNameFL,
46+
p.Area,
47+
V = (p.CanReceiveVotes.GetValueOrDefault() ? "1" : "0") + (p.CanVote.GetValueOrDefault() ? "1" : "0"),
48+
IRG = p.IneligibleReasonGuid,
49+
NumVotes = isSingleNameElection
50+
? votes.Where(v => v.PersonGuid == p.PersonGuid).Sum(v => v.SingleNameElectionCount).AsInt()
51+
: votes.Count(v => v.PersonGuid == p.PersonGuid)
52+
}),
53+
lastVid = votes.Max(v=>v.C_RowId)
54+
}.AsJsonResult();
3555
}
3656

57+
//public JsonResult GetPeople(string search, bool includeMatches = false, bool forBallot = true)
58+
//{
59+
// var currentElection = UserSession.CurrentElection;
60+
// if (currentElection == null)
61+
// {
62+
// return new
63+
// {
64+
// Error = "Election not selected"
65+
// }.AsJsonResult();
66+
// }
67+
68+
// var model = new PeopleSearchModel();
69+
// return model.Search2(search, includeMatches, forBallot);
70+
//}
71+
3772
public JsonResult GetDetail(int id)
3873
{
3974
var model = new PeopleModel();

Site/Controllers/PublicController.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ public ActionResult Install()
5252
return View();
5353
}
5454

55+
public JsonResult Warmup() {
56+
// force the server to contact the database to ensure that it is warmed up and ready for action
57+
UserSession.DbContext.Election.First();
58+
return null;
59+
}
60+
5561
public JsonResult TellerJoin(Guid electionGuid, string pc, Guid? oldCompGuid)
5662
{
5763
return new TellerModel().GrantAccessToGuestTeller(electionGuid, pc, oldCompGuid.AsGuid());

Site/CoreModels/BallotAnalyzer.cs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,6 @@ public BallotAnalyzer(Election election, Action<DbAction, Ballot> ballotSaver)
5656
/// <returns>Returns the updated status code</returns>
5757
public BallotStatusWithSpoilCount UpdateBallotStatus(Ballot ballot, List<VoteInfo> currentVotes, bool refreshVoteStatus)
5858
{
59-
if (IsSingleNameElection)
60-
{
61-
if (ballot.StatusCode != BallotStatusEnum.Ok)
62-
{
63-
BallotSaver(DbAction.Attach, ballot);
64-
65-
ballot.StatusCode = BallotStatusEnum.Ok;
66-
67-
BallotSaver(DbAction.Save, ballot);
68-
}
69-
return new BallotStatusWithSpoilCount
70-
{
71-
Status = BallotStatusEnum.Ok,
72-
SpoiledCount = 0
73-
};
74-
}
75-
76-
7759
//double check:
7860
currentVotes.ForEach(vi => AssertAtRuntime.That(vi.BallotGuid == ballot.BallotGuid));
7961

@@ -85,6 +67,25 @@ public BallotStatusWithSpoilCount UpdateBallotStatus(Ballot ballot, List<VoteInf
8567
string newStatus;
8668
int spoiledCount;
8769

70+
71+
//if (IsSingleNameElection)
72+
//{
73+
// if (ballot.StatusCode != BallotStatusEnum.Ok)
74+
// {
75+
// BallotSaver(DbAction.Attach, ballot);
76+
77+
// ballot.StatusCode = BallotStatusEnum.Ok;
78+
79+
// BallotSaver(DbAction.Save, ballot);
80+
// }
81+
// return new BallotStatusWithSpoilCount
82+
// {
83+
// Status = BallotStatusEnum.Ok,
84+
// SpoiledCount = 0
85+
// };
86+
//}
87+
88+
8889
if (DetermineStatusFromVotesList(ballot.StatusCode, currentVotes, out newStatus, out spoiledCount))
8990
{
9091
BallotSaver(DbAction.Attach, ballot);
@@ -115,15 +116,15 @@ public bool DetermineStatusFromVotesList(string currentStatusCode, List<VoteInfo
115116
return false;
116117
}
117118

118-
if (IsSingleNameElection)
119+
var needsVerification = voteInfos.Any(v => v.PersonCombinedInfo.HasContent() && !v.PersonCombinedInfo.StartsWith(v.PersonCombinedInfoInVote));
120+
if (needsVerification)
119121
{
120-
return StatusChanged(BallotStatusEnum.Ok, currentStatusCode, out statusCode);
122+
return StatusChanged(BallotStatusEnum.Verify, currentStatusCode, out statusCode);
121123
}
122124

123-
var needsVerification = voteInfos.Any(v => v.PersonCombinedInfo != v.PersonCombinedInfoInVote);
124-
if (needsVerification)
125+
if (IsSingleNameElection)
125126
{
126-
return StatusChanged(BallotStatusEnum.Verify, currentStatusCode, out statusCode);
127+
return StatusChanged(BallotStatusEnum.Ok, currentStatusCode, out statusCode);
127128
}
128129

129130
// check counts

0 commit comments

Comments
 (0)