Skip to content

Commit

Permalink
Update Door "pending" status on payment
Browse files Browse the repository at this point in the history
Also adds Door entry if missing (removed during Covid lockdowns)

Fixes #43
  • Loading branch information
castaway committed Mar 14, 2024
1 parent 1aa62b9 commit 30a6930
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/AccessSystem/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ our $VERSION = '15.0';

__PACKAGE__->load_namespaces();

sub the_door {
my ($self) = @_;

return $self->resultset('Tool')->find({ name => 'The Door'});
}

1;
13 changes: 13 additions & 0 deletions lib/AccessSystem/Schema/Result/Person.pm
Original file line number Diff line number Diff line change
Expand Up @@ -533,11 +533,13 @@ sub create_payment {
return;
}
if (!$valid_date) {
$self->update_door_access();
$self->create_communication('Your Swindon Makerspace membership has started', 'first_payment');
}

if($valid_date && $valid_date < $now) {
# renewed payments
$self->update_door_access();
$self->create_communication('Your Swindon Makerspace membership has restarted', 'rejoin_payment');
}
# Only add $OVERLAP extra days if a first or renewal payment - these
Expand Down Expand Up @@ -719,4 +721,15 @@ sub door_colour_to_code {
return undef;
}

sub update_door_access {
my ($self) = @_;

# This entry should exist, but covid policy may have removed it..
my $door = $self->result_source->schema->the_door();
my $door_allowed = $self->allowed->find_or_create({ tool_id => $door->id });
if($door_allowed->pending_acceptance eq 'true') {
$door_allowed->update({ pending_acceptance => 'false', accepted_on => DateTime->now()});
}
}

1;

0 comments on commit 30a6930

Please sign in to comment.