Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify hqadmin views by removing hqadmin_base_report.html #35504

Merged
merged 9 commits into from
Dec 11, 2024
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
@@ -1,17 +1,17 @@
from corehq.apps.hqadmin.views.data import (

Check failure on line 1 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L1

'corehq.apps.hqadmin.views.data.doc_in_es' imported but unused (F401)

Check failure on line 1 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L1

'corehq.apps.hqadmin.views.data.raw_doc' imported but unused (F401)
doc_in_es,
raw_doc,
)
from corehq.apps.hqadmin.views.operations import (

Check failure on line 5 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L5

'corehq.apps.hqadmin.views.operations.CallcenterUCRCheck' imported but unused (F401)

Check failure on line 5 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L5

'corehq.apps.hqadmin.views.operations.ReprocessMessagingCaseUpdatesView' imported but unused (F401)

Check failure on line 5 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L5

'corehq.apps.hqadmin.views.operations.mass_email' imported but unused (F401)
CallcenterUCRCheck,
ReprocessMessagingCaseUpdatesView,
mass_email,
)
from corehq.apps.hqadmin.views.reports import (

Check failure on line 10 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L10

'corehq.apps.hqadmin.views.reports.DownloadGIRView' imported but unused (F401)

Check failure on line 10 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L10

'corehq.apps.hqadmin.views.reports.DownloadMALTView' imported but unused (F401)
DownloadGIRView,
DownloadMALTView,
)
from corehq.apps.hqadmin.views.system import (

Check failure on line 14 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L14

'corehq.apps.hqadmin.views.system.SystemInfoView' imported but unused (F401)

Check failure on line 14 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L14

'corehq.apps.hqadmin.views.system.branches_on_staging' imported but unused (F401)

Check failure on line 14 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L14

'corehq.apps.hqadmin.views.system.check_services' imported but unused (F401)

Check failure on line 14 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L14

'corehq.apps.hqadmin.views.system.get_rabbitmq_management_url' imported but unused (F401)

Check failure on line 14 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L14

'corehq.apps.hqadmin.views.system.pillow_operation_api' imported but unused (F401)

Check failure on line 14 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L14

'corehq.apps.hqadmin.views.system.system_ajax' imported but unused (F401)
SystemInfoView,
branches_on_staging,
check_services,
Expand All @@ -19,7 +19,7 @@
pillow_operation_api,
system_ajax,
)
from corehq.apps.hqadmin.views.users import (

Check failure on line 22 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L22

'corehq.apps.hqadmin.views.users.AdminRestoreView' imported but unused (F401)

Check failure on line 22 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L22

'corehq.apps.hqadmin.views.users.DisableTwoFactorView' imported but unused (F401)

Check failure on line 22 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L22

'corehq.apps.hqadmin.views.users.DisableUserView' imported but unused (F401)

Check failure on line 22 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L22

'corehq.apps.hqadmin.views.users.DomainAdminRestoreView' imported but unused (F401)

Check failure on line 22 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L22

'corehq.apps.hqadmin.views.users.SuperuserManagement' imported but unused (F401)

Check failure on line 22 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L22

'corehq.apps.hqadmin.views.users.WebUserDataView' imported but unused (F401)

Check failure on line 22 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L22

'corehq.apps.hqadmin.views.users.web_user_lookup' imported but unused (F401)
AdminRestoreView,
DisableTwoFactorView,
DisableUserView,
Expand All @@ -28,8 +28,7 @@
WebUserDataView,
web_user_lookup,
)
from corehq.apps.hqadmin.views.utils import (

Check failure on line 31 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L31

'corehq.apps.hqadmin.views.utils.BaseAdminSectionView' imported but unused (F401)

Check failure on line 31 in corehq/apps/hqadmin/views/__init__.py

View workflow job for this annotation

GitHub Actions / Flake8

corehq/apps/hqadmin/views/__init__.py#L31

'corehq.apps.hqadmin.views.utils.default' imported but unused (F401)
BaseAdminSectionView,
default,
get_hqadmin_base_context,
)
15 changes: 7 additions & 8 deletions corehq/apps/hqadmin/views/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from corehq.apps.hqadmin.tasks import send_mass_emails
from corehq.apps.hqadmin.views.utils import (
BaseAdminSectionView,
get_hqadmin_base_context,
get_breadcrumbs,
)
from corehq.form_processor.exceptions import CaseNotFound
from corehq.form_processor.models import CommCareCase
Expand All @@ -40,9 +40,10 @@ def mass_email(request):
else:
form = EmailForm()

context = get_hqadmin_base_context(request)
context['hide_filters'] = True
context['form'] = form
context = {
'form': form,
**get_breadcrumbs('Mass Email Users', 'mass_email'),
}
return render(request, "hqadmin/mass_email.html", context)


Expand Down Expand Up @@ -97,11 +98,9 @@ def form(self):

@property
def page_context(self):
context = get_hqadmin_base_context(self.request)
context.update({
return {
'form': self.form,
})
return context
}

def get_case(self, case_id):
try:
Expand Down
3 changes: 1 addition & 2 deletions corehq/apps/hqadmin/views/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from corehq.apps.hqadmin.utils import get_celery_stats
from corehq.apps.hqadmin.views.utils import (
BaseAdminSectionView,
get_hqadmin_base_context,
)
from corehq.apps.hqwebapp.decorators import use_datatables, use_jquery_ui
from corehq.apps.receiverwrapper.rate_limiter import (
Expand All @@ -56,7 +55,7 @@ def dispatch(self, request, *args, **kwargs):
def page_context(self):
environment = settings.SERVER_ENVIRONMENT

context = get_hqadmin_base_context(self.request)
context = {}
context['couch_update'] = self.request.GET.get('couch_update', 5000)
context['celery_update'] = self.request.GET.get('celery_update', 10000)
context['db_update'] = self.request.GET.get('db_update', 30000)
Expand Down
8 changes: 4 additions & 4 deletions corehq/apps/hqadmin/views/users.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import csv
import itertools
import settings
import os
import urllib.parse
import uuid
from collections import Counter
from datetime import datetime, timedelta
from io import StringIO
Expand Down Expand Up @@ -56,7 +54,7 @@
SuperuserManagementForm,
OffboardingUserListForm,
)
from corehq.apps.hqadmin.views.utils import BaseAdminSectionView
from corehq.apps.hqadmin.views.utils import BaseAdminSectionView, get_breadcrumbs
from corehq.apps.hqmedia.tasks import create_files_for_ccz
from corehq.apps.ota.views import get_restore_params, get_restore_response
from corehq.apps.users.audit.change_messages import UserChangeMessage
Expand Down Expand Up @@ -457,7 +455,8 @@ def get(self, request, *args, **kwargs):

def get_context_data(self, **kwargs):
context = super(DisableUserView, self).get_context_data(**kwargs)
context['verb'] = 'disable' if self.user.is_active else 'enable'
verb = 'Disable' if self.user.is_active else 'Enable'
context.update(get_breadcrumbs(f'{verb} User Account', 'disable_user'))
context['username'] = self.username
return context

Expand Down Expand Up @@ -539,6 +538,7 @@ def get_initial(self):

def render_to_response(self, context, **response_kwargs):
context.update({
**get_breadcrumbs('Temporarily Disable Two-factor Authentication', self.urlname),
'username': self.request.GET.get("q"),
})
return super().render_to_response(context, **response_kwargs)
Expand Down
11 changes: 9 additions & 2 deletions corehq/apps/hqadmin/views/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ def default(request):
return HttpResponseRedirect(UserListReport.get_url())


def get_hqadmin_base_context(request):
def get_breadcrumbs(current_title, current_urlname):
return {
"domain": None,
'current_page': {
'url': reverse(current_urlname),
'page_name': current_title,
},
'section': {
'url': reverse('default_admin_report'),
'title': 'Admin',
},
}


Expand Down
Loading