Skip to content

Commit

Permalink
[users] Add 'request account date' to users (aces#6191)
Browse files Browse the repository at this point in the history
This adds a new account_request_date field to the users table to register information about when a given user requested an account.
  • Loading branch information
cmadjar authored and AlexandraLivadas committed Jun 15, 2021
1 parent 9caf804 commit f514f4e
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ changes in the following format: PR #1234***
#### Updates and Improvements
- Module-specific permissions added for Survey Accounts, Imaging Behavioural
Quality Control, and Behavioural Quality Control. (PR #6041)
- Addition of a new `account_request_date` in `users` table that will be used when
requesting a new account and will be displayed in the User Accounts module (PR #6191)
#### Bug Fixes
- *Add item here*
### Modules
Expand Down
1 change: 1 addition & 0 deletions SQL/0000-00-00-schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ CREATE TABLE `users` (
`language_preference` integer unsigned default NULL,
`active_from` date default NULL,
`active_to` date default NULL,
`account_request_date` date default NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `Email` (`Email`),
UNIQUE KEY `UserID` (`UserID`),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- add a new column to the users table to store the date at which
-- the user requested an account
ALTER TABLE users
ADD COLUMN account_request_date DATE DEFAULT NULL;

-- determine the account_request_date based on what is present in the history
-- table for when the user was inserted the first time in the history table
UPDATE users u, history h
SET u.account_request_date=h.changeDate
WHERE
h.tbl='users' AND
h.col='UserID' AND
h.old IS NULL AND
u.UserID=h.new;
13 changes: 7 additions & 6 deletions modules/login/php/requestaccount.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,13 @@ class RequestAccount extends \NDB_Form
$fullname = $name." ".$lastname;

$vals = [
'UserID' => $from,
'Real_name' => $fullname,
'First_name' => $name,
'Last_name' => $lastname,
'Pending_approval' => 'Y',
'Email' => $from,
'UserID' => $from,
'Real_name' => $fullname,
'First_name' => $name,
'Last_name' => $lastname,
'Pending_approval' => 'Y',
'Email' => $from,
'account_request_date' => date('Y-m-d'),
];

// check email address' uniqueness
Expand Down
5 changes: 5 additions & 0 deletions modules/user_accounts/jsx/userAccountsIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ class UserAccountsIndex extends Component {
type: 'select',
options: options.pendingApprovals,
}},
{label: 'Account Request Date', show: true, filter: {
name: 'accountRequestDate',
type: 'date',
hide: true,
}},
];
const actions = [
{label: 'Add User', action: this.addUser},
Expand Down
3 changes: 2 additions & 1 deletion modules/user_accounts/php/edit_user.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,9 @@ class Edit_User extends \NDB_Form

} else {
// It is an existing user:
// display user name
// display user name and account request date
$this->addScoreColumn('UserID', 'User name');
$this->addScoreColumn('account_request_date', 'Account Request Date');
}

// password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class UserAccountRowProvisioner extends \LORIS\Data\Provisioners\DBRowProvisione
u.Real_name as real_name,
u.Email as email,
u.Active as active,
u.Pending_approval as pending
u.Pending_approval as pending,
u.account_request_date as account_request_date
FROM users u
LEFT JOIN user_psc_rel upsr ON (upsr.UserID=u.ID)
LEFT JOIN user_project_rel uprr ON (uprr.UserID=u.ID)
Expand Down
9 changes: 9 additions & 0 deletions modules/user_accounts/templates/form_edit_user.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,15 @@
</div>
</div>

<div class="row form-group form-inline">
<label class="col-sm-12 col-sm-2 form-label">
{$form.account_request_date.label}
</label>
<div class="col-sm-10">
{$form.account_request_date.html|default:'None'}
</div>
</div>

<div class="row form-group form-inline">
<label class="col-sm-2">
{$form.Pending_approval.label}
Expand Down
3 changes: 2 additions & 1 deletion test/unittests/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class UserTest extends TestCase
'Doc_Repo_Notifications' => 'Y',
'language_preference' => 2,
'active_from' => '2017-07-16',
'active_to' => '2020-07-16'
'active_to' => '2020-07-16',
'account_request_date' => null
);
/**
* The userInfo table that should result from calling the factory function
Expand Down

0 comments on commit f514f4e

Please sign in to comment.