Skip to content

Commit

Permalink
Merge branch 'master' into riese/deprecate_ff
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinRiese authored Nov 15, 2024
2 parents aa6aef3 + 7280c43 commit 212f513
Show file tree
Hide file tree
Showing 174 changed files with 3,396 additions and 1,799 deletions.
2 changes: 1 addition & 1 deletion corehq/apps/accounting/static/accounting/js/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ hqDefine('accounting/js/widgets', [
'underscore',
'hqwebapp/js/utils/email',
'select2/dist/js/select2.full.min',
'commcarehq_b3',
'commcarehq',
], function (
$,
ko,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ hqDefine("app_manager/js/app_exchange", [
"knockout",
'analytix/js/kissmetrix',
"hqwebapp/js/bootstrap3/widgets", // hqwebapp-select2 for versions
"commcarehq",
], function (
$,
ko,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ hqDefine('app_manager/js/download_index_main',[
'app_manager/js/multimedia_size_util',
'app_manager/js/download_async_modal',
'app_manager/js/source_files',
'commcarehq',
], function ($, _, ko, baseAce, initialPageData, multimediaSizeUtil) {
$(function () {
var elements = $('.prettyprint');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ hqDefine('app_manager/js/source_files', [
'hqwebapp/js/initial_page_data',
'app_manager/js/multimedia_size_util',
'app_manager/js/widgets', // version dropdown
'commcarehq',
], function ($, _, ko, initialPageData, multimediaSizeUtil) {
$(function () {
$('.toggle-next').click(function (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ hqDefine('app_manager/js/summary/case_summary',[
'app_manager/js/menu', // enable lang switcher and "Updates to publish" banner
'hqwebapp/js/bootstrap3/knockout_bindings.ko', // popover
'hqwebapp/js/components/search_box',
'commcarehq',
], function ($, _, ko, initialPageData, assertProperties, models) {

var caseTypeModel = function (caseType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ hqDefine('app_manager/js/summary/form_diff',[
'app_manager/js/menu', // enable lang switcher and "Updates to publish" banner
'hqwebapp/js/bootstrap3/knockout_bindings.ko', // popover
'hqwebapp/js/components/search_box',
'commcarehq',
], function ($, _, ko, initialPageData, assertProperties, models, formModels, utils, layout) {

$(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ hqDefine('app_manager/js/summary/form_summary',[
'app_manager/js/menu', // enable lang switcher and "Updates to publish" banner
'hqwebapp/js/bootstrap3/knockout_bindings.ko', // popover
'hqwebapp/js/components/search_box',
'commcarehq',
], function ($, _, ko, initialPageData, assertProperties, models, formModels, utils) {
$(function () {
var lang = initialPageData.get('lang'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% load hq_shared_tags %}
{% load compress %}
{% load i18n %}
{% requirejs_main 'app_manager/js/source_files' %}
{% js_entry_b3 'app_manager/js/source_files' %}
{% block stylesheets %}{{ block.super }}
{% compress css %}
<link type="text/css" rel="stylesheet" href="{% static 'app_manager/css/diff.css' %}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{% block title %}{% trans "COVID-19 CommCare Applications" %}{% endblock title %}

{% requirejs_main 'app_manager/js/app_exchange' %}
{% js_entry_b3 'app_manager/js/app_exchange' %}

{% block content %}
<div class="container" id="hq-content">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% block title %}{% trans "Case Summary" %} - {% trans "Version" %} {{ app_version }}{% endblock %}

{% requirejs_main 'app_manager/js/summary/case_summary' %}
{% js_entry_b3 'app_manager/js/summary/case_summary' %}

{% block content_extra %}
<div class="ko-template" id="case-summary-header">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{% load hq_shared_tags %}
{% load compress %}
{% load i18n %}
{% requirejs_main 'app_manager/js/download_index_main' %}

{% js_entry_b3 'app_manager/js/download_index_main' %}

{% block page_title %}
{{ app.name }}: Build #{{ app.version }}{% if app.build_comment %}: {{ app.build_comment }}{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{% endblocktrans %}
{% endblock %}

{% requirejs_main "app_manager/js/summary/form_summary" %}
{% js_entry_b3 "app_manager/js/summary/form_summary" %}

{% block content_extra %}
{% initial_page_data 'errors' errors %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{% endblocktrans %}
{% endblock %}

{% requirejs_main "app_manager/js/summary/form_diff" %}
{% js_entry_b3 "app_manager/js/summary/form_diff" %}

{% block content_extra %}
{% registerurl 'form_source' domain app_id '---' %}
Expand Down
117 changes: 117 additions & 0 deletions corehq/apps/app_manager/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import re
from contextlib import contextmanager
from unittest import mock
from unittest.mock import patch

from django.contrib.auth import get_user_model
Expand Down Expand Up @@ -448,6 +449,122 @@ def test_form_links_context(self, _):
}
])

def test_copy_regular_app(self, _):
other_domain = Domain.get_or_create_with_name('other-domain', is_active=True)
self.addCleanup(other_domain.delete)

module = self.app.add_module(Module.new_module("Module0", "en"))
self.app.new_form(module.id, "Form0", "en", attachment=get_simple_form(xmlns='xmlns-0.0'))
self.app.save()

copy_data = {
'app': self.app.id,
'domain': other_domain.name,
'name': 'Copy App',
'linked': False,
}
response = self.client.post(reverse('copy_app', args=[self.domain]), copy_data)
self.assertEqual(response.status_code, 302)

copied_app = other_domain.full_applications()[0]
self.assertEqual(copied_app.name, 'Copy App')
self.assertEqual(copied_app.doc_type, 'Application')

copied_module = copied_app.modules[0]
copied_form = list(copied_module.get_forms())[0]
self.assertEqual(copied_module.name['en'], "Module0")
self.assertEqual(copied_form.name['en'], "Form0")

copied_app.delete()

def test_copy_linked_app_to_different_domain(self, _):
other_domain = Domain.get_or_create_with_name('other-domain', is_active=True)
self.addCleanup(other_domain.delete)

module = self.app.add_module(Module.new_module("Module0", "en"))
self.app.new_form(module.id, "Form0", "en", attachment=get_simple_form(xmlns='xmlns-0.0'))
self.app.save()
build = self.app.make_build()
build.is_released = True
build.save()

copy_data = {
'app': self.app.id,
'domain': other_domain.name,
'name': 'Linked App',
'linked': True,
'build_id': build.id,
}
with patch('corehq.apps.app_manager.forms.can_domain_access_linked_domains', return_value=True):
response = self.client.post(reverse('copy_app', args=[self.domain]), copy_data)
self.assertEqual(response.status_code, 302)

linked_app = other_domain.full_applications()[0]
self.assertEqual(linked_app.name, 'Linked App')
self.assertEqual(linked_app.doc_type, 'LinkedApplication')

linked_module = linked_app.modules[0]
linked_form = list(linked_module.get_forms())[0]
self.assertEqual(linked_module.name['en'], "Module0")
self.assertEqual(linked_form.name['en'], "Form0")

linked_app.delete()

def test_cannot_copy_linked_app_to_same_domain(self, _):
module = self.app.add_module(Module.new_module("Module0", "en"))
self.app.new_form(module.id, "Form0", "en", attachment=get_simple_form(xmlns='xmlns-0.0'))
self.app.save()
build = self.app.make_build()
build.is_released = True
build.save()

copy_data = {
'app': self.app.id,
'domain': self.domain,
'name': 'Same Domain Link',
'linked': True,
'build_id': build.id,
}
with patch('corehq.apps.app_manager.forms.can_domain_access_linked_domains', return_value=True):
response = self.client.post(reverse('copy_app', args=[self.domain]), copy_data)

self.assertEqual(response.status_code, 302)
self.assertEqual(
['Creating linked app failed. '
'You cannot create a linked app in the same project space as the upstream app.'],
[m.message for m in response.wsgi_request._messages]
)

def test_copy_regular_app_toggles(self, _):
other_domain = Domain.get_or_create_with_name('other-domain', is_active=True)
self.addCleanup(other_domain.delete)

module = self.app.add_module(Module.new_module("Module0", "en"))
self.app.new_form(module.id, "Form0", "en", attachment=get_simple_form(xmlns='xmlns-0.0'))
self.app.save()

from corehq.toggles import NAMESPACE_DOMAIN, StaticToggle, TAG_INTERNAL
from corehq.toggles.shortcuts import set_toggle

TEST_TOGGLE = StaticToggle(
'test_toggle',
'This is for tests',
TAG_INTERNAL,
[NAMESPACE_DOMAIN],
)
set_toggle(TEST_TOGGLE.slug, other_domain.name, False, namespace=NAMESPACE_DOMAIN)
copy_data = {
'app': self.app.id,
'domain': other_domain.name,
'name': 'Copy App',
'toggles': 'test_toggle',
}
with patch('corehq.toggles.all_toggles_by_name', return_value={'test_toggle': TEST_TOGGLE}), \
mock.patch('corehq.apps.toggle_ui.views.clear_toggle_cache_by_namespace') as mock_clear_cache:
self.client.post(reverse('copy_app', args=[self.domain]), copy_data)
mock_clear_cache.assert_called_once_with(NAMESPACE_DOMAIN, other_domain.name)
self.assertTrue(TEST_TOGGLE.enabled(other_domain.name))


@contextmanager
def apps_modules_setup(test_case):
Expand Down
6 changes: 3 additions & 3 deletions corehq/apps/app_manager/views/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
)
from corehq.elastic import ESError
from corehq.tabs.tabclasses import ApplicationsTab
from corehq.toggles.shortcuts import set_toggle
from corehq.toggles.shortcuts import set_toggles
from corehq.util.dates import iso_string_to_datetime
from corehq.util.timezones.utils import get_timezone_for_user
from corehq.util.view_utils import reverse as reverse_util
Expand Down Expand Up @@ -452,8 +452,8 @@ def _inner(request, to_domain, data, from_domain=domain):
clear_app_cache(request, to_domain)

if data['toggles']:
for slug in data['toggles'].split(","):
set_toggle(slug, to_domain, True, namespace=toggles.NAMESPACE_DOMAIN)
toggle_slugs = data['toggles'].split(",")
set_toggles(toggle_slugs, to_domain, True, namespace=toggles.NAMESPACE_DOMAIN)

linked = data.get('linked')
if linked:
Expand Down
11 changes: 5 additions & 6 deletions corehq/apps/auditcare/utils/export.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import csv
from datetime import datetime, timedelta
from datetime import timedelta
from itertools import chain

from django.contrib.auth.models import User
Expand All @@ -22,9 +22,6 @@ def navigation_events_by_user(user, start_date=None, end_date=None):


def write_log_events(writer, user, domain=None, override_user=None, start_date=None, end_date=None):
start_date = string_to_datetime(start_date).replace(tzinfo=None) if start_date else None
end_date = string_to_datetime(end_date).replace(tzinfo=None) if end_date else None

for event in navigation_events_by_user(user, start_date, end_date):
if not domain or domain == event.domain:
write_log_event(writer, event, override_user)
Expand Down Expand Up @@ -138,9 +135,11 @@ def get_date_range_where(start_date, end_date):
"""Get ORM filter kwargs for inclusive event_date range"""
where = {}
if start_date:
where["event_date__gt"] = start_date.date()
start_date = string_to_datetime(start_date).replace(tzinfo=None)
where["event_date__gt"] = start_date
if end_date:
where["event_date__lt"] = end_date.date() + timedelta(days=1)
end_date = string_to_datetime(end_date).replace(tzinfo=None)
where["event_date__lt"] = end_date + timedelta(days=1)
return where


Expand Down
2 changes: 1 addition & 1 deletion corehq/apps/case_search/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _get_user_template_info(restore_user):
"username": restore_user.username,
"uuid": restore_user.user_id,
"user_data": restore_user.user_session_data,
"location_ids": restore_user.get_location_ids(restore_user.domain),
"location_ids": " ".join(restore_user.get_location_ids(restore_user.domain)),
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ hqDefine('case_search/js/case_search', [
'knockout',
'hqwebapp/js/bootstrap5/alert_user',
'hqwebapp/js/initial_page_data',
'commcarehq',
], function (
$,
_,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ hqDefine('case_search/js/profile_case_search', [
'underscore',
'knockout',
'hqwebapp/js/bootstrap5/alert_user',
'commcarehq',
], function (
$,
_,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% load compress %}
{% load i18n %}

{% requirejs_main_b5 'case_search/js/case_search' %}
{% js_entry 'case_search/js/case_search' %}

{% block page_content %}
{% registerurl 'case_data' request.domain '___' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% load compress %}
{% load i18n %}

{% requirejs_main_b5 'case_search/js/profile_case_search' %}
{% js_entry 'case_search/js/profile_case_search' %}

{% block page_content %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ hqDefine("cloudcare/js/form_entry/const", [], function () {
QUESTIONS_FOR_INDEX: 'questions_for_index',
NEXT_QUESTION: 'next_index',
PREV_QUESTION: 'prev_index',
SCROLLABLE_CONTENT_CONTAINER: '#content-plus-version-info-container',

// XForm Actions
NEW_FORM: 'new-form',
Expand Down Expand Up @@ -112,7 +113,7 @@ hqDefine("cloudcare/js/form_entry/const", [], function () {
FLOAT_VALUE_LIMIT: +("9".repeat(14)),
FILE_PREFIX: "C:\\fakepath\\",

// Boostrap
// Bootstrap
GRID_COLUMNS: 12,
};
});
Loading

0 comments on commit 212f513

Please sign in to comment.