diff --git a/gracedb/events/view_logic.py b/gracedb/events/view_logic.py index 31b9eb51f95757681210cb4f5899bb973ae00318..9e496d29f134dcb4e0758a987c470a802c4baa82 100644 --- a/gracedb/events/view_logic.py +++ b/gracedb/events/view_logic.py @@ -22,10 +22,11 @@ from core.vfile import VersionedFile from django.contrib.contenttypes.models import ContentType from django.contrib.auth.models import Permission from django.contrib.auth.models import Group as AuthGroup +from django.conf import settings from guardian.models import GroupObjectPermission import os -from django.conf import settings +import six import json import datetime @@ -492,7 +493,7 @@ def create_eel(d, event, user): # # Create an EMBB Observaton Record # -def create_emobservation(request, event): +def create_emobservation(request, event): d = getattr(request, 'data', None) if not d: d = getattr(request, 'POST', None) @@ -532,6 +533,19 @@ def create_emobservation(request, event): except Exception, e: raise ValueError('Lacking input: %s' % str(e)) + # Handle case where comma-separated strings are submitted rather than lists + if isinstance(raList, six.string_types): + raList = map(lambda x: float(x.strip()), raList.split(',')) + if isinstance(raWidthList, six.string_types): + raWidthList = map(lambda x: float(x.strip()), raWidthList.split(',')) + if isinstance(decList, six.string_types): + decList = map(lambda x: float(x.strip()), decList.split(',')) + if isinstance(decWidthList, six.string_types): + decWidthList = map(lambda x: float(x.strip()), decWidthList.split(',')) + if isinstance(startTimeList, six.string_types): + startTimeList = map(lambda x: x.strip(), startTimeList.split(',')) + if isinstance(durationList, six.string_types): + durationList = map(lambda x: int(x.strip()), durationList.split(',')) all_lists = (raList, raWidthList, decList, decWidthList, startTimeList, durationList) diff --git a/gracedb/templates/gracedb/emo_form_frag.html b/gracedb/templates/gracedb/emo_form_frag.html index d24281301e85bed94d75457512cdcec3f159b783..f832de1edbec220b9b8de3d73859888e5c78d986 100644 --- a/gracedb/templates/gracedb/emo_form_frag.html +++ b/gracedb/templates/gracedb/emo_form_frag.html @@ -30,24 +30,24 @@ Which MOU Group provides this report?</a></td> <td><select name="group"> {% endfor %} </select> </td> </tr> <tr><td><a href=# onclick="alert('RA and Dec specify a center point of a rectangle that is aligned equatorially. Or list of centers. They must be in decimal degrees 0<=RA<=360 -90<=Dec<=90, in the J2000 frame.');return false;"> -RA (decimal degrees)</a></td> <td><input type="text" name="raList" value="" size=80/></td></tr> +RA (decimal degrees)</a></td> <td><input type="text" name="ra_list" value="" size=80/></td></tr> <tr><td><a href=# onclick="alert('RA and Dec specify a center point of a rectangle that is aligned equatorially. Or list of centers. They must be in decimal degrees 0<=RA<=360 -90<=Dec<=90, in the J2000 frame.');return false;"> -Dec (decimal degrees)</a></td> <td><input type="text" name="decList" value="" size=80/></td></tr> +Dec (decimal degrees)</a></td> <td><input type="text" name="dec_list" value="" size=80/></td></tr> <tr><td><a href=# onclick="alert('RAWidth and DecWidth specify the size of a a rectangle that is aligned equatorially. Thus the edge of the box is distant from the center by half of the width.');return false;"> -RAwidth (decimal degrees)</a></td> <td><input type="text" name="raWidthList" value=""/></td></tr> +RAwidth (decimal degrees)</a></td> <td><input type="text" name="ra_width_list" value=""/></td></tr> <tr><td><a href=# onclick="alert('RAWidth and DecWidth specify the size of a a rectangle that is aligned equatorially. Thus the edge of the box is distant from the center by half of the width.');return false;"> -Decwidth (decimal degrees)</a></td> <td><input type="text" name="decWidthList" value=""/></td></tr> +Decwidth (decimal degrees)</a></td> <td><input type="text" name="dec_width_list" value=""/></td></tr> <tr><td><a href=# onclick="alert('The time at the beginning of a time interval during which the observation was taken. Or list of times. UTC in ISO 8601 format.');return false;"> StartTime</a></td> -<td><input type="text" name="startTimeList" value="" size=80/></td> +<td><input type="text" name="start_time_list" value="" size=80/></td> </tr> <tr><td><a href=# onclick="alert('This is the on-source exposure time in seconds (or the duration of the observation).');return false;"> -On source exposure (seconds)</a></td> <td><input type="text" name="durationList" value=""/></td></tr> +On source exposure (seconds)</a></td> <td><input type="text" name="duration_list" value=""/></td></tr> <tr><td><a href=# onclick="alert('A natural language report.');return false;"> Report as text</a></td> <td colspan=2><textarea name="comment" rows="8" cols="50"></textarea></td></tr>