Skip to content

Commit

Permalink
Merge pull request #34949 from dimagi/ad/ability-to-flag-tab-reports-…
Browse files Browse the repository at this point in the history
…as-location-safe

Add the ability to flag tab reports as location-safe
  • Loading branch information
AddisonDunn authored Aug 7, 2024
2 parents 0ec4b3d + 9070474 commit cd746d5
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

{% block pagination_header %}
<h2>{% trans "Tableau Visualizations" %}</h2>
@@ -13,9 +13,9 @@
<td data-bind="text: title"></td>
@@ -14,9 +14,9 @@
<td data-bind="text: server"></td>
<td data-bind="text: view_url"></td>
<td data-bind="text: location_safe ? '{% trans 'Yes' %}' : '{% trans 'No' %}'"></td>
- <td class="col-md-1"> <!-- actions -->
+ <td class="col-lg-1"> <!-- actions -->
<button type="button"
Expand All @@ -23,7 +23,7 @@
data-bind="attr: {'data-target': '#update-tableau-visualization-' + id}"
class="btn btn-primary btn-block">
{% trans "Update" %}
@@ -24,10 +24,10 @@
@@ -25,10 +25,10 @@
data-bind="attr: {id: 'update-tableau-visualization-' + id}">
<div class="modal-dialog">
<div class="modal-content">
Expand All @@ -37,7 +37,7 @@
aria-hidden="true">&times;</button>
<h3>
{% trans "Update Tableau Visualization" %} <strong data-bind="text: name"></strong>:
@@ -40,32 +40,32 @@
@@ -41,32 +41,32 @@
</div>
</div>
</td>
Expand Down Expand Up @@ -79,7 +79,7 @@
<i class="fa fa-remove"></i> {% trans "Delete" %}
</button>
</div>
@@ -86,7 +86,7 @@
@@ -88,7 +88,7 @@
{% block pagination_footer %}
<div class="spacer"></div>
<div class="row">
Expand Down
10 changes: 10 additions & 0 deletions corehq/apps/reports/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,20 @@ class TableauVisualizationForm(forms.ModelForm):
view_url = forms.CharField(
label=_('View URL'),
)
location_safe = forms.BooleanField(
label=_('Visible to location-restricted users'),
help_text=_('If checked, the visualization will be visible to users with roles that do not have '
'"Full Organization Access"'),
required=False,
)

class Meta:
model = TableauVisualization
fields = [
'title',
'server',
'view_url',
'location_safe',
]

def __init__(self, domain, *args, **kwargs):
Expand All @@ -435,6 +442,7 @@ def helper(self):
crispy.Field('title'),
crispy.Field('server'),
crispy.Field('view_url'),
crispy.Field('location_safe'),

FormActions(
StrictButton(
Expand Down Expand Up @@ -469,6 +477,7 @@ class Meta:
'title',
'server',
'view_url',
'location_safe',
]

@property
Expand All @@ -482,6 +491,7 @@ def helper(self):
crispy.Field('title'),
crispy.Field('server'),
crispy.Field('view_url'),
crispy.Field('location_safe'),
css_class='modal-body',
),
FormActions(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.14 on 2024-08-05 18:57

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('reports', '0018_alter_tableauuser_role'),
]

operations = [
migrations.AddField(
model_name='tableauvisualization',
name='location_safe',
field=models.BooleanField(default=False),
),
]
1 change: 1 addition & 0 deletions corehq/apps/reports/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class TableauVisualization(models.Model):
server = models.ForeignKey(TableauServer, on_delete=models.CASCADE)
view_url = models.CharField(max_length=256)
upstream_id = models.CharField(max_length=32, null=True)
location_safe = models.BooleanField(default=False)

@property
def name(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ <h2>{% trans "Tableau Visualizations" %}</h2>
<td data-bind="text: title"></td>
<td data-bind="text: server"></td>
<td data-bind="text: view_url"></td>
<td data-bind="text: location_safe ? '{% trans 'Yes' %}' : '{% trans 'No' %}'"></td>
<td class="col-md-1"> <!-- actions -->
<button type="button"
data-toggle="modal"
Expand Down Expand Up @@ -79,6 +80,7 @@ <h3>
<td data-bind="text: title"></td>
<td data-bind="text: server"></td>
<td data-bind="text: view_url"></td>
<td data-bind="text: location_safe ? '{% trans 'Yes' %}' : '{% trans 'No' %}'"></td>
<td>{% trans 'Deleted' %}</td>
</script>
{% endblock %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ <h2>{% trans "Tableau Visualizations" %}</h2>
<td data-bind="text: title"></td>
<td data-bind="text: server"></td>
<td data-bind="text: view_url"></td>
<td data-bind="text: location_safe ? '{% trans 'Yes' %}' : '{% trans 'No' %}'"></td>
<td class="col-lg-1"> <!-- actions -->
<button type="button"
data-bs-toggle="modal"
Expand Down Expand Up @@ -79,6 +80,7 @@ <h3>
<td data-bind="text: title"></td>
<td data-bind="text: server"></td>
<td data-bind="text: view_url"></td>
<td data-bind="text: location_safe ? '{% trans 'Yes' %}' : '{% trans 'No' %}'"></td>
<td>{% trans 'Deleted' %}</td>
</script>
{% endblock %}
Expand Down
2 changes: 2 additions & 0 deletions corehq/apps/reports/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1904,6 +1904,7 @@ def column_names(self):
_("Title"),
_("Server"),
_("View URL"),
_("Visible to Location-Restricted Users"),
]

@property
Expand All @@ -1925,6 +1926,7 @@ def _get_item_data(self, tableau_visualization):
'title': tableau_visualization.title,
'server': tableau_visualization.server.server_name,
'view_url': tableau_visualization.view_url,
'location_safe': tableau_visualization.location_safe,
'updateForm': self.get_update_form_response(
self.get_update_form(tableau_visualization)
),
Expand Down
1 change: 1 addition & 0 deletions migrations.lock
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ reports
0016_alter_tableauuser_role
0017_alter_tableauuser_tableau_user_id
0018_alter_tableauuser_role
0019_tableauvisualization_location_safe
saved_reports
0001_initial
0002_scheduledreportlog
Expand Down

0 comments on commit cd746d5

Please sign in to comment.