Skip to content

Commit

Permalink
Remove unused option on assets endpoint to return environment
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Apr 2, 2024
1 parent 001b961 commit 1797c41
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 32 deletions.
23 changes: 0 additions & 23 deletions temba/flows/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5485,29 +5485,6 @@ def test_list(self):


class AssetServerTest(TembaTest):
def test_environment(self):
self.login(self.admin)

date_formats = {"D": "DD-MM-YYYY", "M": "MM-DD-YYYY", "Y": "YYYY-MM-DD"}

for org_date_format, date_format in date_formats.items():
self.org.date_format = org_date_format
self.org.save()

response = self.client.get("/flow/assets/%d/1234/environment/" % self.org.id)
self.assertEqual(
response.json(),
{
"date_format": date_format,
"time_format": "tt:mm",
"timezone": "Africa/Kigali",
"allowed_languages": ["eng", "kin"],
"default_country": "RW",
"redaction_policy": "none",
"input_collation": "default",
},
)

def test_languages(self):
self.login(self.admin)
response = self.client.get("/flow/assets/%d/1234/language/" % self.org.id)
Expand Down
12 changes: 4 additions & 8 deletions temba/flows/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1720,12 +1720,12 @@ def form_valid(self, form):

class Assets(OrgPermsMixin, SmartTemplateView):
"""
Provides environment and languages to the new editor
TODO update editor to use API endpoint instead of this
"""

@classmethod
def derive_url_pattern(cls, path, action):
return rf"^{path}/{action}/(?P<org>\d+)/(?P<fingerprint>[\w-]+)/(?P<type>environment|language)/((?P<uuid>[a-z0-9-]{{36}})/)?$"
return rf"^{path}/{action}/(?P<org>\d+)/(?P<fingerprint>[\w-]+)/(?P<type>language)/((?P<uuid>[a-z0-9-]{{36}})/)?$"

def derive_org(self):
if not hasattr(self, "org"):
Expand All @@ -1734,13 +1734,9 @@ def derive_org(self):

def get(self, *args, **kwargs):
org = self.derive_org()
asset_type_name = kwargs["type"]

if asset_type_name == "environment":
return JsonResponse(org.as_environment_def())
else:
results = [{"iso": code, "name": languages.get_name(code)} for code in org.flow_languages]
return JsonResponse({"results": sorted(results, key=lambda lang: lang["name"])})
results = [{"iso": code, "name": languages.get_name(code)} for code in org.flow_languages]
return JsonResponse({"results": sorted(results, key=lambda lang: lang["name"])})


# this is just for adhoc testing of the preprocess url
Expand Down
1 change: 0 additions & 1 deletion templates/flows/flow_editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@
recents: '/flow/recent_contacts/{{object.uuid}}/',
attachments: '{% url "msgs.media_upload" %}',
languages: base + 'language',
environment: base + 'environment',
activity: '/flow/activity/{{object.uuid}}/',
recipients: '/contact/omnibox?v=2&types=gc',
contacts: '/contact/omnibox?v=2&types=c',
Expand Down

0 comments on commit 1797c41

Please sign in to comment.