Skip to content

Commit 8ccb2be

Browse files
Merge pull request #532 from biocore/master-overhaul
Merge Master-overhaul into Master
2 parents bf07af1 + 4498566 commit 8ccb2be

File tree

86 files changed

+17720
-1261
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+17720
-1261
lines changed

ci/conda_requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ psycopg2
33
flask
44
natsort
55
pycryptodome
6-
pandas
6+
pandas < 2.0.0

microsetta_private_api/LEGACY/locale_data/english_gut.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,9 @@
567567
'TEXT_I_HAVE_READ_SIMPLIFIED': 'Yes, you will be in this research study.',
568568
'PERSON_ATTAINING_ASSENT': 'Signature Of Person Obtaining Assent',
569569
'TEXT_ASSENT_WITNESS': 'In my judgment, the participant is voluntarily and knowingly giving assent and possesses the legal capacity to give assent to participate in the study.',
570-
'OBTAINER_NAME': 'Name of person obtaining assent',
570+
'ASSENT_OBTAINER': 'Name of person obtaining assent',
571571
'TEXT_I_HAVE_READ_PARENT': 'I have read (or someone has read to me) this form. I am aware that I am being asked to provide consent for my child to be in a research study. I voluntarily agree to allow my child to participate in this study. I understand how my child’s personal data will be processed, my related rights, and that I consent to the processing of my child’s sample and data as provided in this document.',
572572
'PARTICIPANT_NAME': 'Participant name',
573-
'PARTICIPANT_EMAIL': 'Participant email',
574573
'PARTICIPANT_PARENT_1': 'Parent/Guardian name',
575574
'PARTICIPANT_PARENT_2': 'Parent/Guardian name of second parent',
576575
'PARTICIPANT_DECEASED_PARENTS': 'One parent/guardian is deceased or unable to consent',

microsetta_private_api/LEGACY/locale_data/spain_spanish_gut.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
'TEXT_I_HAVE_READ_SIMPLIFIED': 'Sí, estarás en este estudio de investigación.',
6868
'PERSON_ATTAINING_ASSENT': 'Firma de la persona que obtiene el consentimiento',
6969
'TEXT_ASSENT_WITNESS': 'A mi juicio, el participante está dando su consentimiento voluntaria y conscientemente y posee la capacidad legal de dar su consentimiento para participar en el estudio.',
70-
'OBTAINER_NAME': 'Nombre de la persona que obtiene el consentimiento',
70+
'ASSENT_OBTAINER': 'Nombre de la persona que obtiene el consentimiento',
7171
'TEXT_I_HAVE_READ_PARENT': 'He leído (o alguien me ha leído) este formulario. Soy consciente de que se le está pidiendo a mi hijo que participe en un estudio de investigación. Acepto voluntariamente que mi hijo participe en este estudio',
7272
'PARTICIPANT_NAME': 'Nombre del participante',
7373
'PARTICIPANT_EMAIL': 'Correo electrónico del participante',

microsetta_private_api/LEGACY/locale_data/spanish_gut.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,9 @@
6767
'TEXT_I_HAVE_READ_SIMPLIFIED': 'Sí, estarás en este estudio de investigación.',
6868
'PERSON_ATTAINING_ASSENT': 'Firma de la persona que obtiene el consentimiento',
6969
'TEXT_ASSENT_WITNESS': 'A mi juicio, el participante está dando su consentimiento voluntaria y conscientemente y posee la capacidad legal de dar su consentimiento para participar en el estudio.',
70-
'OBTAINER_NAME': 'Nombre de la persona que obtiene el consentimiento',
70+
'ASSENT_OBTAINER': 'Nombre de la persona que obtiene el consentimiento',
7171
'TEXT_I_HAVE_READ_PARENT': 'He leído (o alguien me ha leído) este formulario. Soy consciente de que se le está pidiendo a mi hijo que participe en un estudio de investigación. Acepto voluntariamente que mi hijo participe en este estudio',
7272
'PARTICIPANT_NAME': 'Nombre del participante',
73-
'PARTICIPANT_EMAIL': 'Correo electrónico del participante',
7473
'PARTICIPANT_PARENT_1': 'Nombre del Padre de Familia / Guardian',
7574
'PARTICIPANT_PARENT_2': 'Nombre del padre / tutor del segundo padre',
7675
'PARTICIPANT_DECEASED_PARENTS': 'Uno de los padres / tutor ha fallecido o no puede dar su consentimiento',

microsetta_private_api/admin/admin_impl.py

+82-35
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from werkzeug.exceptions import Unauthorized
3636
from microsetta_private_api.qiita import qclient
3737
from microsetta_private_api.repo.interested_user_repo import InterestedUserRepo
38+
from microsetta_private_api.repo.removal_queue_repo import RemovalQueueRepo
3839

3940

4041
def search_barcode(token_info, sample_barcode):
@@ -542,6 +543,21 @@ def create_daklapack_orders(body, token_info):
542543
return response
543544

544545

546+
# We need an internal wrapper to create orders based on contributions coming
547+
# from Fundrazr without authenticating an admin user.
548+
# Do NOT expose an API endpoint for this.
549+
def create_daklapack_order_internal(order_dict):
550+
# Since we've established the consent dummy as a stable account across
551+
# dev, staging, and production, we'll continue to use that internally
552+
with Transaction() as t:
553+
account_repo = AccountRepo(t)
554+
order_dict[SUBMITTER_ACCT_KEY] = account_repo.get_account(
555+
SERVER_CONFIG['fulfillment_account_id'])
556+
557+
result = _create_daklapack_order(order_dict)
558+
return result
559+
560+
545561
def _create_daklapack_order(order_dict):
546562
order_dict[ORDER_ID_KEY] = str(uuid.uuid4())
547563

@@ -614,6 +630,15 @@ def list_campaigns(token_info):
614630
return jsonify(campaigns), 200
615631

616632

633+
def list_removal_queue(token_info):
634+
validate_admin_access(token_info)
635+
636+
with Transaction() as t:
637+
repo = RemovalQueueRepo(t)
638+
requests = repo.get_all_account_removal_requests()
639+
return jsonify(requests), 200
640+
641+
617642
def post_campaign_information(body, token_info):
618643
validate_admin_access(token_info)
619644

@@ -656,6 +681,20 @@ def generate_activation_codes(body, token_info):
656681
return jsonify(results), 200
657682

658683

684+
def generate_ffq_codes(body, token_info):
685+
validate_admin_access(token_info)
686+
687+
quantity = body.get("code_quantity", 1)
688+
with Transaction() as t:
689+
admin_repo = AdminRepo(t)
690+
code_list = []
691+
for i in range(quantity):
692+
code_list.append(admin_repo.create_ffq_code())
693+
t.commit()
694+
695+
return jsonify(code_list), 200
696+
697+
659698
def list_barcode_query_fields(token_info):
660699
validate_admin_access(token_info)
661700

@@ -796,7 +835,6 @@ def delete_account(account_id, token_info):
796835
src_repo = SourceRepo(t)
797836
samp_repo = SampleRepo(t)
798837
sar_repo = SurveyAnswersRepo(t)
799-
template_repo = SurveyTemplateRepo(t)
800838

801839
acct = acct_repo.get_account(account_id)
802840
if acct is None:
@@ -806,8 +844,6 @@ def delete_account(account_id, token_info):
806844
if acct.account_type == 'deleted':
807845
return None, 204
808846

809-
sample_count = 0
810-
account_has_external = False
811847
sources = src_repo.get_sources_in_account(
812848
account_id,
813849
allow_revoked=True
@@ -820,50 +856,61 @@ def delete_account(account_id, token_info):
820856
allow_revoked=True
821857
)
822858

823-
has_samples = len(samples) > 0
824-
sample_count += len(samples)
825-
has_external = template_repo.has_external_surveys(account_id,
826-
source.id)
827-
828-
if has_external:
829-
account_has_external = True
830-
831859
for sample in samples:
832860
# we scrub rather than disassociate in the event that the
833861
# sample is in our freezers but not with an up-to-date scan
834862
samp_repo.scrub(account_id, source.id, sample.id)
835863

836864
surveys = sar_repo.list_answered_surveys(account_id, source.id)
837-
if has_samples or has_external:
838-
# if we have samples or external surveys, we need to scrub
839-
# survey / source free text
840-
for survey_id in surveys:
841-
sar_repo.scrub(account_id, source.id, survey_id)
842-
843-
# We're including scrubbed sources to detect external surveys
844-
# so we need to make sure the source isn't already scrubbed
845-
if source.source_data.date_revoked is None:
846-
src_repo.scrub(account_id, source.id)
847-
848-
if not has_samples and not has_external:
849-
# if we do not have associated samples, or external surveys,
850-
# then the source is safe to delete
851-
for survey_id in surveys:
852-
sar_repo.delete_answered_survey(account_id, survey_id)
853-
src_repo.delete_source(account_id, source.id)
854-
855-
# an account is safe to delete if there are no associated samples
856-
# and does not have external surveys
857-
if sample_count > 0 or account_has_external:
858-
acct_repo.scrub(account_id)
859-
else:
860-
acct_repo.delete_account(account_id)
865+
for survey_id in surveys:
866+
sar_repo.scrub(account_id, source.id, survey_id)
867+
868+
# We're including scrubbed sources to detect external surveys
869+
# so we need to make sure the source isn't already scrubbed
870+
if source.source_data.date_revoked is None:
871+
src_repo.scrub(account_id, source.id)
872+
873+
acct_repo.scrub(account_id)
861874

862875
t.commit()
863876

864877
return None, 204
865878

866879

880+
def ignore_removal_request(account_id, token_info):
881+
validate_admin_access(token_info)
882+
883+
with Transaction() as t:
884+
rq_repo = RemovalQueueRepo(t)
885+
try:
886+
# remove the user from the queue, noting the admin who allowed it
887+
# and the time the action was performed.
888+
rq_repo.update_queue(account_id, token_info['email'], 'ignored')
889+
t.commit()
890+
except RepoException as e:
891+
raise e
892+
893+
return None, 204
894+
895+
896+
def allow_removal_request(account_id, token_info):
897+
validate_admin_access(token_info)
898+
899+
with Transaction() as t:
900+
rq_repo = RemovalQueueRepo(t)
901+
902+
try:
903+
# remove the user from the queue, noting the admin who allowed it
904+
# and the time the action was performed.
905+
rq_repo.update_queue(account_id, token_info['email'], 'deleted')
906+
t.commit()
907+
except RepoException as e:
908+
raise e
909+
910+
# delete the user
911+
return delete_account(account_id, token_info)
912+
913+
867914
def get_vioscreen_sample_to_user(token_info):
868915
validate_admin_access(token_info)
869916
with Transaction() as t:

microsetta_private_api/admin/email_templates.py

+32
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,38 @@ class EmailMessage(Enum):
7979
EventType.EMAIL,
8080
EventSubtype.EMAIL_SUBMIT_INTEREST_CONFIRMATION
8181
)
82+
thank_you_with_kit = (
83+
gettext(
84+
"Registration code & kit update!"),
85+
"email/thank_you_with_kit.jinja2",
86+
("first_name", "registration_code", "interface_endpoint"),
87+
EventType.EMAIL,
88+
EventSubtype.EMAIL_THANK_YOU_WITH_KIT
89+
)
90+
thank_you_no_kit = (
91+
gettext(
92+
"Your questionnaire is ready!"),
93+
"email/thank_you_no_kit.jinja2",
94+
("first_name", "registration_code", "interface_endpoint"),
95+
EventType.EMAIL,
96+
EventSubtype.EMAIL_THANK_YOU_NO_KIT
97+
)
98+
kit_tracking_number = (
99+
gettext(
100+
"Your kit is on its way!"),
101+
"email/kit_tracking_number.jinja2",
102+
("first_name", "tracking_number"),
103+
EventType.EMAIL,
104+
EventSubtype.EMAIL_KIT_TRACKING_NUMBER
105+
)
106+
subscription_ffq_code = (
107+
gettext(
108+
"Registration code & kit update!"),
109+
"email/subscription_ffq_code.jinja2",
110+
("first_name", "tracking_number", "interface_endpoint"),
111+
EventType.EMAIL,
112+
EventSubtype.EMAIL_SUBSCRIPTION_FFQ_CODE
113+
)
82114

83115
def __init__(self, subject, html, required, event_type, event_sub):
84116
self.subject = subject

microsetta_private_api/admin/sample_summary.py

-3
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@ def per_sample(project, barcodes, strip_sampleid):
4141
source = diag['source']
4242

4343
account_email = None if account is None else account.email
44-
source_email = None
4544
source_type = None if source is None else source.source_type
4645
vio_id = None
4746

4847
if source is not None and source_type == Source.SOURCE_TYPE_HUMAN:
49-
source_email = source.source_data.email
5048

5149
vio_id = template_repo.get_vioscreen_id_if_exists(account.id,
5250
source.id,
@@ -75,7 +73,6 @@ def per_sample(project, barcodes, strip_sampleid):
7573
"project": project,
7674
"source-type": source_type,
7775
"site-sampled": sample_site,
78-
"source-email": source_email,
7976
"account-email": account_email,
8077
"vioscreen_username": vio_id,
8178
"ffq-taken": ffq_taken,

0 commit comments

Comments
 (0)