Skip to content

Commit

Permalink
Merge pull request #7313 from inverse-inc/fix/6385
Browse files Browse the repository at this point in the history
fix/6385
  • Loading branch information
JeGoi committed Oct 28, 2022
2 parents 41c40ef + f0a361a commit 10ef626
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 4 deletions.
1 change: 1 addition & 0 deletions db/pf-schema-X.Y.sql
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ CREATE TABLE person (
`psk` varchar(255) NULL DEFAULT NULL,
`potd` enum('no','yes') NOT NULL DEFAULT 'no',
`otp` MEDIUMTEXT NULL DEFAULT NULL,
`sponsored_date` DATETIME DEFAULT NULL,
PRIMARY KEY (`pid`)
) ENGINE=InnoDB DEFAULT CHARACTER SET = 'utf8mb4';

Expand Down
4 changes: 4 additions & 0 deletions db/upgrade-X.X-X.Y.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ call ValidateVersion;

DROP PROCEDURE IF EXISTS ValidateVersion;

\! echo "Updating the person table"
ALTER TABLE person
ADD COLUMN IF NOT EXISTS sponsored_date DATETIME DEFAULT NULL;

--
-- UPGRADE STATEMENTS GO HERE
--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ sub do_sponsor_registration {
return unless($self->_validate_sponsor($sponsor));

# form valid, adding person (using modify in case person already exists)
my $note = 'sponsored confirmation Date of arrival: ' . time2str("%Y-%m-%d %H:%M:%S", time);
$logger->info( "Adding guest person $pid" );
my $sponsored_date = time2str("%Y-%m-%d %H:%M:%S", time);
$logger->info( "Adding guest person $pid Date of arrival: $sponsored_date");

$info{'bcc'} = $source->{sponsorship_bcc};
$info{'activation_domain'} = $source->{activation_domain} if (defined($source->{activation_domain}));
Expand Down Expand Up @@ -250,10 +250,10 @@ sub do_sponsor_registration {

# update sponsor field with forced_sponsor value
if (!defined($self->request_fields->{sponsor})) {
$self->update_person_from_fields(additionnal_fields => {notes => $note, sponsor => $sponsor});
$self->update_person_from_fields(additionnal_fields => {sponsored_date => $sponsored_date, sponsor => $sponsor});
}
else {
$self->update_person_from_fields(additionnal_fields => {notes => $note});
$self->update_person_from_fields(additionnal_fields => {sponsored_date => $sponsored_date});
}

$self->waiting_room();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<form-group-sponsor namespace="sponsor"
:column-label="$t('Sponsor')" />

<form-group-sponsored-date namespace="sponsored_date"
:column-label="$t('Sponsored Date')"
readonly
/>

<form-group-language namespace="lang"
:column-label="$t('Language')" />

Expand Down Expand Up @@ -300,6 +305,7 @@ import {
FormGroupLoginRemaining,
FormGroupEmail,
FormGroupSponsor,
FormGroupSponsoredDate,
FormGroupLanguage,
FormGroupGender,
FormGroupTitle,
Expand Down Expand Up @@ -344,6 +350,7 @@ const components = {
FormGroupPid,
FormGroupEmail,
FormGroupSponsor,
FormGroupSponsoredDate,
FormGroupLanguage,
FormGroupGender,
FormGroupTitle,
Expand Down
1 change: 1 addition & 0 deletions html/pfappserver/root/src/views/Users/_components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export {
BaseFormGroupTextarea as FormGroupAddress,
BaseFormGroupInputDateTime as FormGroupAnniversary,
BaseFormGroupInputDateTime as FormGroupBirthday,
BaseFormGroupInputDateTime as FormGroupSponsoredDate,
BaseFormGroupInput as FormGroupPsk,
BaseFormGroupTextarea as FormGroupNotes,
BaseFormGroupInput as FormGroupCustomField1,
Expand Down
8 changes: 8 additions & 0 deletions html/pfappserver/root/src/views/Users/_config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const createSingleForm = {
pid: '',
email: '',
sponsor: '',
sponsored_date: null,
password: '',
login_remaining: null,
gender: '',
Expand Down Expand Up @@ -153,6 +154,13 @@ export const importFields = [
required: false,
validator: validatorFromColumnSchemas(MysqlDatabase.person.sponsor)
},
{
value: 'sponsored_date',
text: i18n.t('Sponsored Date'),
types: [fieldType.DATE],
required: false,
validator: validatorFromColumnSchemas(MysqlDatabase.person.sponsored_date)
},
{
value: 'anniversary',
text: i18n.t('Anniversary'),
Expand Down
11 changes: 11 additions & 0 deletions html/pfappserver/root/src/views/Users/_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ export const useSearch = makeSearch('users', {
searchable: false,
sortable: true
},
{
key: 'sponsored_date',
label: 'Sponsored Date', // i18n defer
searchable: false,
sortable: true
},
{
key: 'anniversary',
label: 'Anniversary', // i18n defer
Expand Down Expand Up @@ -256,6 +262,11 @@ export const useSearch = makeSearch('users', {
text: 'Sponsor', // i18n defer
types: [conditionType.SUBSTRING]
},
{
value: 'sponsored_date',
text: 'Sponsored Date', // i18n defer
types: [conditionType.SUBSTRING]
},
{
value: 'anniversary',
text: 'Anniversary', // i18n defer
Expand Down
10 changes: 10 additions & 0 deletions lib/pf/dal/_person.pm
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ BEGIN {
psk
potd
otp
sponsored_date
);

%DEFAULTS = (
Expand Down Expand Up @@ -104,6 +105,7 @@ BEGIN {
psk => undef,
potd => 'no',
otp => undef,
sponsored_date => undef,
);

@INSERTABLE_FIELDS = qw(
Expand Down Expand Up @@ -141,6 +143,7 @@ BEGIN {
psk
potd
otp
sponsored_date
);

%FIELDS_META = (
Expand Down Expand Up @@ -352,6 +355,12 @@ BEGIN {
is_primary_key => 0,
is_nullable => 1,
},
sponsored_date => {
type => 'DATETIME',
is_auto_increment => 0,
is_primary_key => 0,
is_nullable => 1,
},
);

@PRIMARY_KEYS = qw(
Expand Down Expand Up @@ -393,6 +402,7 @@ BEGIN {
person.psk
person.potd
person.otp
person.sponsored_date
);

}
Expand Down

0 comments on commit 10ef626

Please sign in to comment.