-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
257 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"""Hide deleted user's identifiers | ||
Revision ID: ebb5fee8122b | ||
Revises: 406484da81af | ||
Create Date: 2021-05-04 12:50:49.638956 | ||
""" | ||
from alembic import op | ||
import re | ||
from sqlalchemy.sql import text | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'ebb5fee8122b' | ||
down_revision = '406484da81af' | ||
|
||
|
||
def upgrade(): | ||
""" Hide unique system identifiers tied to deleted users. | ||
To prevent conflicts, should a second user desire to use an identifier | ||
previously "owned" by a now deleted user, hide the deleted user's | ||
identifier with a suffix. | ||
""" | ||
conn = op.get_bind() | ||
|
||
patients = conn.execute( | ||
"SELECT user_id FROM user_identifiers JOIN users ON users.id = user_id " | ||
"WHERE deleted_id IS NOT NULL").fetchall() | ||
|
||
fixes = [] | ||
for user_id in patients: | ||
ident_id, value = conn.execute(text( | ||
"SELECT identifiers.id, value FROM identifiers JOIN " | ||
"user_identifiers ON identifiers.id = identifier_id WHERE " | ||
"user_id=:user_id"), user_id=user_id[0]).fetchone() | ||
# Only concerned with IDs that match the MR format (nnn-nn-nnn) | ||
match = re.search(r'\d+-\d+-\d+$', value) | ||
if not match: | ||
continue | ||
deleted_value = f"{value}-deleted" | ||
print(f"change {ident_id} {value} to {deleted_value}") | ||
fixes.append((ident_id, deleted_value)) | ||
|
||
for ident_id, new_value in fixes: | ||
conn.execute(text( | ||
"UPDATE identifiers SET value=:value WHERE id=:id"), | ||
value=new_value, | ||
id=ident_id) | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
pass | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
$(document).ready(function() { | ||
var submitForm = function() { | ||
if (!$("#faInput").val()) return; | ||
$(".buttons-container").addClass("loading"); | ||
setTimeout(function() { | ||
$("#TwoFAForm").submit(); | ||
}, 50); | ||
}; | ||
$("#submitValidationCode").on("click", function(e) { | ||
e.stopPropagation(); | ||
submitForm(); | ||
}); | ||
$(document).keypress(function(event) { | ||
if (event.which === 13) { | ||
submitForm(); | ||
return false; | ||
} | ||
return true; | ||
}); | ||
}); |
Oops, something went wrong.