Skip to content

Commit

Permalink
Adjustments from tester feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
cassidysymons committed Sep 12, 2023
1 parent f760139 commit 86a2af1
Show file tree
Hide file tree
Showing 6 changed files with 275 additions and 204 deletions.
35 changes: 28 additions & 7 deletions microsetta_interface/implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,14 +1092,18 @@ def get_account(*, account_id=None):

# Determine if the source/profile has any action items. This framework
# will evolve over time.
non_human_sources = False
for s in sources:
alerts = 0
if s['source_type'] == Source.SOURCE_TYPE_HUMAN:

need_reconsent_d = check_current_consent(
account_id, s[SOURCE_ID], "data"
)
if need_reconsent_d:
alerts += 1
need_reconsent_d = check_current_consent(
account_id, s[SOURCE_ID], "data"
)
if need_reconsent_d:
alerts += 1
else:
non_human_sources = True

s['alerts'] = alerts

Expand All @@ -1113,7 +1117,8 @@ def get_account(*, account_id=None):
return _render_with_defaults('account_overview.jinja2',
account=account,
sources=sources,
japan_user=japan_user)
japan_user=japan_user,
non_human_sources=non_human_sources)


@prerequisite([ACCT_PREREQS_MET])
Expand Down Expand Up @@ -1842,17 +1847,23 @@ def get_kits(*, account_id=None, source_id=None, check_survey_date=False):
for sample in samples_output:
if sample['sample_datetime'] is not None:
dt = datetime.fromisoformat(sample['sample_datetime'])
sample['ts_for_sort'] = dt
# rebase=True - show in user's locale, rebase=False, UTC (I think?)
sample['sample_datetime'] = flask_babel.format_datetime(
dt,
format=None, # Use babel default (short/medium/long/full)
rebase=False)
else:
# We just need a sort value for samples without a collection date
# and we want it to filter to the top when we sort by date desc.
sample['ts_for_sort'] = datetime.fromisoformat("9999-12-31")

is_human = source_output['source_type'] == Source.SOURCE_TYPE_HUMAN

samples = [translate_sample(s) for s in samples_output]

kits = defaultdict(list)
kits_ts = {}
for s in samples:
if s['sample_site'] == '' or s['sample_datetime'] == '':
s['css_class'] = "sample-needs-info"
Expand All @@ -1862,6 +1873,16 @@ def get_kits(*, account_id=None, source_id=None, check_survey_date=False):
s['alert_icon'] = "green_checkmark.svg"

kits[s['kit_id']].append(s)
if s['kit_id'] in kits_ts:
if s['ts_for_sort'] > kits_ts[s['kit_id']]:
kits_ts[s['kit_id']] = s['ts_for_sort']
else:
kits_ts[s['kit_id']] = s['ts_for_sort']

sorted_kits = {}
sorted_kits_ts = dict(sorted(kits_ts.items(), key=lambda x: x[1], reverse=True))
for kit_id in sorted_kits_ts.keys():
sorted_kits[kit_id] = kits[kit_id]

profile_has_samples = _check_if_source_has_samples(account_id, source_id)

Expand Down Expand Up @@ -1889,7 +1910,7 @@ def get_kits(*, account_id=None, source_id=None, check_survey_date=False):
account_id=account_id,
source_id=source_id,
is_human=is_human,
kits=kits,
kits=sorted_kits,
source_name=source_output['source_name'],
fundrazr_url=SERVER_CONFIG["fundrazr_url"],
account_country=account_country,
Expand Down
28 changes: 28 additions & 0 deletions microsetta_interface/templates/account_overview.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
<div class="container default-container">
{% if sources|length > 0 %}
<h2 class="account-h2">{{ _('Active Profiles') }}</h2>
{% if non_human_sources %}
<p class="tmi-tooltip">{{ _('Please note: animal and environmental profiles are currently unavailable.') }}</p>
{% endif %}
<div class="row mb-5">
{% for source in sources %}
<div class="col-md-4 mb-4">
Expand All @@ -66,13 +69,31 @@
</div>
</div>
{% else %}
{% if source.source_type == "animal" %}
<div class="card card-profile">
<img src="/static/img/source_animal.png" class="mx-auto card-profile-icon" width="70px">
<h2 class="profile-card-h2 mx-auto mt-2 mb-4" title="{{ source.source_name|e}}">{{ source.source_name|e}}</h2>
<a class="btn btn-blue-gradient mx-auto" style="width: fit-content; pointer-events: none;" href="#" disabled>
{{ _('Unavailable') }}
</a>
</div>
{% elif source.source_type == "environmental" %}
<div class="card card-profile">
<img src="/static/img/source_environmental.png" class="mx-auto card-profile-icon" width="70px">
<h2 class="profile-card-h2 mx-auto mt-2 mb-4" title="{{ source.source_name|e}}">{{ source.source_name|e}}</h2>
<a class="btn btn-blue-gradient mx-auto" style="width: fit-content; pointer-events: none;" href="#" disabled>
{{ _('Unavailable') }}
</a>
</div>
{% else %}
<div class="card card-profile">
<img src="/static/img/profile_card_icon.png" class="mx-auto card-profile-icon">
<h2 class="profile-card-h2 mx-auto mt-2 mb-4" title="{{ source.source_name|e}}">{{ source.source_name|e}}</h2>
<a class="btn btn-blue-gradient mx-auto" style="width: fit-content;" href="/accounts/{{account.account_id}}/sources/{{ source.source_id|e }}">
{{ _('Go to My Profile') }}
</a>
</div>
{% endif %}
{% endif %}
</div>
{% endfor %}
Expand Down Expand Up @@ -106,6 +127,13 @@
<p class="disabled-source-types"><strong>{{ _('Coming Soon') }}</strong></p>
</div>
</div>
{% if admin_mode %}
<div class="row mt-3">
<div class="col-12">
<center><h2><a href="/accounts/{{ account.account_id }}/details">{{ _('Account Details') }}</a></h2></center>
</div>
</div>
{% endif %}
</div>


Expand Down
10 changes: 6 additions & 4 deletions microsetta_interface/templates/kits.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,15 @@
}
}
function updateButtonState(kit_id_value) {
if(kit_id_value != "") {
/*
function updateButtonState() {
if(document.list_kit_form.kit_name.value != "") {
document.getElementById("kit_id_button").disabled = false;
} else {
document.getElementById("kit_id_button").disabled = true;
}
}
*/
function openKitPanel() {
document.getElementById('add_kit_container').style.display = '';
Expand Down Expand Up @@ -282,12 +284,12 @@
<div class="col-12 text-center">
<div class="kit_id_container">
<label for="kit_name" name="label_kit_name" class="tmi-content">{{ _('To register your kit, enter your Kit ID below') }}:</label><br />
<input type="text" name="kit_name" id="kit_name" class="form-control" placeholder="XXXXXXXXXX" onKeyUp="updateButtonState(this.value);"/>
<input type="text" name="kit_name" id="kit_name" class="form-control" placeholder="XXXXXXXXXX" />
<label for="kit_name" class="error kit-validation-error" style="display: none"></label>
</div>
</div>
<div class="col-12 text-center mt-4">
<button class="btn btn-blue-gradient" name="kit_id_button" id="kit_id_button" disabled>{{ _('Register Kit') }}</button>
<button class="btn btn-blue-gradient" name="kit_id_button" id="kit_id_button">{{ _('Register Kit') }}</button>
</div>
</div>
</div>
Expand Down
8 changes: 5 additions & 3 deletions microsetta_interface/templates/nutrition.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
preclude_whitespace('#ffq_code');
$("form[name='" + form_name + "']").on('submit', function() {
updateButtonState("");
document.getElementById("ffq_code_button").disabled = true;
});
// Initialize form validation on the registration form.
Expand All @@ -72,13 +72,15 @@
});
});
/*
function updateButtonState(ffq_code_value) {
if(ffq_code_value != "") {
document.getElementById("ffq_code_button").disabled = false;
} else {
document.getElementById("ffq_code_button").disabled = true;
}
}
*/
function openCodePanel() {
document.getElementById('add_code_container').style.display = '';
Expand Down Expand Up @@ -209,12 +211,12 @@
<div class="col-12 text-center">
<div class="kit_id_container">
<label for="ffq_code" name="ffq_code_name" class="tmi-content">{{ _('Registration Code') }}:</label><br />
<input type="text" name="ffq_code" id="ffq_code" class="form-control" placeholder="TMI-XXXXX-XXXXX-XXXXX" onKeyUp="updateButtonState(this.value);"/>
<input type="text" name="ffq_code" id="ffq_code" class="form-control" placeholder="TMI-XXXXX-XXXXX-XXXXX" />
<label for="ffq_code" class="error kit-validation-error" style="display: none"></label>
</div>
</div>
<div class="col-12 text-center mt-4">
<button class="btn btn-blue-gradient" name="ffq_code_button" id="ffq_code_button" disabled>{{ _('Register FFQ') }}</button>
<button class="btn btn-blue-gradient" name="ffq_code_button" id="ffq_code_button">{{ _('Register FFQ') }}</button>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 86a2af1

Please sign in to comment.