-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34970 from dimagi/ad/GA-embed-tableau-by-user-toggle
Migrate "EMBED_TABLEAU_REPORT_BY_USER" toggle to project-level setting
- Loading branch information
Showing
6 changed files
with
67 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -317,6 +317,14 @@ class TableauServerForm(forms.Form): | |
label=_('Target Site'), | ||
) | ||
|
||
get_reports_using_role = forms.BooleanField( | ||
label=_("Get Tableau reports using role name"), | ||
required=False, | ||
help_text=_("If checked, CommCareHQ will request embedded reports from Tableau Server using the user's " | ||
"role name instead of the user's username (e.g. \"HQ/Field Implementer\" instead of " | ||
"\"HQ/[email protected]\")") | ||
) | ||
|
||
tableau_groups_allowed = forms.MultipleChoiceField( | ||
label=_("Allowed Tableau Groups"), | ||
choices=[], | ||
|
@@ -331,6 +339,7 @@ class Meta: | |
'server_name', | ||
'validate_hostname', | ||
'target_site', | ||
'get_reports_using_role' | ||
'tableau_groups_allowed' | ||
] | ||
|
||
|
@@ -355,6 +364,9 @@ def __init__(self, data, user_syncing_config={}, *args, **kwargs): | |
crispy.Div( | ||
crispy.Field('target_site'), | ||
), | ||
crispy.Div( | ||
crispy.Field('get_reports_using_role'), | ||
), | ||
FormActions( | ||
crispy.Submit('submit_btn', 'Submit') | ||
) | ||
|
@@ -395,13 +407,15 @@ def initial_data(self): | |
'server_name': self._existing_config.server_name, | ||
'validate_hostname': self._existing_config.validate_hostname, | ||
'target_site': self._existing_config.target_site, | ||
'get_reports_using_role': self._existing_config.get_reports_using_role, | ||
'allowed_tableau_groups': self._existing_config.allowed_tableau_groups, | ||
} | ||
|
||
def save(self): | ||
self._existing_config.server_type = self.cleaned_data['server_type'] | ||
self._existing_config.server_name = self.cleaned_data['server_name'] | ||
self._existing_config.validate_hostname = self.cleaned_data['validate_hostname'] | ||
self._existing_config.get_reports_using_role = self.cleaned_data['get_reports_using_role'] | ||
self._existing_config.target_site = self.cleaned_data['target_site'] | ||
if self.add_allowed_tableau_groups_field: | ||
self._existing_config.allowed_tableau_groups = [ | ||
|
43 changes: 43 additions & 0 deletions
43
corehq/apps/reports/migrations/0020_tableauserver_get_reports_using_role.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Generated by Django 4.2.14 on 2024-08-13 19:14 | ||
|
||
from django.db import migrations, models | ||
from corehq.util.django_migrations import skip_on_fresh_install | ||
|
||
|
||
@skip_on_fresh_install | ||
def _move_ff_to_setting(apps, schema_editor): | ||
try: | ||
from corehq.toggles import EMBED_TABLEAU_REPORT_BY_USER | ||
from corehq.toggles import EMBEDDED_TABLEAU | ||
except ImportError: | ||
return | ||
TableauServer = apps.get_model('reports', 'TableauServer') | ||
for domain in EMBEDDED_TABLEAU.get_enabled_domains(): | ||
if not EMBED_TABLEAU_REPORT_BY_USER.enabled(domain): | ||
try: | ||
server = TableauServer.objects.get(domain=domain) | ||
except TableauServer.DoesNotExist: | ||
pass | ||
else: | ||
server.get_reports_using_role = True | ||
server.save() | ||
|
||
|
||
def noop(*args, **kwargs): | ||
pass | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('reports', '0019_tableauvisualization_location_safe'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='tableauserver', | ||
name='get_reports_using_role', | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.RunPython(_move_ff_to_setting, reverse_code=noop), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2485,11 +2485,9 @@ def _commtrackify(domain_name, toggle_is_enabled): | |
EMBED_TABLEAU_REPORT_BY_USER = StaticToggle( | ||
'embed_tableau_report_by_user', | ||
'Use a Tableau username "HQ/{username}" to embed reports instead of "HQ/{role name}"', | ||
TAG_INTERNAL, | ||
TAG_DEPRECATED, | ||
namespaces=[NAMESPACE_DOMAIN], | ||
description='By default, a Tableau username "HQ/{role name}" is sent to Tableau to get the embedded report. ' | ||
'Turn on this flag to instead send "HQ/{the user\'s HQ username}", i.e. "HQ/[email protected]", ' | ||
'to Tableau to get the embedded report.', | ||
description='This flag is now deprecated and will be removed.', | ||
parent_toggles=[EMBEDDED_TABLEAU] | ||
) | ||
|
||
|
@@ -2510,7 +2508,7 @@ def _commtrackify(domain_name, toggle_is_enabled): | |
Each time a user is added/deleted/updated on HQ, an equivalent Tableau user with the username "HQ/{username}" | ||
will be added/deleted/updated on the linked Tableau server. | ||
""", | ||
parent_toggles=[EMBED_TABLEAU_REPORT_BY_USER], | ||
parent_toggles=[EMBEDDED_TABLEAU], | ||
help_link='https://confluence.dimagi.com/display/USH/Tableau+User+Syncing', | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters