Skip to content

Commit

Permalink
Merge branch 'master' into jc/commcare_client_version_compliance_report
Browse files Browse the repository at this point in the history
  • Loading branch information
jingcheng16 authored Dec 11, 2024
2 parents 4bc93c8 + 0c6d4b1 commit 1c1abb6
Show file tree
Hide file tree
Showing 78 changed files with 1,260 additions and 2,943 deletions.
25 changes: 15 additions & 10 deletions corehq/apps/app_manager/fixtures/mobile_ucr.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def __call__(self, restore_state):
return []

restore_user = restore_state.restore_user
apps = self._get_apps(restore_state, restore_user)
with restore_state.timing_context('_get_apps'):
apps = self._get_apps(restore_state, restore_user)
report_configs = self._get_report_configs(apps)
if not report_configs:
return []
Expand Down Expand Up @@ -168,6 +169,7 @@ def __init__(self, domain, report_configs):
self.reports = {}
self.domain = domain
self.report_configs = report_configs
self.add_row_index = toggles.ADD_ROW_INDEX_TO_MOBILE_UCRS.enabled(domain)

def get_data(self, key, data_source):
if key not in self.data_cache:
Expand Down Expand Up @@ -234,7 +236,8 @@ def __call__(self, restore_state, restore_user, needed_versions, report_configs)
if needed_versions.intersection({MOBILE_UCR_VERSION_1, MOBILE_UCR_MIGRATING_TO_2}):
yield _get_report_index_fixture(restore_user)
try:
self.report_data_cache.load_reports()
with restore_state.timing_context('V1 load_reports'):
self.report_data_cache.load_reports()
except Exception:
logging.exception("Error fetching reports for domain", extra={
"domain": restore_user.domain,
Expand Down Expand Up @@ -275,13 +278,11 @@ def _v1_fixture(self, restore_user, report_configs, fail_hard=False):
return root

def report_config_to_fixture(self, report_config, restore_user):
row_index_enabled = toggles.ADD_ROW_INDEX_TO_MOBILE_UCRS.enabled(restore_user.domain)

def _row_to_row_elem(
deferred_fields, filter_options_by_field, row, index, is_total_row=False,
):
row_elem = E.row(index=str(index), is_total_row=str(is_total_row))
if row_index_enabled:
if self.report_data_cache.add_row_index:
row_elem.append(E.column(str(index), id='row_index'))
for k in sorted(row.keys()):
value = serialize(row[k])
Expand Down Expand Up @@ -321,15 +322,17 @@ def __call__(self, restore_state, restore_user, needed_versions, report_configs)
yield _get_report_index_fixture(restore_user, oldest_sync_time)

try:
self.report_data_cache.load_reports(synced_fixtures)
with restore_state.timing_context('V2 load_reports'):
self.report_data_cache.load_reports(synced_fixtures)
except Exception:
logging.exception("Error fetching reports for domain", extra={
"domain": restore_user.domain,
"report_config_ids": [config.report_id for config in synced_fixtures]
})
return []

yield from self._v2_fixtures(restore_user, synced_fixtures, restore_state.params.fail_hard)
with restore_state.timing_context('_v2_fixtures'):
yield from self._v2_fixtures(restore_state, synced_fixtures)
for report_uuid in purged_fixture_ids:
yield from self._empty_v2_fixtures(report_uuid)

Expand Down Expand Up @@ -404,10 +407,12 @@ def _empty_v2_fixtures(self, report_uuid):
yield E.fixture(id=self._report_fixture_id(report_uuid))
yield E.fixture(id=self._report_filter_id(report_uuid))

def _v2_fixtures(self, restore_user, report_configs, fail_hard=False):
def _v2_fixtures(self, restore_state, report_configs):
fail_hard = restore_state.params.fail_hard
for report_config in report_configs:
try:
yield from self.report_config_to_fixture(report_config, restore_user)
with restore_state.timing_context(report_config.instance_id):
yield from self.report_config_to_fixture(report_config, restore_state.restore_user)
except ReportConfigurationNotFoundError as err:
logging.exception('Error generating report fixture: {}'.format(err))
if fail_hard:
Expand All @@ -427,7 +432,7 @@ def _v2_fixtures(self, restore_user, report_configs, fail_hard=False):
def report_config_to_fixture(self, report_config, restore_user):
def _row_to_row_elem(deferred_fields, filter_options_by_field, row, index, is_total_row=False):
row_elem = E.row(index=str(index), is_total_row=str(is_total_row))
if toggles.ADD_ROW_INDEX_TO_MOBILE_UCRS.enabled(restore_user.domain):
if self.report_data_cache.add_row_index:
row_elem.append(E('row_index', str(index)))
for k in sorted(row.keys()):
value = serialize(row[k])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,12 @@ hqDefine("enterprise/js/project_dashboard", [
const maxDateRangeDays = initialPageData.get("max_date_range_days");

const displayMap = {
"form_submission": formSubmissionsDisplay,
"form_submissions": formSubmissionsDisplay,
"sms": smsDisplay,
};
const dateRangeModal = DateRangeModal($dateRangeModal, datePicker, dateRangePresetOptions, maxDateRangeDays, displayMap);

$("#form_submission_dateRangeDisplay").koApplyBindings(formSubmissionsDisplay);
$("#form_submissions_dateRangeDisplay").koApplyBindings(formSubmissionsDisplay);
$("#sms_dateRangeDisplay").koApplyBindings(smsDisplay);
$dateRangeModal.koApplyBindings(
dateRangeModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,16 @@ <h4 class="fs-5 pt-2">{{ report.title }}</h4>
</div>
<div class="card-footer bg-transparent border-0 pt-0">
<div class="pb-2">
{% if report.title == "Mobile Form Submissions" %}
{% if report.slug in uses_date_range %}
<button
class="btn btn-link fs-6" id="form_submission_dateRangeDisplay" type="button"
class="btn btn-link fs-6" id="{{ report.slug }}_dateRangeDisplay" type="button"
data-bind="text: presetText"
data-bs-toggle="modal"
data-bs-target="#enterpriseFormsDaterange"
data-sender="form_submission"
>&nbsp;</button>
{% elif report.title == "SMS Usage" %}
<button
class="btn btn-link fs-6" id="sms_dateRangeDisplay" type="button"
data-bind="text: presetText"
data-bs-toggle="modal"
data-bs-target="#enterpriseFormsDaterange"
data-sender="sms"
data-sender="{{ report.slug }}"
>&nbsp;</button>
{% else %}
<div class="form-control-plaintext fs-6">{{ "&nbsp;" }}</div>
<div class="form-control-plaintext fs-6">&nbsp;</div>
{% endif %}
</div>
<div class="mb-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="row mt-4">
{% for report in reports %}
<div class="col-md-6 col-lg-6 col-xl-3 mb-3">
{% include 'enterprise/partials/project_tile.html' with report=report %}
{% include 'enterprise/partials/project_tile.html' with report=report uses_date_range=uses_date_range%}
</div>
{% endfor %}
</div>
Expand Down
1 change: 1 addition & 0 deletions corehq/apps/enterprise/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def platform_overview(request, domain):
EnterpriseReport.COMMCARE_VERSION_COMPLIANCE,
EnterpriseReport.SMS,
)],
'uses_date_range': [EnterpriseReport.FORM_SUBMISSIONS, EnterpriseReport.SMS],
'metric_type': 'Platform Overview',
})

Expand Down
19 changes: 19 additions & 0 deletions corehq/apps/hqadmin/static/hqadmin/js/mass_email.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
hqDefine("hqadmin/js/mass_email", [
'jquery',
'commcarehq',
], function (
$
) {
$(function () {
$('#real_email').click(function (e) {
if ($(this).prop('checked')) {
$('#warning_modal').modal('show');
e.preventDefault();
}
});

$('#accept_mass_email').click(function () {
$('#real_email').prop('checked', 'checked');
});
});
});
9 changes: 5 additions & 4 deletions corehq/apps/hqadmin/templates/hqadmin/disable_two_factor.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{% extends "hqadmin/hqadmin_base_report.html" %}
{% extends "hqwebapp/bootstrap3/base_section.html" %}
{% load i18n %}
{% load crispy_forms_tags %}

{% block reportcontent %}
<h1>{% block title %}{% trans "Temporarily Disable Two-factor Authentication" %}{% endblock %}</h1>
{% block title %}{{ current_page.page_name }}{% endblock %}

{% block page_content %}
<p>{% blocktrans %}You are about to temporarily disable two-factor authentication for {{ username }}. This
compromises their account security, are you sure?{% endblocktrans %}</p>
<div class="alert alert-warning">
<p>When temporarily disabling and resetting Two-Factor Auth it is important to verify that the request was made by the owner of the account (and not faked by someone else).</p>
<p>Please follow the <a href="https://confluence.dimagi.com/pages/viewpage.action?pageId=27362739"#Two-StepAuthentication(2FA)-StepsforsupporttoresetCommCareHQaccount\">guidelines on the wiki</a>.</p>
<p>Please follow the <a href="https://confluence.dimagi.com/pages/viewpage.action?pageId=27362739#Two-StepAuthentication(2FA)-StepsforsupporttoresetCommCareHQaccount">guidelines on the wiki</a>.</p>
</div>
{% crispy form %}
{% endblock %}
7 changes: 4 additions & 3 deletions corehq/apps/hqadmin/templates/hqadmin/disable_user.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{% extends "hqadmin/hqadmin_base_report.html" %}
{% extends "hqwebapp/bootstrap3/base_section.html" %}
{% load i18n %}
{% load crispy_forms_tags %}

{% block reportcontent %}
<h1>{% block title %}{{ verb|title }} {% trans "User Account" %}{% endblock %}</h1>
{% block title %}{{ current_page.page_name }}{% endblock %}

{% block page_content %}
<p>{% blocktrans %}You are about to {{ verb }} the user account for "{{ username }}".{% endblocktrans %}</p>
<p>This will prevent them from using CommCare HQ at all and will be enforced immediately.</p>
{% crispy form %}
Expand Down
6 changes: 4 additions & 2 deletions corehq/apps/hqadmin/templates/hqadmin/global_thresholds.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{% extends "hqadmin/hqadmin_base_report.html" %}
{% extends "hqwebapp/bootstrap3/base_section.html" %}
{% load hq_shared_tags %}

{% block reportcontent %}
{% block title %}{{ current_page.page_name }}{% endblock %}

{% block page_content %}

{% include "domain/admin/partials/bootstrap3/project_limits_table.html" %}

Expand Down
61 changes: 0 additions & 61 deletions corehq/apps/hqadmin/templates/hqadmin/hqadmin_base_report.html

This file was deleted.

30 changes: 8 additions & 22 deletions corehq/apps/hqadmin/templates/hqadmin/mass_email.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
{% extends "hqadmin/hqadmin_base_report.html" %}
{% extends "hqwebapp/bootstrap3/base_section.html" %}
{% load hq_shared_tags %}
{% load i18n %}
{% block title %}Mass Email Users{% endblock %}
{% block js-inline %} {{ block.super }}
<script>
$(function () {
$('#real_email').click(function(e) {
if($(this).prop('checked')) {
$('#warning_modal').modal();
e.preventDefault();
}
});

$('#accept_mass_email').click(function() {
$('#real_email').prop('checked', 'checked');
});
});
</script>
{% endblock %}
{% block reportcontent %}
<br><br>
{% block title %}{{ current_page.page_name }}{% endblock %}

{% js_entry_b3 "hqadmin/js/mass_email" %}

{% block page_content %}
{% if form.errors %}
<div class="alert alert-danger">{{ form.errors }}</div>
{% endif %}
Expand All @@ -28,7 +15,7 @@
This is the email mailing list tool. Please exercise caution
when using it.
</p>
</p>
<p>
Leave the <strong>email all users</strong> checkbox unchecked to send a test
email only to yourself. This is useful for verifying that
your formatting is correct before sending a real message.
Expand All @@ -49,8 +36,7 @@
name="email_subject"
type="text"
class="form-control"
placeholder="Enter subject...">
</input>
placeholder="Enter subject..."/>
</div>

<div class="form-group">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% extends "hqadmin/hqadmin_base_report.html" %}
{% extends "hqwebapp/bootstrap3/base_section.html" %}
{% load crispy_forms_tags %}
{% load i18n %}
{% block reportcontent %}
<h2>{% trans "Reprocess Messaging Case Updates" %}</h2>
<div class="row">
{% crispy form %}
</div>

{% block title %}{{ current_page.page_name }}{% endblock %}

{% block page_content %}
{% crispy form %}
{% endblock %}
6 changes: 4 additions & 2 deletions corehq/apps/hqadmin/templates/hqadmin/system_info.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{% extends "hqadmin/hqadmin_base_report.html" %}
{% extends "hqwebapp/bootstrap3/base_section.html" %}
{% load hq_shared_tags %}
{% load i18n %}
{% load humanize %}

{% js_entry_b3 'hqadmin/js/system_info' %}

{% block reportcontent %}
{% block title %}{{ current_page.page_name }}{% endblock %}

{% block page_content %}
{% initial_page_data "celery_update" celery_update %}
{% initial_page_data "couch_update" couch_update %}
{% initial_page_data "is_bigcouch" is_bigcouch %}
Expand Down
1 change: 0 additions & 1 deletion corehq/apps/hqadmin/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@
from corehq.apps.hqadmin.views.utils import (
BaseAdminSectionView,
default,
get_hqadmin_base_context,
)
Loading

0 comments on commit 1c1abb6

Please sign in to comment.