Repository: ietf-tools/datatracker

Issue:
Get rid of ajax call for timezone conversion
### Describe the issue

The interim request page makes an ajax call to the `ajax_get_utc()` view to convert a time/date/timezone into UTC. This is unnecessary - should lose the view and do the conversion directly in JS using luxon (or moment, I suppose).

### Code of Conduct

- [X] I agree to follow the [IETF's Code of Conduct](https://github.com/ietf-tools/.github/blob/main/CODE_OF_CONDUCT.md)


Discussion:

Resolving patch:
diff --git a/ietf/meeting/urls.py b/ietf/meeting/urls.py
--- a/ietf/meeting/urls.py
+++ b/ietf/meeting/urls.py
@@ -113,7 +113,6 @@ def get_redirect_url(self, *args, **kwargs):
 urlpatterns = [
     # First patterns which start with unique strings
     url(r'^$', views.current_materials),
-    url(r'^ajax/get-utc/?$', views.ajax_get_utc),
     url(r'^interim/announce/?$', views.interim_announce),
     url(r'^interim/announce/(?P<number>[A-Za-z0-9._+-]+)/?$', views.interim_send_announcement),
     url(r'^interim/skip_announce/(?P<number>[A-Za-z0-9._+-]+)/?$', views.interim_skip_announcement),
diff --git a/ietf/meeting/views.py b/ietf/meeting/views.py
--- a/ietf/meeting/views.py
+++ b/ietf/meeting/views.py
@@ -3029,43 +3029,6 @@ def delete_schedule(request, num, owner, name):
 # -------------------------------------------------
 # Interim Views
 # -------------------------------------------------
-
-
-def ajax_get_utc(request):
-    '''Ajax view that takes arguments time, timezone, date and returns UTC data'''
-    time = request.GET.get('time')
-    timezone = request.GET.get('timezone')
-    date = request.GET.get('date')
-    time_re = re.compile(r'^\d{2}:\d{2}$')
-    # validate input
-    if not time_re.match(time) or not date:
-        return HttpResponse(json.dumps({'error': True}),
-                            content_type='application/json')
-    hour, minute = time.split(':')
-    if not (int(hour) <= 23 and int(minute) <= 59):
-        return HttpResponse(json.dumps({'error': True}),
-                            content_type='application/json')
-    year, month, day = date.split('-')
-    dt = datetime.datetime(int(year), int(month), int(day), int(hour), int(minute))
-    tz = pytz.timezone(timezone)
-    aware_dt = tz.localize(dt, is_dst=None)
-    utc_dt = aware_dt.astimezone(pytz.utc)
-    utc = utc_dt.strftime('%H:%M')
-    # calculate utc day offset
-    naive_utc_dt = utc_dt.replace(tzinfo=None)
-    utc_day_offset = (naive_utc_dt.date() - dt.date()).days
-    html = "<span>{utc} UTC</span>".format(utc=utc)
-    if utc_day_offset != 0:
-        html = html + '<span class="day-offset"> {0:+d} Day</span>'.format(utc_day_offset)
-    context_data = {'timezone': timezone, 
-                    'time': time, 
-                    'utc': utc, 
-                    'utc_day_offset': utc_day_offset,
-                    'html': html}
-    return HttpResponse(json.dumps(context_data),
-                        content_type='application/json')
-
-
 def interim_announce(request):
     '''View which shows interim meeting requests awaiting announcement'''
     meetings = data_for_meetings_overview(Meeting.objects.filter(type='interim').order_by('date'), interim_status='scheda')


Test patch:
diff --git a/ietf/meeting/tests_views.py b/ietf/meeting/tests_views.py
--- a/ietf/meeting/tests_views.py
+++ b/ietf/meeting/tests_views.py
@@ -5800,35 +5800,6 @@ def test_group_ical(self):
         self.assertContains(r, 'END:VEVENT')
 
 
-class AjaxTests(TestCase):
-    def test_ajax_get_utc(self):
-        # test bad queries
-        url = urlreverse('ietf.meeting.views.ajax_get_utc') + "?date=2016-1-1&time=badtime&timezone=UTC"
-        r = self.client.get(url)
-        self.assertEqual(r.status_code, 200)
-        data = r.json()
-        self.assertEqual(data["error"], True)
-        url = urlreverse('ietf.meeting.views.ajax_get_utc') + "?date=2016-1-1&time=25:99&timezone=UTC"
-        r = self.client.get(url)
-        self.assertEqual(r.status_code, 200)
-        data = r.json()
-        self.assertEqual(data["error"], True)
-        url = urlreverse('ietf.meeting.views.ajax_get_utc') + "?date=2016-1-1&time=10:00am&timezone=UTC"
-        r = self.client.get(url)
-        self.assertEqual(r.status_code, 200)
-        data = r.json()
-        self.assertEqual(data["error"], True)
-        # test good query
-        url = urlreverse('ietf.meeting.views.ajax_get_utc') + "?date=2016-1-1&time=12:00&timezone=America/Los_Angeles"
-        r = self.client.get(url)
-        self.assertEqual(r.status_code, 200)
-        data = r.json()
-        self.assertIn('timezone', data)
-        self.assertIn('time', data)
-        self.assertIn('utc', data)
-        self.assertNotIn('error', data)
-        self.assertEqual(data['utc'], '20:00')
-
 class IphoneAppJsonTests(TestCase):
     def test_iphone_app_json_interim(self):
         make_interim_test_data()