From 524d7291ed56255fa67cee7c9c09f57eaedb0e30 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Wed, 7 Mar 2018 20:47:32 +0100 Subject: [PATCH] Applicant signup should work --- Logic/Communications/OutboundComm.cs | 2 ++ .../Payload/NotificationPayload.cs | 2 ++ Logic/Logic.csproj | 1 + ...ansmission.NotificationPayload.Designer.cs | 18 ++++++++++ ...ions.Transmission.NotificationPayload.resx | 6 ++++ .../LogEntries/ApplicantAddedLogEntry.cs | 34 +++++++++++++++++++ Logic/Support/SwarmopsLogEntry.cs | 5 +++ Site/Pages/v5/Public/Signup.aspx.cs | 6 ++-- 8 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 Logic/Support/LogEntries/ApplicantAddedLogEntry.cs diff --git a/Logic/Communications/OutboundComm.cs b/Logic/Communications/OutboundComm.cs index cc64dabe..99f34315 100644 --- a/Logic/Communications/OutboundComm.cs +++ b/Logic/Communications/OutboundComm.cs @@ -392,6 +392,8 @@ namespace Swarmops.Logic.Communications payload.Strings[NotificationString.RegularTitle] = organization.RegularLabel.ToString(); // may need fudging later because localization payload.Strings[NotificationString.ActivistTitle] = organization.ActivistLabel.ToString(); // as above + // TODO: Change the below to resolve to at least the global officers + return CreateSingleRecipientNotification (payload, organization, Person.FromIdentity (1)); } diff --git a/Logic/Communications/Payload/NotificationPayload.cs b/Logic/Communications/Payload/NotificationPayload.cs index 35f7f62e..b97bfb7e 100644 --- a/Logic/Communications/Payload/NotificationPayload.cs +++ b/Logic/Communications/Payload/NotificationPayload.cs @@ -180,6 +180,8 @@ namespace Swarmops.Logic.Communications.Payload Participant_Renewed, Participant_Terminated, Participant_Churned, + Applicant_Signup, + Applicant_Approved, Bitcoin_PaidOut, Bitcoin_Shortage, Bitcoin_Shortage_Urgent, diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index 83126f21..b48ad397 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -223,6 +223,7 @@ + diff --git a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs index d2e73b1c..6352b2b7 100644 --- a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs +++ b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.Designer.cs @@ -60,6 +60,24 @@ namespace Swarmops.Logic.Resources { } } + /// + /// Looks up a localized string similar to A new person has applied to be a [RegularTitle] in [OrganizationName]! [ConcernedPersonName] currently resides in [GeographyName], [CountryCode].. + /// + internal static string Applicant_Signup_Body { + get { + return ResourceManager.GetString("Applicant_Signup_Body", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to [[OrganizationName]] New Applicant: [ConcernedPersonName], [GeographyName]. + /// + internal static string Applicant_Signup_Header { + get { + return ResourceManager.GetString("Applicant_Signup_Header", resourceCulture); + } + } + /// /// Looks up a localized string similar to The bitcoin hotwallet for [OrganizationName] just made [PaymentCount] automatic payment(s) totalling [CurrencyCode] [AmountFloat] ([BitcoinAmountFloat] microbitcoin or "bits").. /// diff --git a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx index d7cb7fb0..9c4c7cb7 100644 --- a/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx +++ b/Logic/Resources/Logic.Communications.Transmission.NotificationPayload.resx @@ -117,6 +117,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + A new person has applied to be a [RegularTitle] in [OrganizationName]! [ConcernedPersonName] currently resides in [GeographyName], [CountryCode]. + + + [[OrganizationName]] New Applicant: [ConcernedPersonName], [GeographyName] + On attempting a payout to your Bitcoin Cash payout address, the address ([BitcoinAddress]) was rejected by the underlying payout engine as invalid. It has therefore been cleared from your profile. diff --git a/Logic/Support/LogEntries/ApplicantAddedLogEntry.cs b/Logic/Support/LogEntries/ApplicantAddedLogEntry.cs new file mode 100644 index 00000000..f24073a3 --- /dev/null +++ b/Logic/Support/LogEntries/ApplicantAddedLogEntry.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Web; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Swarmops.Logic.Structure; +using Swarmops.Logic.Swarm; +using Swarmops.Logic.Support; + +namespace Swarmops.Logic.Support.LogEntries +{ + [Serializable] + public class ApplicantAddedLogEntry: LogEntryBase + { + [Obsolete("Do not call empty ctor directly. Intended for serialization only.", true)] + public ApplicantAddedLogEntry() + { + // Do not call empty ctor directly. Intended for serialization only. + } + + public ApplicantAddedLogEntry (Applicant newApplicant) + { + this.ApplicantId = newApplicant.Identity; + if (HttpContext.Current != null) + { + ActingIPAddress = SupportFunctions.GetMostLikelyRemoteIPAddress(); + } + } + + public int ApplicantId { get; set; } + public string ActingIPAddress { get; set; } + } +} diff --git a/Logic/Support/SwarmopsLogEntry.cs b/Logic/Support/SwarmopsLogEntry.cs index cff354af..9d13ffa6 100644 --- a/Logic/Support/SwarmopsLogEntry.cs +++ b/Logic/Support/SwarmopsLogEntry.cs @@ -30,6 +30,11 @@ namespace Swarmops.Logic.Support // Writing intentional } + public static SwarmopsLogEntry Create(IXmlPayload logEntry, params object[] affectedObjects) + { + return Create(null, logEntry, affectedObjects); + } + public static SwarmopsLogEntry Create (Person person, IXmlPayload logEntry, params object[] affectedObjects) { SwarmopsLogEntry entry = SwarmopsLog.CreateEntry (person, logEntry); diff --git a/Site/Pages/v5/Public/Signup.aspx.cs b/Site/Pages/v5/Public/Signup.aspx.cs index 8f7a97a6..fa817420 100644 --- a/Site/Pages/v5/Public/Signup.aspx.cs +++ b/Site/Pages/v5/Public/Signup.aspx.cs @@ -285,8 +285,10 @@ namespace Swarmops.Frontend.Pages.Public if (organization.Parameters.ParticipationEntry == "ApplicationApproval") { - // Applicant Applicant = - // SwarmopsLog.CreateEntry(newPerson, new ApplicantAddedLogEntry(, newPerson))) + Applicant newApplicant = Applicant.Create(newPerson, organization); + SwarmopsLog.CreateEntry(newPerson, new ApplicantAddedLogEntry(newApplicant)); + OutboundComm.CreateParticipantNotification(newPerson, newPerson, organization, + NotificationResource.Applicant_Signup); } else {