Move module funcs to properties
This commit is contained in:
parent
facc294d66
commit
42e3a58131
@ -69,7 +69,7 @@ module private Helpers =
|
|||||||
{ Id = SmallGroupId (row.uuid "id")
|
{ Id = SmallGroupId (row.uuid "id")
|
||||||
ChurchId = ChurchId (row.uuid "church_id")
|
ChurchId = ChurchId (row.uuid "church_id")
|
||||||
Name = row.string "group_name"
|
Name = row.string "group_name"
|
||||||
Preferences = ListPreferences.empty
|
Preferences = ListPreferences.Empty
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Map a row to a Small Group information set
|
/// Map a row to a Small Group information set
|
||||||
@ -243,12 +243,12 @@ module PrayerRequests =
|
|||||||
|
|
||||||
/// Get all (or active) requests for a small group as of now or the specified date
|
/// Get all (or active) requests for a small group as of now or the specified date
|
||||||
let forGroup (opts : PrayerRequestOptions) =
|
let forGroup (opts : PrayerRequestOptions) =
|
||||||
let theDate = defaultArg opts.ListDate (SmallGroup.localDateNow opts.Clock opts.SmallGroup)
|
let theDate = defaultArg opts.ListDate (opts.SmallGroup.LocalDateNow opts.Clock)
|
||||||
let where, parameters =
|
let where, parameters =
|
||||||
if opts.ActiveOnly then
|
if opts.ActiveOnly then
|
||||||
let asOf = NpgsqlParameter (
|
let asOf = NpgsqlParameter (
|
||||||
"@asOf",
|
"@asOf",
|
||||||
(theDate.AtStartOfDayInZone(SmallGroup.timeZone opts.SmallGroup)
|
(theDate.AtStartOfDayInZone(opts.SmallGroup.TimeZone)
|
||||||
- Duration.FromDays opts.SmallGroup.Preferences.DaysToExpire)
|
- Duration.FromDays opts.SmallGroup.Preferences.DaysToExpire)
|
||||||
.ToInstant ())
|
.ToInstant ())
|
||||||
" AND ( updated_date > @asOf
|
" AND ( updated_date > @asOf
|
||||||
@ -458,7 +458,7 @@ module SmallGroups =
|
|||||||
"@groupPassword", Sql.string pref.GroupPassword
|
"@groupPassword", Sql.string pref.GroupPassword
|
||||||
"@defaultEmailType", Sql.string (string pref.DefaultEmailType)
|
"@defaultEmailType", Sql.string (string pref.DefaultEmailType)
|
||||||
"@isPublic", Sql.bool pref.IsPublic
|
"@isPublic", Sql.bool pref.IsPublic
|
||||||
"@timeZoneId", Sql.string (TimeZoneId.toString pref.TimeZoneId)
|
"@timeZoneId", Sql.string (string pref.TimeZoneId)
|
||||||
"@pageSize", Sql.int pref.PageSize
|
"@pageSize", Sql.int pref.PageSize
|
||||||
"@asOfDateDisplay", Sql.string (string pref.AsOfDateDisplay) ]
|
"@asOfDateDisplay", Sql.string (string pref.AsOfDateDisplay) ]
|
||||||
|
|
||||||
|
@ -174,14 +174,11 @@ type SmallGroupId =
|
|||||||
|
|
||||||
|
|
||||||
/// PK type for the TimeZone entity
|
/// PK type for the TimeZone entity
|
||||||
type TimeZoneId = TimeZoneId of string
|
type TimeZoneId =
|
||||||
|
| TimeZoneId of string
|
||||||
|
|
||||||
/// Functions to support time zone IDs
|
override this.ToString() =
|
||||||
module TimeZoneId =
|
match this with
|
||||||
|
|
||||||
/// Convert a time zone ID to its string value
|
|
||||||
let toString =
|
|
||||||
function
|
|
||||||
| TimeZoneId it -> it
|
| TimeZoneId it -> it
|
||||||
|
|
||||||
|
|
||||||
@ -259,12 +256,9 @@ type Church =
|
|||||||
InterfaceAddress: string option
|
InterfaceAddress: string option
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Functions to support churches
|
|
||||||
module Church =
|
|
||||||
|
|
||||||
/// An empty church
|
/// An empty church
|
||||||
// aww... how sad :(
|
// aww... how sad :(
|
||||||
let empty =
|
static member Empty =
|
||||||
{ Id = ChurchId Guid.Empty
|
{ Id = ChurchId Guid.Empty
|
||||||
Name = ""
|
Name = ""
|
||||||
City = ""
|
City = ""
|
||||||
@ -339,11 +333,8 @@ type ListPreferences =
|
|||||||
else
|
else
|
||||||
this.Fonts
|
this.Fonts
|
||||||
|
|
||||||
/// Functions to support list preferences
|
|
||||||
module ListPreferences =
|
|
||||||
|
|
||||||
/// A set of preferences with their default values
|
/// A set of preferences with their default values
|
||||||
let empty =
|
static member Empty =
|
||||||
{ SmallGroupId = SmallGroupId Guid.Empty
|
{ SmallGroupId = SmallGroupId Guid.Empty
|
||||||
DaysToExpire = 14
|
DaysToExpire = 14
|
||||||
DaysToKeepNew = 7
|
DaysToKeepNew = 7
|
||||||
@ -384,11 +375,8 @@ type Member =
|
|||||||
Format: EmailFormat option
|
Format: EmailFormat option
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Functions to support small group members
|
|
||||||
module Member =
|
|
||||||
|
|
||||||
/// An empty member
|
/// An empty member
|
||||||
let empty =
|
static member Empty =
|
||||||
{ Id = MemberId Guid.Empty
|
{ Id = MemberId Guid.Empty
|
||||||
SmallGroupId = SmallGroupId Guid.Empty
|
SmallGroupId = SmallGroupId Guid.Empty
|
||||||
Name = ""
|
Name = ""
|
||||||
@ -396,6 +384,50 @@ module Member =
|
|||||||
Format = None }
|
Format = None }
|
||||||
|
|
||||||
|
|
||||||
|
/// This represents a small group (Sunday School class, Bible study group, etc.)
|
||||||
|
[<NoComparison; NoEquality>]
|
||||||
|
type SmallGroup =
|
||||||
|
{
|
||||||
|
/// The ID of this small group
|
||||||
|
Id: SmallGroupId
|
||||||
|
|
||||||
|
/// The church to which this group belongs
|
||||||
|
ChurchId: ChurchId
|
||||||
|
|
||||||
|
/// The name of the group
|
||||||
|
Name: string
|
||||||
|
|
||||||
|
/// The preferences for the request list
|
||||||
|
Preferences: ListPreferences
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The DateTimeZone for the time zone ID for this small group
|
||||||
|
member this.TimeZone =
|
||||||
|
let tzId = string this.Preferences.TimeZoneId
|
||||||
|
|
||||||
|
if DateTimeZoneProviders.Tzdb.Ids.Contains tzId then
|
||||||
|
DateTimeZoneProviders.Tzdb[tzId]
|
||||||
|
else
|
||||||
|
DateTimeZone.Utc
|
||||||
|
|
||||||
|
/// Get the local date/time for this group
|
||||||
|
member this.LocalTimeNow(clock: IClock) =
|
||||||
|
if isNull clock then
|
||||||
|
nullArg (nameof clock)
|
||||||
|
|
||||||
|
clock.GetCurrentInstant().InZone(this.TimeZone).LocalDateTime
|
||||||
|
|
||||||
|
/// Get the local date for this group
|
||||||
|
member this.LocalDateNow clock = this.LocalTimeNow(clock).Date
|
||||||
|
|
||||||
|
/// An empty small group
|
||||||
|
static member Empty =
|
||||||
|
{ Id = SmallGroupId Guid.Empty
|
||||||
|
ChurchId = ChurchId Guid.Empty
|
||||||
|
Name = ""
|
||||||
|
Preferences = ListPreferences.Empty }
|
||||||
|
|
||||||
|
|
||||||
/// This represents a single prayer request
|
/// This represents a single prayer request
|
||||||
[<NoComparison; NoEquality>]
|
[<NoComparison; NoEquality>]
|
||||||
type PrayerRequest =
|
type PrayerRequest =
|
||||||
@ -430,61 +462,31 @@ type PrayerRequest =
|
|||||||
/// Is this request expired?
|
/// Is this request expired?
|
||||||
Expiration: Expiration
|
Expiration: Expiration
|
||||||
}
|
}
|
||||||
// functions are below small group functions
|
|
||||||
|
|
||||||
|
/// Is this request expired?
|
||||||
|
member this.IsExpired (asOf: LocalDate) (group: SmallGroup) =
|
||||||
|
match this.Expiration, this.RequestType with
|
||||||
|
| Forced, _ -> true
|
||||||
|
| Manual, _
|
||||||
|
| Automatic, LongTermRequest
|
||||||
|
| Automatic, Expecting -> false
|
||||||
|
| Automatic, _ ->
|
||||||
|
// Automatic expiration
|
||||||
|
Period
|
||||||
|
.Between(this.UpdatedDate.InZone(group.TimeZone).Date, asOf, PeriodUnits.Days)
|
||||||
|
.Days
|
||||||
|
>= group.Preferences.DaysToExpire
|
||||||
|
|
||||||
/// This represents a small group (Sunday School class, Bible study group, etc.)
|
/// Is an update required for this long-term request?
|
||||||
[<NoComparison; NoEquality>]
|
member this.UpdateRequired asOf group =
|
||||||
type SmallGroup =
|
if this.IsExpired asOf group then
|
||||||
{
|
false
|
||||||
/// The ID of this small group
|
|
||||||
Id: SmallGroupId
|
|
||||||
|
|
||||||
/// The church to which this group belongs
|
|
||||||
ChurchId: ChurchId
|
|
||||||
|
|
||||||
/// The name of the group
|
|
||||||
Name: string
|
|
||||||
|
|
||||||
/// The preferences for the request list
|
|
||||||
Preferences: ListPreferences
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Functions to support small groups
|
|
||||||
module SmallGroup =
|
|
||||||
|
|
||||||
/// An empty small group
|
|
||||||
let empty =
|
|
||||||
{ Id = SmallGroupId Guid.Empty
|
|
||||||
ChurchId = ChurchId Guid.Empty
|
|
||||||
Name = ""
|
|
||||||
Preferences = ListPreferences.empty }
|
|
||||||
|
|
||||||
/// The DateTimeZone for the time zone ID for this small group
|
|
||||||
let timeZone group =
|
|
||||||
let tzId = TimeZoneId.toString group.Preferences.TimeZoneId
|
|
||||||
|
|
||||||
if DateTimeZoneProviders.Tzdb.Ids.Contains tzId then
|
|
||||||
DateTimeZoneProviders.Tzdb[tzId]
|
|
||||||
else
|
else
|
||||||
DateTimeZone.Utc
|
asOf.PlusWeeks -group.Preferences.LongTermUpdateWeeks
|
||||||
|
>= this.UpdatedDate.InZone(group.TimeZone).Date
|
||||||
/// Get the local date/time for this group
|
|
||||||
let localTimeNow (clock: IClock) group =
|
|
||||||
if isNull clock then
|
|
||||||
nullArg (nameof clock)
|
|
||||||
|
|
||||||
clock.GetCurrentInstant().InZone(timeZone group).LocalDateTime
|
|
||||||
|
|
||||||
/// Get the local date for this group
|
|
||||||
let localDateNow clock group = (localTimeNow clock group).Date
|
|
||||||
|
|
||||||
|
|
||||||
/// Functions to support prayer requests
|
|
||||||
module PrayerRequest =
|
|
||||||
|
|
||||||
/// An empty request
|
/// An empty request
|
||||||
let empty =
|
static member Empty =
|
||||||
{ Id = PrayerRequestId Guid.Empty
|
{ Id = PrayerRequestId Guid.Empty
|
||||||
RequestType = CurrentRequest
|
RequestType = CurrentRequest
|
||||||
UserId = UserId Guid.Empty
|
UserId = UserId Guid.Empty
|
||||||
@ -496,28 +498,6 @@ module PrayerRequest =
|
|||||||
NotifyChaplain = false
|
NotifyChaplain = false
|
||||||
Expiration = Automatic }
|
Expiration = Automatic }
|
||||||
|
|
||||||
/// Is this request expired?
|
|
||||||
let isExpired (asOf: LocalDate) group req =
|
|
||||||
match req.Expiration, req.RequestType with
|
|
||||||
| Forced, _ -> true
|
|
||||||
| Manual, _
|
|
||||||
| Automatic, LongTermRequest
|
|
||||||
| Automatic, Expecting -> false
|
|
||||||
| Automatic, _ ->
|
|
||||||
// Automatic expiration
|
|
||||||
Period
|
|
||||||
.Between(req.UpdatedDate.InZone(SmallGroup.timeZone group).Date, asOf, PeriodUnits.Days)
|
|
||||||
.Days
|
|
||||||
>= group.Preferences.DaysToExpire
|
|
||||||
|
|
||||||
/// Is an update required for this long-term request?
|
|
||||||
let updateRequired asOf group req =
|
|
||||||
if isExpired asOf group req then
|
|
||||||
false
|
|
||||||
else
|
|
||||||
asOf.PlusWeeks -group.Preferences.LongTermUpdateWeeks
|
|
||||||
>= req.UpdatedDate.InZone(SmallGroup.timeZone group).Date
|
|
||||||
|
|
||||||
|
|
||||||
/// This represents a user of PrayerTracker
|
/// This represents a user of PrayerTracker
|
||||||
[<NoComparison; NoEquality>]
|
[<NoComparison; NoEquality>]
|
||||||
@ -548,11 +528,8 @@ type User =
|
|||||||
/// The full name of the user
|
/// The full name of the user
|
||||||
member this.Name = $"{this.FirstName} {this.LastName}"
|
member this.Name = $"{this.FirstName} {this.LastName}"
|
||||||
|
|
||||||
/// Functions to support users
|
|
||||||
module User =
|
|
||||||
|
|
||||||
/// An empty user
|
/// An empty user
|
||||||
let empty =
|
static member Empty =
|
||||||
{ Id = UserId Guid.Empty
|
{ Id = UserId Guid.Empty
|
||||||
FirstName = ""
|
FirstName = ""
|
||||||
LastName = ""
|
LastName = ""
|
||||||
@ -573,10 +550,7 @@ type UserSmallGroup =
|
|||||||
SmallGroupId: SmallGroupId
|
SmallGroupId: SmallGroupId
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Functions to support user/small group cross-reference
|
|
||||||
module UserSmallGroup =
|
|
||||||
|
|
||||||
/// An empty user/small group xref
|
/// An empty user/small group xref
|
||||||
let empty =
|
static member Empty =
|
||||||
{ UserId = UserId Guid.Empty
|
{ UserId = UserId Guid.Empty
|
||||||
SmallGroupId = SmallGroupId Guid.Empty }
|
SmallGroupId = SmallGroupId Guid.Empty }
|
||||||
|
@ -39,8 +39,8 @@ let asOfDateDisplayTests =
|
|||||||
[<Tests>]
|
[<Tests>]
|
||||||
let churchTests =
|
let churchTests =
|
||||||
testList "Church" [
|
testList "Church" [
|
||||||
test "empty is as expected" {
|
test "Empty is as expected" {
|
||||||
let mt = Church.empty
|
let mt = Church.Empty
|
||||||
Expect.equal mt.Id.Value Guid.Empty "The church ID should have been an empty GUID"
|
Expect.equal mt.Id.Value Guid.Empty "The church ID should have been an empty GUID"
|
||||||
Expect.equal mt.Name "" "The name should have been blank"
|
Expect.equal mt.Name "" "The name should have been blank"
|
||||||
Expect.equal mt.City "" "The city should have been blank"
|
Expect.equal mt.City "" "The city should have been blank"
|
||||||
@ -111,16 +111,16 @@ let expirationTests =
|
|||||||
let listPreferencesTests =
|
let listPreferencesTests =
|
||||||
testList "ListPreferences" [
|
testList "ListPreferences" [
|
||||||
test "FontStack is correct for native fonts" {
|
test "FontStack is correct for native fonts" {
|
||||||
Expect.equal ListPreferences.empty.FontStack
|
Expect.equal ListPreferences.Empty.FontStack
|
||||||
"""system-ui,-apple-system,"Segoe UI",Roboto,Ubuntu,"Liberation Sans",Cantarell,"Helvetica Neue",sans-serif"""
|
"""system-ui,-apple-system,"Segoe UI",Roboto,Ubuntu,"Liberation Sans",Cantarell,"Helvetica Neue",sans-serif"""
|
||||||
"The expected native font stack was incorrect"
|
"The expected native font stack was incorrect"
|
||||||
}
|
}
|
||||||
test "FontStack is correct for specific fonts" {
|
test "FontStack is correct for specific fonts" {
|
||||||
Expect.equal { ListPreferences.empty with Fonts = "Arial,sans-serif" }.FontStack "Arial,sans-serif"
|
Expect.equal { ListPreferences.Empty with Fonts = "Arial,sans-serif" }.FontStack "Arial,sans-serif"
|
||||||
"The specified fonts were not returned correctly"
|
"The specified fonts were not returned correctly"
|
||||||
}
|
}
|
||||||
test "empty is as expected" {
|
test "Empty is as expected" {
|
||||||
let mt = ListPreferences.empty
|
let mt = ListPreferences.Empty
|
||||||
Expect.equal mt.SmallGroupId.Value Guid.Empty "The small group ID should have been an empty GUID"
|
Expect.equal mt.SmallGroupId.Value Guid.Empty "The small group ID should have been an empty GUID"
|
||||||
Expect.equal mt.DaysToExpire 14 "The default days to expire should have been 14"
|
Expect.equal mt.DaysToExpire 14 "The default days to expire should have been 14"
|
||||||
Expect.equal mt.DaysToKeepNew 7 "The default days to keep new should have been 7"
|
Expect.equal mt.DaysToKeepNew 7 "The default days to keep new should have been 7"
|
||||||
@ -137,8 +137,7 @@ let listPreferencesTests =
|
|||||||
Expect.equal mt.GroupPassword "" "The default group password should have been blank"
|
Expect.equal mt.GroupPassword "" "The default group password should have been blank"
|
||||||
Expect.equal mt.DefaultEmailType HtmlFormat "The default e-mail type should have been HTML"
|
Expect.equal mt.DefaultEmailType HtmlFormat "The default e-mail type should have been HTML"
|
||||||
Expect.isFalse mt.IsPublic "The isPublic flag should not have been set"
|
Expect.isFalse mt.IsPublic "The isPublic flag should not have been set"
|
||||||
Expect.equal (TimeZoneId.toString mt.TimeZoneId) "America/Denver"
|
Expect.equal (string mt.TimeZoneId) "America/Denver" "The default time zone should have been America/Denver"
|
||||||
"The default time zone should have been America/Denver"
|
|
||||||
Expect.equal mt.PageSize 100 "The default page size should have been 100"
|
Expect.equal mt.PageSize 100 "The default page size should have been 100"
|
||||||
Expect.equal mt.AsOfDateDisplay NoDisplay "The as-of date display should have been No Display"
|
Expect.equal mt.AsOfDateDisplay NoDisplay "The as-of date display should have been No Display"
|
||||||
}
|
}
|
||||||
@ -147,8 +146,8 @@ let listPreferencesTests =
|
|||||||
[<Tests>]
|
[<Tests>]
|
||||||
let memberTests =
|
let memberTests =
|
||||||
testList "Member" [
|
testList "Member" [
|
||||||
test "empty is as expected" {
|
test "Empty is as expected" {
|
||||||
let mt = Member.empty
|
let mt = Member.Empty
|
||||||
Expect.equal mt.Id.Value Guid.Empty "The member ID should have been an empty GUID"
|
Expect.equal mt.Id.Value Guid.Empty "The member ID should have been an empty GUID"
|
||||||
Expect.equal mt.SmallGroupId.Value Guid.Empty "The small group ID should have been an empty GUID"
|
Expect.equal mt.SmallGroupId.Value Guid.Empty "The small group ID should have been an empty GUID"
|
||||||
Expect.equal mt.Name "" "The member name should have been blank"
|
Expect.equal mt.Name "" "The member name should have been blank"
|
||||||
@ -162,8 +161,8 @@ let prayerRequestTests =
|
|||||||
let instantNow = SystemClock.Instance.GetCurrentInstant
|
let instantNow = SystemClock.Instance.GetCurrentInstant
|
||||||
let localDateNow () = (instantNow ()).InUtc().Date
|
let localDateNow () = (instantNow ()).InUtc().Date
|
||||||
testList "PrayerRequest" [
|
testList "PrayerRequest" [
|
||||||
test "empty is as expected" {
|
test "Empty is as expected" {
|
||||||
let mt = PrayerRequest.empty
|
let mt = PrayerRequest.Empty
|
||||||
Expect.equal mt.Id.Value Guid.Empty "The request ID should have been an empty GUID"
|
Expect.equal mt.Id.Value Guid.Empty "The request ID should have been an empty GUID"
|
||||||
Expect.equal mt.RequestType CurrentRequest "The request type should have been Current"
|
Expect.equal mt.RequestType CurrentRequest "The request type should have been Current"
|
||||||
Expect.equal mt.UserId.Value Guid.Empty "The user ID should have been an empty GUID"
|
Expect.equal mt.UserId.Value Guid.Empty "The user ID should have been an empty GUID"
|
||||||
@ -175,59 +174,60 @@ let prayerRequestTests =
|
|||||||
Expect.isFalse mt.NotifyChaplain "The notify chaplain flag should not have been set"
|
Expect.isFalse mt.NotifyChaplain "The notify chaplain flag should not have been set"
|
||||||
Expect.equal mt.Expiration Automatic "The expiration should have been Automatic"
|
Expect.equal mt.Expiration Automatic "The expiration should have been Automatic"
|
||||||
}
|
}
|
||||||
test "isExpired always returns false for expecting requests" {
|
test "IsExpired always returns false for expecting requests" {
|
||||||
PrayerRequest.isExpired (localDateNow ()) SmallGroup.empty
|
{ PrayerRequest.Empty with RequestType = Expecting }.IsExpired (localDateNow ()) SmallGroup.Empty
|
||||||
{ PrayerRequest.empty with RequestType = Expecting }
|
|
||||||
|> Flip.Expect.isFalse "An expecting request should never be considered expired"
|
|> Flip.Expect.isFalse "An expecting request should never be considered expired"
|
||||||
}
|
}
|
||||||
test "isExpired always returns false for manually-expired requests" {
|
test "IsExpired always returns false for manually-expired requests" {
|
||||||
PrayerRequest.isExpired (localDateNow ()) SmallGroup.empty
|
{ PrayerRequest.Empty with
|
||||||
{ PrayerRequest.empty with UpdatedDate = (instantNow ()) - Duration.FromDays 1; Expiration = Manual }
|
UpdatedDate = (instantNow ()) - Duration.FromDays 1
|
||||||
|
Expiration = Manual }.IsExpired (localDateNow ()) SmallGroup.Empty
|
||||||
|> Flip.Expect.isFalse "A never-expired request should never be considered expired"
|
|> Flip.Expect.isFalse "A never-expired request should never be considered expired"
|
||||||
}
|
}
|
||||||
test "isExpired always returns false for long term/recurring requests" {
|
test "IsExpired always returns false for long term/recurring requests" {
|
||||||
PrayerRequest.isExpired (localDateNow ()) SmallGroup.empty
|
{ PrayerRequest.Empty with RequestType = LongTermRequest }.IsExpired (localDateNow ()) SmallGroup.Empty
|
||||||
{ PrayerRequest.empty with RequestType = LongTermRequest }
|
|
||||||
|> Flip.Expect.isFalse "A recurring/long-term request should never be considered expired"
|
|> Flip.Expect.isFalse "A recurring/long-term request should never be considered expired"
|
||||||
}
|
}
|
||||||
test "isExpired always returns true for force-expired requests" {
|
test "IsExpired always returns true for force-expired requests" {
|
||||||
PrayerRequest.isExpired (localDateNow ()) SmallGroup.empty
|
{ PrayerRequest.Empty with UpdatedDate = (instantNow ()); Expiration = Forced }.IsExpired
|
||||||
{ PrayerRequest.empty with UpdatedDate = (instantNow ()); Expiration = Forced }
|
(localDateNow ()) SmallGroup.Empty
|
||||||
|> Flip.Expect.isTrue "A force-expired request should always be considered expired"
|
|> Flip.Expect.isTrue "A force-expired request should always be considered expired"
|
||||||
}
|
}
|
||||||
test "isExpired returns false for non-expired requests" {
|
test "IsExpired returns false for non-expired requests" {
|
||||||
let now = instantNow ()
|
let now = instantNow ()
|
||||||
PrayerRequest.isExpired (now.InUtc().Date) SmallGroup.empty
|
{ PrayerRequest.Empty with UpdatedDate = now - Duration.FromDays 5 }.IsExpired
|
||||||
{ PrayerRequest.empty with UpdatedDate = now - Duration.FromDays 5 }
|
(now.InUtc().Date) SmallGroup.Empty
|
||||||
|> Flip.Expect.isFalse "A request updated 5 days ago should not be considered expired"
|
|> Flip.Expect.isFalse "A request updated 5 days ago should not be considered expired"
|
||||||
}
|
}
|
||||||
test "isExpired returns true for expired requests" {
|
test "IsExpired returns true for expired requests" {
|
||||||
let now = instantNow ()
|
let now = instantNow ()
|
||||||
PrayerRequest.isExpired (now.InUtc().Date) SmallGroup.empty
|
{ PrayerRequest.Empty with UpdatedDate = now - Duration.FromDays 15 }.IsExpired
|
||||||
{ PrayerRequest.empty with UpdatedDate = now - Duration.FromDays 15 }
|
(now.InUtc().Date) SmallGroup.Empty
|
||||||
|> Flip.Expect.isTrue "A request updated 15 days ago should be considered expired"
|
|> Flip.Expect.isTrue "A request updated 15 days ago should be considered expired"
|
||||||
}
|
}
|
||||||
test "isExpired returns true for same-day expired requests" {
|
test "IsExpired returns true for same-day expired requests" {
|
||||||
let now = instantNow ()
|
let now = instantNow ()
|
||||||
PrayerRequest.isExpired (now.InUtc().Date) SmallGroup.empty
|
{ PrayerRequest.Empty with
|
||||||
{ PrayerRequest.empty with UpdatedDate = now - (Duration.FromDays 14) - (Duration.FromSeconds 1L) }
|
UpdatedDate = now - (Duration.FromDays 14) - (Duration.FromSeconds 1L) }.IsExpired
|
||||||
|
(now.InUtc().Date) SmallGroup.Empty
|
||||||
|> Flip.Expect.isTrue "A request entered a second before midnight should be considered expired"
|
|> Flip.Expect.isTrue "A request entered a second before midnight should be considered expired"
|
||||||
}
|
}
|
||||||
test "updateRequired returns false for expired requests" {
|
test "UpdateRequired returns false for expired requests" {
|
||||||
PrayerRequest.updateRequired (localDateNow ()) SmallGroup.empty
|
{ PrayerRequest.Empty with Expiration = Forced }.UpdateRequired (localDateNow ()) SmallGroup.Empty
|
||||||
{ PrayerRequest.empty with Expiration = Forced }
|
|
||||||
|> Flip.Expect.isFalse "An expired request should not require an update"
|
|> Flip.Expect.isFalse "An expired request should not require an update"
|
||||||
}
|
}
|
||||||
test "updateRequired returns false when an update is not required for an active request" {
|
test "UpdateRequired returns false when an update is not required for an active request" {
|
||||||
let now = instantNow ()
|
let now = instantNow ()
|
||||||
PrayerRequest.updateRequired (localDateNow ()) SmallGroup.empty
|
{ PrayerRequest.Empty with
|
||||||
{ PrayerRequest.empty with RequestType = LongTermRequest; UpdatedDate = now - Duration.FromDays 14 }
|
RequestType = LongTermRequest
|
||||||
|
UpdatedDate = now - Duration.FromDays 14 }.UpdateRequired (localDateNow ()) SmallGroup.Empty
|
||||||
|> Flip.Expect.isFalse "An active request updated 14 days ago should not require an update until 28 days"
|
|> Flip.Expect.isFalse "An active request updated 14 days ago should not require an update until 28 days"
|
||||||
}
|
}
|
||||||
test "UpdateRequired returns true when an update is required for an active request" {
|
test "UpdateRequired returns true when an update is required for an active request" {
|
||||||
let now = instantNow ()
|
let now = instantNow ()
|
||||||
PrayerRequest.updateRequired (localDateNow ()) SmallGroup.empty
|
{ PrayerRequest.Empty with
|
||||||
{ PrayerRequest.empty with RequestType = LongTermRequest; UpdatedDate = now - Duration.FromDays 34 }
|
RequestType = LongTermRequest
|
||||||
|
UpdatedDate = now - Duration.FromDays 34 }.UpdateRequired (localDateNow ()) SmallGroup.Empty
|
||||||
|> Flip.Expect.isTrue "An active request updated 34 days ago should require an update (past 28 days)"
|
|> Flip.Expect.isTrue "An active request updated 34 days ago should require an update (past 28 days)"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -311,8 +311,8 @@ let smallGroupTests =
|
|||||||
let now = Instant.FromDateTimeUtc (DateTime (2017, 5, 12, 12, 15, 0, DateTimeKind.Utc))
|
let now = Instant.FromDateTimeUtc (DateTime (2017, 5, 12, 12, 15, 0, DateTimeKind.Utc))
|
||||||
let withFakeClock f () =
|
let withFakeClock f () =
|
||||||
FakeClock now |> f
|
FakeClock now |> f
|
||||||
yield test "empty is as expected" {
|
yield test "Empty is as expected" {
|
||||||
let mt = SmallGroup.empty
|
let mt = SmallGroup.Empty
|
||||||
Expect.equal mt.Id.Value Guid.Empty "The small group ID should have been an empty GUID"
|
Expect.equal mt.Id.Value Guid.Empty "The small group ID should have been an empty GUID"
|
||||||
Expect.equal mt.ChurchId.Value Guid.Empty "The church ID should have been an empty GUID"
|
Expect.equal mt.ChurchId.Value Guid.Empty "The church ID should have been an empty GUID"
|
||||||
Expect.equal mt.Name "" "The name should have been blank"
|
Expect.equal mt.Name "" "The name should have been blank"
|
||||||
@ -321,31 +321,31 @@ let smallGroupTests =
|
|||||||
"LocalTimeNow adjusts the time ahead of UTC",
|
"LocalTimeNow adjusts the time ahead of UTC",
|
||||||
fun clock ->
|
fun clock ->
|
||||||
let grp =
|
let grp =
|
||||||
{ SmallGroup.empty with
|
{ SmallGroup.Empty with
|
||||||
Preferences = { ListPreferences.empty with TimeZoneId = TimeZoneId "Europe/Berlin" }
|
Preferences = { ListPreferences.Empty with TimeZoneId = TimeZoneId "Europe/Berlin" }
|
||||||
}
|
}
|
||||||
Expect.isGreaterThan (SmallGroup.localTimeNow clock grp) (now.InUtc().LocalDateTime)
|
Expect.isGreaterThan (grp.LocalTimeNow clock) (now.InUtc().LocalDateTime)
|
||||||
"UTC to Europe/Berlin should have added hours"
|
"UTC to Europe/Berlin should have added hours"
|
||||||
"LocalTimeNow adjusts the time behind UTC",
|
"LocalTimeNow adjusts the time behind UTC",
|
||||||
fun clock ->
|
fun clock ->
|
||||||
Expect.isLessThan (SmallGroup.localTimeNow clock SmallGroup.empty) (now.InUtc().LocalDateTime)
|
Expect.isLessThan (SmallGroup.Empty.LocalTimeNow clock) (now.InUtc().LocalDateTime)
|
||||||
"UTC to America/Denver should have subtracted hours"
|
"UTC to America/Denver should have subtracted hours"
|
||||||
"LocalTimeNow returns UTC when the time zone is invalid",
|
"LocalTimeNow returns UTC when the time zone is invalid",
|
||||||
fun clock ->
|
fun clock ->
|
||||||
let grp =
|
let grp =
|
||||||
{ SmallGroup.empty with
|
{ SmallGroup.Empty with
|
||||||
Preferences = { ListPreferences.empty with TimeZoneId = TimeZoneId "garbage" }
|
Preferences = { ListPreferences.Empty with TimeZoneId = TimeZoneId "garbage" }
|
||||||
}
|
}
|
||||||
Expect.equal (SmallGroup.localTimeNow clock grp) (now.InUtc().LocalDateTime)
|
Expect.equal (grp.LocalTimeNow clock) (now.InUtc().LocalDateTime)
|
||||||
"UTC should have been returned for an invalid time zone"
|
"UTC should have been returned for an invalid time zone"
|
||||||
]
|
]
|
||||||
yield test "localTimeNow fails when clock is not passed" {
|
yield test "localTimeNow fails when clock is not passed" {
|
||||||
Expect.throws (fun () -> (SmallGroup.localTimeNow null SmallGroup.empty |> ignore))
|
Expect.throws (fun () -> SmallGroup.Empty.LocalTimeNow null |> ignore)
|
||||||
"Should have raised an exception for null clock"
|
"Should have raised an exception for null clock"
|
||||||
}
|
}
|
||||||
yield test "LocalDateNow returns the date portion" {
|
yield test "LocalDateNow returns the date portion" {
|
||||||
let clock = FakeClock (Instant.FromDateTimeUtc (DateTime (2017, 5, 12, 1, 15, 0, DateTimeKind.Utc)))
|
let clock = FakeClock (Instant.FromDateTimeUtc (DateTime (2017, 5, 12, 1, 15, 0, DateTimeKind.Utc)))
|
||||||
Expect.isLessThan (SmallGroup.localDateNow clock SmallGroup.empty) (now.InUtc().Date)
|
Expect.isLessThan (SmallGroup.Empty.LocalDateNow clock) (now.InUtc().Date)
|
||||||
"The date should have been a day earlier"
|
"The date should have been a day earlier"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -353,8 +353,8 @@ let smallGroupTests =
|
|||||||
[<Tests>]
|
[<Tests>]
|
||||||
let userTests =
|
let userTests =
|
||||||
testList "User" [
|
testList "User" [
|
||||||
test "empty is as expected" {
|
test "Empty is as expected" {
|
||||||
let mt = User.empty
|
let mt = User.Empty
|
||||||
Expect.equal mt.Id.Value Guid.Empty "The user ID should have been an empty GUID"
|
Expect.equal mt.Id.Value Guid.Empty "The user ID should have been an empty GUID"
|
||||||
Expect.equal mt.FirstName "" "The first name should have been blank"
|
Expect.equal mt.FirstName "" "The first name should have been blank"
|
||||||
Expect.equal mt.LastName "" "The last name should have been blank"
|
Expect.equal mt.LastName "" "The last name should have been blank"
|
||||||
@ -363,7 +363,7 @@ let userTests =
|
|||||||
Expect.equal mt.PasswordHash "" "The password hash should have been blank"
|
Expect.equal mt.PasswordHash "" "The password hash should have been blank"
|
||||||
}
|
}
|
||||||
test "Name concatenates first and last names" {
|
test "Name concatenates first and last names" {
|
||||||
let user = { User.empty with FirstName = "Unit"; LastName = "Test" }
|
let user = { User.Empty with FirstName = "Unit"; LastName = "Test" }
|
||||||
Expect.equal user.Name "Unit Test" "The full name should be the first and last, separated by a space"
|
Expect.equal user.Name "Unit Test" "The full name should be the first and last, separated by a space"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -371,8 +371,8 @@ let userTests =
|
|||||||
[<Tests>]
|
[<Tests>]
|
||||||
let userSmallGroupTests =
|
let userSmallGroupTests =
|
||||||
testList "UserSmallGroup" [
|
testList "UserSmallGroup" [
|
||||||
test "empty is as expected" {
|
test "Empty is as expected" {
|
||||||
let mt = UserSmallGroup.empty
|
let mt = UserSmallGroup.Empty
|
||||||
Expect.equal mt.UserId.Value Guid.Empty "The user ID should have been an empty GUID"
|
Expect.equal mt.UserId.Value Guid.Empty "The user ID should have been an empty GUID"
|
||||||
Expect.equal mt.SmallGroupId.Value Guid.Empty "The small group ID should have been an empty GUID"
|
Expect.equal mt.SmallGroupId.Value Guid.Empty "The small group ID should have been an empty GUID"
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ let appViewInfoTests =
|
|||||||
let assignGroupsTests =
|
let assignGroupsTests =
|
||||||
testList "AssignGroups" [
|
testList "AssignGroups" [
|
||||||
test "fromUser populates correctly" {
|
test "fromUser populates correctly" {
|
||||||
let usr = { User.empty with Id = (Guid.NewGuid >> UserId) (); FirstName = "Alice"; LastName = "Bob" }
|
let usr = { User.Empty with Id = (Guid.NewGuid >> UserId) (); FirstName = "Alice"; LastName = "Bob" }
|
||||||
let asg = AssignGroups.fromUser usr
|
let asg = AssignGroups.fromUser usr
|
||||||
Expect.equal asg.UserId (shortGuid usr.Id.Value) "The user ID was not filled correctly"
|
Expect.equal asg.UserId (shortGuid usr.Id.Value) "The user ID was not filled correctly"
|
||||||
Expect.equal asg.UserName usr.Name "The user's name was not filled correctly"
|
Expect.equal asg.UserName usr.Name "The user's name was not filled correctly"
|
||||||
@ -142,7 +142,7 @@ let editChurchTests =
|
|||||||
testList "EditChurch" [
|
testList "EditChurch" [
|
||||||
test "fromChurch populates correctly when interface exists" {
|
test "fromChurch populates correctly when interface exists" {
|
||||||
let church =
|
let church =
|
||||||
{ Church.empty with
|
{ Church.Empty with
|
||||||
Id = (Guid.NewGuid >> ChurchId) ()
|
Id = (Guid.NewGuid >> ChurchId) ()
|
||||||
Name = "Unit Test"
|
Name = "Unit Test"
|
||||||
City = "Testlandia"
|
City = "Testlandia"
|
||||||
@ -163,7 +163,7 @@ let editChurchTests =
|
|||||||
test "fromChurch populates correctly when interface does not exist" {
|
test "fromChurch populates correctly when interface does not exist" {
|
||||||
let edit =
|
let edit =
|
||||||
EditChurch.fromChurch
|
EditChurch.fromChurch
|
||||||
{ Church.empty with
|
{ Church.Empty with
|
||||||
Id = (Guid.NewGuid >> ChurchId) ()
|
Id = (Guid.NewGuid >> ChurchId) ()
|
||||||
Name = "Unit Test"
|
Name = "Unit Test"
|
||||||
City = "Testlandia"
|
City = "Testlandia"
|
||||||
@ -198,7 +198,7 @@ let editChurchTests =
|
|||||||
HasInterface = Some true
|
HasInterface = Some true
|
||||||
InterfaceAddress = Some "https://test.units"
|
InterfaceAddress = Some "https://test.units"
|
||||||
}
|
}
|
||||||
let church = edit.PopulateChurch Church.empty
|
let church = edit.PopulateChurch Church.Empty
|
||||||
Expect.notEqual (shortGuid church.Id.Value) edit.ChurchId "The church ID should not have been modified"
|
Expect.notEqual (shortGuid church.Id.Value) edit.ChurchId "The church ID should not have been modified"
|
||||||
Expect.equal church.Name edit.Name "The church name was not updated correctly"
|
Expect.equal church.Name edit.Name "The church name was not updated correctly"
|
||||||
Expect.equal church.City edit.City "The church's city was not updated correctly"
|
Expect.equal church.City edit.City "The church's city was not updated correctly"
|
||||||
@ -213,7 +213,7 @@ let editChurchTests =
|
|||||||
Name = "Test Baptist Church"
|
Name = "Test Baptist Church"
|
||||||
City = "Testerville"
|
City = "Testerville"
|
||||||
State = "TE"
|
State = "TE"
|
||||||
}.PopulateChurch Church.empty
|
}.PopulateChurch Church.Empty
|
||||||
Expect.isFalse church.HasVpsInterface "The church should show that it has an interface"
|
Expect.isFalse church.HasVpsInterface "The church should show that it has an interface"
|
||||||
Expect.isNone church.InterfaceAddress "The interface address should exist"
|
Expect.isNone church.InterfaceAddress "The interface address should exist"
|
||||||
}
|
}
|
||||||
@ -224,7 +224,7 @@ let editMemberTests =
|
|||||||
testList "EditMember" [
|
testList "EditMember" [
|
||||||
test "fromMember populates with group default format" {
|
test "fromMember populates with group default format" {
|
||||||
let mbr =
|
let mbr =
|
||||||
{ Member.empty with
|
{ Member.Empty with
|
||||||
Id = (Guid.NewGuid >> MemberId) ()
|
Id = (Guid.NewGuid >> MemberId) ()
|
||||||
Name = "Test Name"
|
Name = "Test Name"
|
||||||
Email = "test_units@example.com"
|
Email = "test_units@example.com"
|
||||||
@ -236,7 +236,7 @@ let editMemberTests =
|
|||||||
Expect.equal edit.Format "" "The e-mail format should have been blank for group default"
|
Expect.equal edit.Format "" "The e-mail format should have been blank for group default"
|
||||||
}
|
}
|
||||||
test "fromMember populates with specific format" {
|
test "fromMember populates with specific format" {
|
||||||
let edit = EditMember.fromMember { Member.empty with Format = Some HtmlFormat }
|
let edit = EditMember.fromMember { Member.Empty with Format = Some HtmlFormat }
|
||||||
Expect.equal edit.Format (string HtmlFormat) "The e-mail format was not filled correctly"
|
Expect.equal edit.Format (string HtmlFormat) "The e-mail format was not filled correctly"
|
||||||
}
|
}
|
||||||
test "empty is as expected" {
|
test "empty is as expected" {
|
||||||
@ -259,7 +259,7 @@ let editMemberTests =
|
|||||||
let editPreferencesTests =
|
let editPreferencesTests =
|
||||||
testList "EditPreferences" [
|
testList "EditPreferences" [
|
||||||
test "fromPreferences succeeds for native fonts, named colors, and private list" {
|
test "fromPreferences succeeds for native fonts, named colors, and private list" {
|
||||||
let prefs = ListPreferences.empty
|
let prefs = ListPreferences.Empty
|
||||||
let edit = EditPreferences.fromPreferences prefs
|
let edit = EditPreferences.fromPreferences prefs
|
||||||
Expect.equal edit.ExpireDays prefs.DaysToExpire "The expiration days were not filled correctly"
|
Expect.equal edit.ExpireDays prefs.DaysToExpire "The expiration days were not filled correctly"
|
||||||
Expect.equal edit.DaysToKeepNew prefs.DaysToKeepNew "The days to keep new were not filled correctly"
|
Expect.equal edit.DaysToKeepNew prefs.DaysToKeepNew "The days to keep new were not filled correctly"
|
||||||
@ -278,7 +278,7 @@ let editPreferencesTests =
|
|||||||
Expect.isNone edit.Fonts "The list fonts should not exist for native font stack"
|
Expect.isNone edit.Fonts "The list fonts should not exist for native font stack"
|
||||||
Expect.equal edit.HeadingFontSize prefs.HeadingFontSize "The heading font size was not filled correctly"
|
Expect.equal edit.HeadingFontSize prefs.HeadingFontSize "The heading font size was not filled correctly"
|
||||||
Expect.equal edit.ListFontSize prefs.TextFontSize "The list text font size was not filled correctly"
|
Expect.equal edit.ListFontSize prefs.TextFontSize "The list text font size was not filled correctly"
|
||||||
Expect.equal edit.TimeZone (TimeZoneId.toString prefs.TimeZoneId) "The time zone was not filled correctly"
|
Expect.equal edit.TimeZone (string prefs.TimeZoneId) "The time zone was not filled correctly"
|
||||||
Expect.isSome edit.GroupPassword "The group password should have been set"
|
Expect.isSome edit.GroupPassword "The group password should have been set"
|
||||||
Expect.equal edit.GroupPassword (Some prefs.GroupPassword) "The group password was not filled correctly"
|
Expect.equal edit.GroupPassword (Some prefs.GroupPassword) "The group password was not filled correctly"
|
||||||
Expect.equal edit.Visibility GroupVisibility.PrivateList
|
Expect.equal edit.Visibility GroupVisibility.PrivateList
|
||||||
@ -287,7 +287,7 @@ let editPreferencesTests =
|
|||||||
Expect.equal edit.AsOfDate (string prefs.AsOfDateDisplay) "The as-of date display was not filled correctly"
|
Expect.equal edit.AsOfDate (string prefs.AsOfDateDisplay) "The as-of date display was not filled correctly"
|
||||||
}
|
}
|
||||||
test "fromPreferences succeeds for RGB line color and password-protected list" {
|
test "fromPreferences succeeds for RGB line color and password-protected list" {
|
||||||
let prefs = { ListPreferences.empty with LineColor = "#ff0000"; GroupPassword = "pw" }
|
let prefs = { ListPreferences.Empty with LineColor = "#ff0000"; GroupPassword = "pw" }
|
||||||
let edit = EditPreferences.fromPreferences prefs
|
let edit = EditPreferences.fromPreferences prefs
|
||||||
Expect.equal edit.LineColorType "RGB" "The heading line color type was not derived correctly"
|
Expect.equal edit.LineColorType "RGB" "The heading line color type was not derived correctly"
|
||||||
Expect.equal edit.LineColor prefs.LineColor "The heading line color was not filled correctly"
|
Expect.equal edit.LineColor prefs.LineColor "The heading line color was not filled correctly"
|
||||||
@ -297,7 +297,7 @@ let editPreferencesTests =
|
|||||||
"The list visibility was not derived correctly"
|
"The list visibility was not derived correctly"
|
||||||
}
|
}
|
||||||
test "fromPreferences succeeds for RGB text color and public list" {
|
test "fromPreferences succeeds for RGB text color and public list" {
|
||||||
let prefs = { ListPreferences.empty with HeadingColor = "#0000ff"; IsPublic = true }
|
let prefs = { ListPreferences.Empty with HeadingColor = "#0000ff"; IsPublic = true }
|
||||||
let edit = EditPreferences.fromPreferences prefs
|
let edit = EditPreferences.fromPreferences prefs
|
||||||
Expect.equal edit.HeadingColorType "RGB" "The heading text color type was not derived correctly"
|
Expect.equal edit.HeadingColorType "RGB" "The heading text color type was not derived correctly"
|
||||||
Expect.equal edit.HeadingColor prefs.HeadingColor "The heading text color was not filled correctly"
|
Expect.equal edit.HeadingColor prefs.HeadingColor "The heading text color was not filled correctly"
|
||||||
@ -307,7 +307,7 @@ let editPreferencesTests =
|
|||||||
"The list visibility was not derived correctly"
|
"The list visibility was not derived correctly"
|
||||||
}
|
}
|
||||||
test "fromPreferences succeeds for non-native fonts" {
|
test "fromPreferences succeeds for non-native fonts" {
|
||||||
let prefs = { ListPreferences.empty with Fonts = "Arial,sans-serif" }
|
let prefs = { ListPreferences.Empty with Fonts = "Arial,sans-serif" }
|
||||||
let edit = EditPreferences.fromPreferences prefs
|
let edit = EditPreferences.fromPreferences prefs
|
||||||
Expect.isFalse edit.IsNative "The IsNative flag should have been false"
|
Expect.isFalse edit.IsNative "The IsNative flag should have been false"
|
||||||
Expect.isSome edit.Fonts "The fonts should have been filled for non-native fonts"
|
Expect.isSome edit.Fonts "The fonts should have been filled for non-native fonts"
|
||||||
@ -330,7 +330,7 @@ let editRequestTests =
|
|||||||
}
|
}
|
||||||
test "fromRequest succeeds" {
|
test "fromRequest succeeds" {
|
||||||
let req =
|
let req =
|
||||||
{ PrayerRequest.empty with
|
{ PrayerRequest.Empty with
|
||||||
Id = (Guid.NewGuid >> PrayerRequestId) ()
|
Id = (Guid.NewGuid >> PrayerRequestId) ()
|
||||||
RequestType = CurrentRequest
|
RequestType = CurrentRequest
|
||||||
Requestor = Some "Me"
|
Requestor = Some "Me"
|
||||||
@ -358,7 +358,7 @@ let editSmallGroupTests =
|
|||||||
testList "EditSmallGroup" [
|
testList "EditSmallGroup" [
|
||||||
test "fromGroup succeeds" {
|
test "fromGroup succeeds" {
|
||||||
let grp =
|
let grp =
|
||||||
{ SmallGroup.empty with
|
{ SmallGroup.Empty with
|
||||||
Id = (Guid.NewGuid >> SmallGroupId) ()
|
Id = (Guid.NewGuid >> SmallGroupId) ()
|
||||||
Name = "test group"
|
Name = "test group"
|
||||||
ChurchId = (Guid.NewGuid >> ChurchId) ()
|
ChurchId = (Guid.NewGuid >> ChurchId) ()
|
||||||
@ -387,7 +387,7 @@ let editSmallGroupTests =
|
|||||||
Name = "test name"
|
Name = "test name"
|
||||||
ChurchId = (Guid.NewGuid >> shortGuid) ()
|
ChurchId = (Guid.NewGuid >> shortGuid) ()
|
||||||
}
|
}
|
||||||
let grp = edit.populateGroup SmallGroup.empty
|
let grp = edit.populateGroup SmallGroup.Empty
|
||||||
Expect.equal grp.Name edit.Name "The name was not populated correctly"
|
Expect.equal grp.Name edit.Name "The name was not populated correctly"
|
||||||
Expect.equal grp.ChurchId (idFromShort ChurchId edit.ChurchId) "The church ID was not populated correctly"
|
Expect.equal grp.ChurchId (idFromShort ChurchId edit.ChurchId) "The church ID was not populated correctly"
|
||||||
}
|
}
|
||||||
@ -408,7 +408,7 @@ let editUserTests =
|
|||||||
}
|
}
|
||||||
test "fromUser succeeds" {
|
test "fromUser succeeds" {
|
||||||
let usr =
|
let usr =
|
||||||
{ User.empty with
|
{ User.Empty with
|
||||||
Id = (Guid.NewGuid >> UserId) ()
|
Id = (Guid.NewGuid >> UserId) ()
|
||||||
FirstName = "user"
|
FirstName = "user"
|
||||||
LastName = "test"
|
LastName = "test"
|
||||||
@ -438,7 +438,7 @@ let editUserTests =
|
|||||||
Password = "testpw"
|
Password = "testpw"
|
||||||
}
|
}
|
||||||
let hasher = fun x -> x + "+"
|
let hasher = fun x -> x + "+"
|
||||||
let usr = edit.PopulateUser User.empty hasher
|
let usr = edit.PopulateUser User.Empty hasher
|
||||||
Expect.equal usr.FirstName edit.FirstName "The first name was not populated correctly"
|
Expect.equal usr.FirstName edit.FirstName "The first name was not populated correctly"
|
||||||
Expect.equal usr.LastName edit.LastName "The last name was not populated correctly"
|
Expect.equal usr.LastName edit.LastName "The last name was not populated correctly"
|
||||||
Expect.equal usr.Email edit.Email "The e-mail address was not populated correctly"
|
Expect.equal usr.Email edit.Email "The e-mail address was not populated correctly"
|
||||||
@ -500,26 +500,26 @@ let requestListTests =
|
|||||||
let withRequestList f () =
|
let withRequestList f () =
|
||||||
let today = SystemClock.Instance.GetCurrentInstant ()
|
let today = SystemClock.Instance.GetCurrentInstant ()
|
||||||
{ Requests = [
|
{ Requests = [
|
||||||
{ PrayerRequest.empty with
|
{ PrayerRequest.Empty with
|
||||||
RequestType = CurrentRequest
|
RequestType = CurrentRequest
|
||||||
Requestor = Some "Zeb"
|
Requestor = Some "Zeb"
|
||||||
Text = "zyx"
|
Text = "zyx"
|
||||||
UpdatedDate = today
|
UpdatedDate = today
|
||||||
}
|
}
|
||||||
{ PrayerRequest.empty with
|
{ PrayerRequest.Empty with
|
||||||
RequestType = CurrentRequest
|
RequestType = CurrentRequest
|
||||||
Requestor = Some "Aaron"
|
Requestor = Some "Aaron"
|
||||||
Text = "abc"
|
Text = "abc"
|
||||||
UpdatedDate = today - Duration.FromDays 9
|
UpdatedDate = today - Duration.FromDays 9
|
||||||
}
|
}
|
||||||
{ PrayerRequest.empty with
|
{ PrayerRequest.Empty with
|
||||||
RequestType = PraiseReport
|
RequestType = PraiseReport
|
||||||
Text = "nmo"
|
Text = "nmo"
|
||||||
UpdatedDate = today
|
UpdatedDate = today
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Date = today.InUtc().Date
|
Date = today.InUtc().Date
|
||||||
SmallGroup = SmallGroup.empty
|
SmallGroup = SmallGroup.Empty
|
||||||
ShowHeader = false
|
ShowHeader = false
|
||||||
Recipients = []
|
Recipients = []
|
||||||
CanEmail = false
|
CanEmail = false
|
||||||
@ -596,7 +596,7 @@ let requestListTests =
|
|||||||
}
|
}
|
||||||
let html = htmlList.AsHtml _s
|
let html = htmlList.AsHtml _s
|
||||||
let expected =
|
let expected =
|
||||||
htmlList.Requests[0].UpdatedDate.InZone(SmallGroup.timeZone reqList.SmallGroup).Date.ToString ("d", null)
|
htmlList.Requests[0].UpdatedDate.InZone(reqList.SmallGroup.TimeZone).Date.ToString ("d", null)
|
||||||
|> sprintf """<strong>Zeb</strong> – zyx<i style="font-size:9.60pt"> (as of %s)</i>"""
|
|> sprintf """<strong>Zeb</strong> – zyx<i style="font-size:9.60pt"> (as of %s)</i>"""
|
||||||
// spot check; if one request has it, they all should
|
// spot check; if one request has it, they all should
|
||||||
Expect.stringContains html expected "Expected short as-of date not found"
|
Expect.stringContains html expected "Expected short as-of date not found"
|
||||||
@ -611,7 +611,7 @@ let requestListTests =
|
|||||||
}
|
}
|
||||||
let html = htmlList.AsHtml _s
|
let html = htmlList.AsHtml _s
|
||||||
let expected =
|
let expected =
|
||||||
htmlList.Requests[0].UpdatedDate.InZone(SmallGroup.timeZone reqList.SmallGroup).Date.ToString ("D", null)
|
htmlList.Requests[0].UpdatedDate.InZone(reqList.SmallGroup.TimeZone).Date.ToString ("D", null)
|
||||||
|> sprintf """<strong>Zeb</strong> – zyx<i style="font-size:9.60pt"> (as of %s)</i>"""
|
|> sprintf """<strong>Zeb</strong> – zyx<i style="font-size:9.60pt"> (as of %s)</i>"""
|
||||||
// spot check; if one request has it, they all should
|
// spot check; if one request has it, they all should
|
||||||
Expect.stringContains html expected "Expected long as-of date not found"
|
Expect.stringContains html expected "Expected long as-of date not found"
|
||||||
@ -642,7 +642,7 @@ let requestListTests =
|
|||||||
}
|
}
|
||||||
let text = textList.AsText _s
|
let text = textList.AsText _s
|
||||||
let expected =
|
let expected =
|
||||||
textList.Requests[0].UpdatedDate.InZone(SmallGroup.timeZone reqList.SmallGroup).Date.ToString ("d", null)
|
textList.Requests[0].UpdatedDate.InZone(reqList.SmallGroup.TimeZone).Date.ToString ("d", null)
|
||||||
|> sprintf " + Zeb - zyx (as of %s)"
|
|> sprintf " + Zeb - zyx (as of %s)"
|
||||||
// spot check; if one request has it, they all should
|
// spot check; if one request has it, they all should
|
||||||
Expect.stringContains text expected "Expected short as-of date not found"
|
Expect.stringContains text expected "Expected short as-of date not found"
|
||||||
@ -657,7 +657,7 @@ let requestListTests =
|
|||||||
}
|
}
|
||||||
let text = textList.AsText _s
|
let text = textList.AsText _s
|
||||||
let expected =
|
let expected =
|
||||||
textList.Requests[0].UpdatedDate.InZone(SmallGroup.timeZone reqList.SmallGroup).Date.ToString ("D", null)
|
textList.Requests[0].UpdatedDate.InZone(reqList.SmallGroup.TimeZone).Date.ToString ("D", null)
|
||||||
|> sprintf " + Zeb - zyx (as of %s)"
|
|> sprintf " + Zeb - zyx (as of %s)"
|
||||||
// spot check; if one request has it, they all should
|
// spot check; if one request has it, they all should
|
||||||
Expect.stringContains text expected "Expected long as-of date not found"
|
Expect.stringContains text expected "Expected long as-of date not found"
|
||||||
|
@ -215,7 +215,7 @@ module TimeZones =
|
|||||||
match xref |> List.tryFind (fun it -> fst it = timeZoneId) with
|
match xref |> List.tryFind (fun it -> fst it = timeZoneId) with
|
||||||
| Some tz -> s[snd tz]
|
| Some tz -> s[snd tz]
|
||||||
| None ->
|
| None ->
|
||||||
let tzId = TimeZoneId.toString timeZoneId
|
let tzId = string timeZoneId
|
||||||
LocalizedString (tzId, tzId)
|
LocalizedString (tzId, tzId)
|
||||||
|
|
||||||
/// All known time zones in their defined order
|
/// All known time zones in their defined order
|
||||||
|
@ -156,7 +156,7 @@ let maintain (model : MaintainRequests) (ctx : HttpContext) viewInfo =
|
|||||||
use sw = new StringWriter ()
|
use sw = new StringWriter ()
|
||||||
let raw = rawLocText sw
|
let raw = rawLocText sw
|
||||||
let group = model.SmallGroup
|
let group = model.SmallGroup
|
||||||
let now = SmallGroup.localDateNow (ctx.GetService<IClock> ()) group
|
let now = group.LocalDateNow (ctx.GetService<IClock>())
|
||||||
let types = ReferenceList.requestTypeList s |> Map.ofList
|
let types = ReferenceList.requestTypeList s |> Map.ofList
|
||||||
let vi = AppViewInfo.withScopedStyles [ "#requestList { grid-template-columns: repeat(5, auto); }" ] viewInfo
|
let vi = AppViewInfo.withScopedStyles [ "#requestList { grid-template-columns: repeat(5, auto); }" ] viewInfo
|
||||||
/// Iterate the sequence once, before we render, so we can get the count of it at the top of the table
|
/// Iterate the sequence once, before we render, so we can get the count of it at the top of the table
|
||||||
@ -164,8 +164,8 @@ let maintain (model : MaintainRequests) (ctx : HttpContext) viewInfo =
|
|||||||
model.Requests
|
model.Requests
|
||||||
|> List.map (fun req ->
|
|> List.map (fun req ->
|
||||||
let updateClass =
|
let updateClass =
|
||||||
_class (if PrayerRequest.updateRequired now group req then "cell pt-request-update" else "cell")
|
_class (if req.UpdateRequired now group then "cell pt-request-update" else "cell")
|
||||||
let isExpired = PrayerRequest.isExpired now group req
|
let isExpired = req.IsExpired now group
|
||||||
let expiredClass = _class (if isExpired then "cell pt-request-expired" else "cell")
|
let expiredClass = _class (if isExpired then "cell pt-request-expired" else "cell")
|
||||||
let reqId = shortGuid req.Id.Value
|
let reqId = shortGuid req.Id.Value
|
||||||
let reqText = htmlToPlainText req.Text
|
let reqText = htmlToPlainText req.Text
|
||||||
|
@ -589,7 +589,7 @@ let preferences (model : EditPreferences) ctx viewInfo =
|
|||||||
"", selectDefault s["Select"].Value
|
"", selectDefault s["Select"].Value
|
||||||
yield!
|
yield!
|
||||||
TimeZones.all
|
TimeZones.all
|
||||||
|> List.map (fun tz -> TimeZoneId.toString tz, (TimeZones.name tz s).Value)
|
|> List.map (fun tz -> string tz, (TimeZones.name tz s).Value)
|
||||||
}
|
}
|
||||||
|> selectList (nameof model.TimeZone) model.TimeZone [ _required ]
|
|> selectList (nameof model.TimeZone) model.TimeZone [ _required ]
|
||||||
]
|
]
|
||||||
|
@ -448,7 +448,7 @@ module EditPreferences =
|
|||||||
Fonts = if prefs.Fonts = "native" then None else Some prefs.Fonts
|
Fonts = if prefs.Fonts = "native" then None else Some prefs.Fonts
|
||||||
HeadingFontSize = prefs.HeadingFontSize
|
HeadingFontSize = prefs.HeadingFontSize
|
||||||
ListFontSize = prefs.TextFontSize
|
ListFontSize = prefs.TextFontSize
|
||||||
TimeZone = TimeZoneId.toString prefs.TimeZoneId
|
TimeZone = string prefs.TimeZoneId
|
||||||
GroupPassword = Some prefs.GroupPassword
|
GroupPassword = Some prefs.GroupPassword
|
||||||
PageSize = prefs.PageSize
|
PageSize = prefs.PageSize
|
||||||
AsOfDate = string prefs.AsOfDateDisplay
|
AsOfDate = string prefs.AsOfDateDisplay
|
||||||
@ -670,7 +670,7 @@ module MaintainRequests =
|
|||||||
/// An empty instance
|
/// An empty instance
|
||||||
let empty =
|
let empty =
|
||||||
{ Requests = []
|
{ Requests = []
|
||||||
SmallGroup = SmallGroup.empty
|
SmallGroup = SmallGroup.Empty
|
||||||
OnlyActive = None
|
OnlyActive = None
|
||||||
SearchTerm = None
|
SearchTerm = None
|
||||||
PageNbr = None
|
PageNbr = None
|
||||||
@ -773,7 +773,7 @@ with
|
|||||||
|
|
||||||
/// Is this request new?
|
/// Is this request new?
|
||||||
member this.IsNew (req: PrayerRequest) =
|
member this.IsNew (req: PrayerRequest) =
|
||||||
let reqDate = req.UpdatedDate.InZone(SmallGroup.timeZone this.SmallGroup).Date
|
let reqDate = req.UpdatedDate.InZone(this.SmallGroup.TimeZone).Date
|
||||||
Period.Between(reqDate, this.Date, PeriodUnits.Days).Days <= this.SmallGroup.Preferences.DaysToKeepNew
|
Period.Between(reqDate, this.Date, PeriodUnits.Days).Days <= this.SmallGroup.Preferences.DaysToKeepNew
|
||||||
|
|
||||||
/// Generate this list as HTML
|
/// Generate this list as HTML
|
||||||
@ -803,7 +803,7 @@ with
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
let tz = SmallGroup.timeZone this.SmallGroup
|
let tz = this.SmallGroup.TimeZone
|
||||||
reqs
|
reqs
|
||||||
|> List.map (fun req ->
|
|> List.map (fun req ->
|
||||||
let bullet = if this.IsNew req then "circle" else "disc"
|
let bullet = if this.IsNew req then "circle" else "disc"
|
||||||
@ -835,7 +835,7 @@ with
|
|||||||
|
|
||||||
/// Generate this list as plain text
|
/// Generate this list as plain text
|
||||||
member this.AsText (s: IStringLocalizer) =
|
member this.AsText (s: IStringLocalizer) =
|
||||||
let tz = SmallGroup.timeZone this.SmallGroup
|
let tz = this.SmallGroup.TimeZone
|
||||||
seq {
|
seq {
|
||||||
this.SmallGroup.Name
|
this.SmallGroup.Name
|
||||||
s["Prayer Requests"].Value
|
s["Prayer Requests"].Value
|
||||||
|
@ -63,7 +63,7 @@ let save : HttpHandler = requireAccess [ Admin ] >=> validateCsrf >=> fun next c
|
|||||||
match! ctx.TryBindFormAsync<EditChurch> () with
|
match! ctx.TryBindFormAsync<EditChurch> () with
|
||||||
| Ok model ->
|
| Ok model ->
|
||||||
let! church =
|
let! church =
|
||||||
if model.IsNew then Task.FromResult(Some { Church.empty with Id = (Guid.NewGuid >> ChurchId) () })
|
if model.IsNew then Task.FromResult(Some { Church.Empty with Id = (Guid.NewGuid >> ChurchId) () })
|
||||||
else Churches.tryById (idFromShort ChurchId model.ChurchId)
|
else Churches.tryById (idFromShort ChurchId model.ChurchId)
|
||||||
match church with
|
match church with
|
||||||
| Some ch ->
|
| Some ch ->
|
||||||
|
@ -20,7 +20,7 @@ let private findRequest (ctx: HttpContext) reqId = task {
|
|||||||
/// Generate a list of requests for the given date
|
/// Generate a list of requests for the given date
|
||||||
let private generateRequestList (ctx: HttpContext) date = task {
|
let private generateRequestList (ctx: HttpContext) date = task {
|
||||||
let group = ctx.Session.CurrentGroup.Value
|
let group = ctx.Session.CurrentGroup.Value
|
||||||
let listDate = match date with Some d -> d | None -> SmallGroup.localDateNow ctx.Clock group
|
let listDate = defaultArg date (group.LocalDateNow ctx.Clock)
|
||||||
let! reqs =
|
let! reqs =
|
||||||
PrayerRequests.forGroup
|
PrayerRequests.forGroup
|
||||||
{ SmallGroup = group
|
{ SmallGroup = group
|
||||||
@ -50,7 +50,7 @@ open System
|
|||||||
// GET /prayer-request/[request-id]/edit
|
// GET /prayer-request/[request-id]/edit
|
||||||
let edit reqId : HttpHandler = requireAccess [ User ] >=> fun next ctx -> task {
|
let edit reqId : HttpHandler = requireAccess [ User ] >=> fun next ctx -> task {
|
||||||
let group = ctx.Session.CurrentGroup.Value
|
let group = ctx.Session.CurrentGroup.Value
|
||||||
let now = SmallGroup.localDateNow ctx.Clock group
|
let now = group.LocalDateNow ctx.Clock
|
||||||
let requestId = PrayerRequestId reqId
|
let requestId = PrayerRequestId reqId
|
||||||
if requestId.Value = Guid.Empty then
|
if requestId.Value = Guid.Empty then
|
||||||
return!
|
return!
|
||||||
@ -61,7 +61,7 @@ let edit reqId : HttpHandler = requireAccess [ User ] >=> fun next ctx -> task {
|
|||||||
match! findRequest ctx requestId with
|
match! findRequest ctx requestId with
|
||||||
| Ok req ->
|
| Ok req ->
|
||||||
let s = ctx.Strings
|
let s = ctx.Strings
|
||||||
if PrayerRequest.isExpired now group req then
|
if req.IsExpired now group then
|
||||||
{ UserMessage.warning with
|
{ UserMessage.warning with
|
||||||
Text = htmlLocString s["This request is expired."]
|
Text = htmlLocString s["This request is expired."]
|
||||||
Description =
|
Description =
|
||||||
@ -139,7 +139,7 @@ let list groupId : HttpHandler = requireAccess [ AccessLevel.Public ] >=> fun ne
|
|||||||
viewInfo ctx
|
viewInfo ctx
|
||||||
|> Views.PrayerRequest.list
|
|> Views.PrayerRequest.list
|
||||||
{ Requests = reqs
|
{ Requests = reqs
|
||||||
Date = SmallGroup.localDateNow ctx.Clock group
|
Date = group.LocalDateNow ctx.Clock
|
||||||
SmallGroup = group
|
SmallGroup = group
|
||||||
ShowHeader = true
|
ShowHeader = true
|
||||||
CanEmail = Option.isSome ctx.User.UserId
|
CanEmail = Option.isSome ctx.User.UserId
|
||||||
@ -226,7 +226,7 @@ let save : HttpHandler = requireAccess [ User ] >=> validateCsrf >=> fun next ct
|
|||||||
let group = ctx.Session.CurrentGroup.Value
|
let group = ctx.Session.CurrentGroup.Value
|
||||||
let! req =
|
let! req =
|
||||||
if model.IsNew then
|
if model.IsNew then
|
||||||
{ PrayerRequest.empty with
|
{ PrayerRequest.Empty with
|
||||||
Id = (Guid.NewGuid >> PrayerRequestId) ()
|
Id = (Guid.NewGuid >> PrayerRequestId) ()
|
||||||
SmallGroupId = group.Id
|
SmallGroupId = group.Id
|
||||||
UserId = ctx.User.UserId.Value
|
UserId = ctx.User.UserId.Value
|
||||||
@ -235,7 +235,7 @@ let save : HttpHandler = requireAccess [ User ] >=> validateCsrf >=> fun next ct
|
|||||||
else PrayerRequests.tryById (idFromShort PrayerRequestId model.RequestId)
|
else PrayerRequests.tryById (idFromShort PrayerRequestId model.RequestId)
|
||||||
match req with
|
match req with
|
||||||
| Some pr when pr.SmallGroupId = group.Id ->
|
| Some pr when pr.SmallGroupId = group.Id ->
|
||||||
let now = SmallGroup.localDateNow ctx.Clock group
|
let now = group.LocalDateNow ctx.Clock
|
||||||
let updated =
|
let updated =
|
||||||
{ pr with
|
{ pr with
|
||||||
RequestType = PrayerRequestType.Parse model.RequestType
|
RequestType = PrayerRequestType.Parse model.RequestType
|
||||||
@ -247,7 +247,7 @@ let save : HttpHandler = requireAccess [ User ] >=> validateCsrf >=> fun next ct
|
|||||||
| it when model.IsNew ->
|
| it when model.IsNew ->
|
||||||
let dt =
|
let dt =
|
||||||
(defaultArg (parseListDate model.EnteredDate) now)
|
(defaultArg (parseListDate model.EnteredDate) now)
|
||||||
.AtStartOfDayInZone(SmallGroup.timeZone group)
|
.AtStartOfDayInZone(group.TimeZone)
|
||||||
.ToInstant()
|
.ToInstant()
|
||||||
{ it with EnteredDate = dt; UpdatedDate = dt }
|
{ it with EnteredDate = dt; UpdatedDate = dt }
|
||||||
| it when defaultArg model.SkipDateUpdate false -> it
|
| it when defaultArg model.SkipDateUpdate false -> it
|
||||||
|
@ -183,7 +183,7 @@ let save : HttpHandler = requireAccess [ Admin ] >=> validateCsrf >=> fun next c
|
|||||||
match! ctx.TryBindFormAsync<EditSmallGroup>() with
|
match! ctx.TryBindFormAsync<EditSmallGroup>() with
|
||||||
| Ok model ->
|
| Ok model ->
|
||||||
let! tryGroup =
|
let! tryGroup =
|
||||||
if model.IsNew then Task.FromResult(Some { SmallGroup.empty with Id = (Guid.NewGuid >> SmallGroupId) () })
|
if model.IsNew then Task.FromResult(Some { SmallGroup.Empty with Id = (Guid.NewGuid >> SmallGroupId) () })
|
||||||
else SmallGroups.tryById (idFromShort SmallGroupId model.SmallGroupId)
|
else SmallGroups.tryById (idFromShort SmallGroupId model.SmallGroupId)
|
||||||
match tryGroup with
|
match tryGroup with
|
||||||
| Some group ->
|
| Some group ->
|
||||||
@ -202,7 +202,7 @@ let saveMember : HttpHandler = requireAccess [ User ] >=> validateCsrf >=> fun n
|
|||||||
let group = ctx.Session.CurrentGroup.Value
|
let group = ctx.Session.CurrentGroup.Value
|
||||||
let! tryMbr =
|
let! tryMbr =
|
||||||
if model.IsNew then
|
if model.IsNew then
|
||||||
Task.FromResult(Some { Member.empty with Id = (Guid.NewGuid >> MemberId) (); SmallGroupId = group.Id })
|
Task.FromResult(Some { Member.Empty with Id = (Guid.NewGuid >> MemberId) (); SmallGroupId = group.Id })
|
||||||
else Members.tryById (idFromShort MemberId model.MemberId)
|
else Members.tryById (idFromShort MemberId model.MemberId)
|
||||||
match tryMbr with
|
match tryMbr with
|
||||||
| Some mbr when mbr.SmallGroupId = group.Id ->
|
| Some mbr when mbr.SmallGroupId = group.Id ->
|
||||||
@ -250,7 +250,7 @@ let sendAnnouncement : HttpHandler = requireAccess [ User ] >=> validateCsrf >=>
|
|||||||
let group = ctx.Session.CurrentGroup.Value
|
let group = ctx.Session.CurrentGroup.Value
|
||||||
let pref = group.Preferences
|
let pref = group.Preferences
|
||||||
let usr = ctx.Session.CurrentUser.Value
|
let usr = ctx.Session.CurrentUser.Value
|
||||||
let now = SmallGroup.localTimeNow ctx.Clock group
|
let now = group.LocalTimeNow ctx.Clock
|
||||||
let s = ctx.Strings
|
let s = ctx.Strings
|
||||||
// Reformat the text to use the class's font stylings
|
// Reformat the text to use the class's font stylings
|
||||||
let requestText = ckEditorToText model.Text
|
let requestText = ckEditorToText model.Text
|
||||||
@ -262,7 +262,7 @@ let sendAnnouncement : HttpHandler = requireAccess [ User ] >=> validateCsrf >=>
|
|||||||
let! recipients = task {
|
let! recipients = task {
|
||||||
if model.SendToClass = "N" && usr.IsAdmin then
|
if model.SendToClass = "N" && usr.IsAdmin then
|
||||||
let! users = Users.all ()
|
let! users = Users.all ()
|
||||||
return users |> List.map (fun u -> { Member.empty with Name = u.Name; Email = u.Email })
|
return users |> List.map (fun u -> { Member.Empty with Name = u.Name; Email = u.Email })
|
||||||
else return! Members.forGroup group.Id
|
else return! Members.forGroup group.Id
|
||||||
}
|
}
|
||||||
use! client = Email.getConnection ()
|
use! client = Email.getConnection ()
|
||||||
@ -282,9 +282,9 @@ let sendAnnouncement : HttpHandler = requireAccess [ User ] >=> validateCsrf >=>
|
|||||||
| _, None -> ()
|
| _, None -> ()
|
||||||
| _, Some x when not x -> ()
|
| _, Some x when not x -> ()
|
||||||
| _, _ ->
|
| _, _ ->
|
||||||
let zone = SmallGroup.timeZone group
|
let zone = group.TimeZone
|
||||||
do! PrayerRequests.save
|
do! PrayerRequests.save
|
||||||
{ PrayerRequest.empty with
|
{ PrayerRequest.Empty with
|
||||||
Id = (Guid.NewGuid >> PrayerRequestId) ()
|
Id = (Guid.NewGuid >> PrayerRequestId) ()
|
||||||
SmallGroupId = group.Id
|
SmallGroupId = group.Id
|
||||||
UserId = usr.Id
|
UserId = usr.Id
|
||||||
|
@ -218,7 +218,7 @@ let save : HttpHandler = requireAccess [ Admin ] >=> validateCsrf >=> fun next c
|
|||||||
match! ctx.TryBindFormAsync<EditUser>() with
|
match! ctx.TryBindFormAsync<EditUser>() with
|
||||||
| Ok model ->
|
| Ok model ->
|
||||||
let! user =
|
let! user =
|
||||||
if model.IsNew then Task.FromResult(Some { User.empty with Id = (Guid.NewGuid >> UserId) () })
|
if model.IsNew then Task.FromResult(Some { User.Empty with Id = (Guid.NewGuid >> UserId) () })
|
||||||
else Users.tryById (idFromShort UserId model.UserId)
|
else Users.tryById (idFromShort UserId model.UserId)
|
||||||
match user with
|
match user with
|
||||||
| Some usr ->
|
| Some usr ->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user