Database 0071: Applicants

This commit is contained in:
Rick Falkvinge
2018-03-07 11:04:18 +01:00
parent 85e207aa29
commit e2e9a050e1
6 changed files with 133 additions and 8 deletions
+1
View File
@@ -64,6 +64,7 @@
<Compile Include="Types\Financial\BasicVatReport.cs" />
<Compile Include="Types\Financial\BasicVatReportItem.cs" />
<Compile Include="Types\Governance\BasicBallot.cs" />
<Compile Include="Types\Swarm\BasicApplicant.cs" />
<Compile Include="Types\Swarm\BasicPosition.cs" />
<Compile Include="Types\Swarm\BasicPositionAssignment.cs" />
<Compile Include="Types\Swarm\BasicVolunteerPosition.cs" />
+25
View File
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Swarmops.Common.Interfaces;
namespace Swarmops.Basic.Types.Swarm
{
public class BasicApplicant: IHasIdentity
{
public int ApplicantId { get; private set; }
public int PersonId { get; private set; }
public int OrganizationId { get; private set; }
public DateTime CreatedDateTime { get; private set; }
public int Score1 { get; protected set; }
public int Score2 { get; protected set; }
public int Score3 { get; protected set; }
public int Identity { get { return ApplicantId; } }
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ namespace Swarmops.Database
/// <summary>
/// This is the IN-CODE revision of the database. The version we expect to be running against.
/// </summary>
public static int DbVersionExpected => 70;
public static int DbVersionExpected => 71;
// This class is in horrible need of serious refactoring. For its simplicity in task, it's a horrible bowl of spaghetti.
+2 -1
View File
@@ -67,4 +67,5 @@
0067 - Bugfix for 0066 [RF]
0068 - Added SetSalaryOpen [RF]
0069 - Added table, procs for ExpenseClaimGroups [RF]
0070 - Added first Applications tables, procs [RF]
0070 - Added first Applications tables, procs [RF]
0071 - Renamed Application to Applicant, to avoid a marsh and misery of name collisions [RF]
+86
View File
@@ -0,0 +1,86 @@
DROP TABLE `Applications`
#
CREATE TABLE `Applicants` (
`ApplicantId` INT NOT NULL AUTO_INCREMENT,
`PersonId` INT NOT NULL,
`OrganizationId` INT NOT NULL,
`CreatedDateTime` DATETIME NOT NULL,
`GrantedDateTime` DATETIME NOT NULL DEFAULT '1800-01-01',
`GrantedByPersonId` INT NOT NULL DEFAULT 0,
`Open` TINYINT NOT NULL DEFAULT 1,
`Score1` BIGINT NOT NULL DEFAULT 0,
`Score2` BIGINT NOT NULL DEFAULT 0,
`Score3` BIGINT NOT NULL DEFAULT 0,
PRIMARY KEY (`ApplicantId`),
INDEX `Ix_Person` (`PersonId` ASC),
INDEX `Ix_Organization` (`OrganizationId` ASC),
INDEX `Ix_Scores` (`Score1` ASC, `Score2` ASC, `Score3` ASC),
INDEX `Ix_Open` (`Open` ASC),
INDEX `Ix_Created` (`CreatedDateTime` ASC))
#
DROP PROCEDURE IF EXISTS `CreateApplication`
#
DROP PROCEDURE IF EXISTS `UpdateApplicationScore`
#
DROP PROCEDURE IF EXISTS `CreateApplicant`
#
DROP PROCEDURE IF EXISTS `UpdateApplicantScore`
#
CREATE PROCEDURE `CreateApplicant`(
IN personId INT,
IN organizationId INT,
IN dateTimeNow DATETIME
)
BEGIN
INSERT INTO Applicants (PersonId, OrganizationId, CreatedDateTime)
VALUES (personId, organizationId, dateTimeNow);
SELECT LAST_INSERT_ID() AS Identity;
END
#
CREATE PROCEDURE `UpdateApplicantScore`(
IN applicantId INT,
IN deltaScore1 BIGINT,
IN deltaScore2 BIGINT,
IN deltaScore3 BIGINT
)
BEGIN
UPDATE Applicants
SET Applicants.Score1 = Applicants.Score1 + deltaScore1,
Applicants.Score2 = Applicants.Score2 + deltaScore2,
Applicants.Score3 = Applicants.Score3 + deltaScore3
WHERE Applicants.ApplicantId = applicantId;
END
+18 -6
View File
@@ -281,20 +281,32 @@ namespace Swarmops.Frontend.Pages.Public
Person newPerson = Person.Create (name, mail, password, phone, street1 + "\n" + street2.Trim(), postalCode,
city, countryCode, parsedDateOfBirth, gender);
Participation participation = newPerson.AddParticipation (organization, DateTime.UtcNow.AddYears (1)); // TODO: set duration from organization settings of Participantship
if (organization.Parameters.ParticipationEntry == "ApplicationApproval")
{
Applicant Applicant =
SwarmopsLog.CreateEntry(newPerson, new ApplicantAddedLogEntry(, newPerson)))
}
else
{
// "Application" or null, default
Participation participation = newPerson.AddParticipation(organization, DateTime.UtcNow.AddYears(1)); // TODO: set duration from organization settings of Participantship
SwarmopsLog.CreateEntry(newPerson, new PersonAddedLogEntry(participation, newPerson));
OutboundComm.CreateParticipantNotification(newPerson, newPerson, organization,
NotificationResource.Participant_Signup);
}
// TODO: CREATE APPLICATION INSTEAD DEPENDING ON POLICY
// TODO: SEND NOTIFICATIONS
// Log the signup
SwarmopsLog.CreateEntry (newPerson, new PersonAddedLogEntry (participation, newPerson));
// Create notification
OutboundComm.CreateParticipantNotification (newPerson, newPerson, organization,
NotificationResource.Participant_Signup);
// Add the bells and whistles