Skip to content
Snippets Groups Projects
Commit 76a04a2e authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB
Browse files

Updating emobservation creation from web interface

Adding ability to create_emobservation to handle comma-separated
strings as input rather than lists, which is necessary for handling
input from the web form on the event pages.
parent 598182eb
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment