diff --git a/gracedb/api.py b/gracedb/api.py index 3ee2cb802716170c76b436ba9bb93592753ad149..c8b1ad78a9d17bcf3ce033b58922d0a53dfe90a6 100644 --- a/gracedb/api.py +++ b/gracedb/api.py @@ -12,6 +12,7 @@ from django.db import IntegrityError import json from gracedb.models import Event, Group, EventLog, Tag +from gracedb.models import EMFacility, EMBBEventLog, EMSPECTRUM from gracedb.views import create_label, get_performance_info from gracedb.views import create_eel from translator import handle_uploaded_data @@ -26,8 +27,6 @@ import shutil import exceptions import pytz -import logging - from utils.vfile import VersionedFile ################################################################## @@ -987,9 +986,8 @@ class EventLogDetail(APIView): #================================================================== # EMBBEventLog (EEL) -# FIXME -# Eel serializer. +# EEL serializer. def embbEventLogToDict(eel, request=None): uri = None if request: @@ -1374,7 +1372,7 @@ class GracedbRoot(APIView): log = reverse("eventlog-list", args=["G1200"], request=request) log = log.replace("G1200", "{graceid}") embb = reverse("embbeventlog-list", args=["G1200"], request=request) - embb = log.replace("G1200", "{graceid}") + embb = embb.replace("G1200", "{graceid}") files = reverse("files", args=["G1200", "filename"], request=request) files = files.replace("G1200", "{graceid}") @@ -1420,6 +1418,10 @@ class GracedbRoot(APIView): "templates" : templates, "groups" : [group.name for group in Group.objects.all()], "analysis-types" : dict(Event.ANALYSIS_TYPE_CHOICES), + "em-facilities" : [f.shortName for f in EMFacility.objects.all()], + "wavebands" : dict(EMSPECTRUM), + "eel-statuses" : dict(EMBBEventLog.EEL_STATUS_CHOICES), + "obs-statuses" : dict(EMBBEventLog.OBS_STATUS_CHOICES), }) ################################################################## diff --git a/gracedb/models.py b/gracedb/models.py index 7c3dcacc0a689c21eeae9d2a540cbcda721d9876..c9513865793c18ba7c892d0a24e0407939d445d8 100644 --- a/gracedb/models.py +++ b/gracedb/models.py @@ -10,7 +10,6 @@ import datetime import thread import string import os -import logging import glue import glue.ligolw @@ -19,8 +18,6 @@ import glue.ligolw.table import glue.ligolw.lsctables from glue.lal import LIGOTimeGPS -log = logging.getLogger('gracedb.models') - # XXX ER2.utils. utils is in project directory. ugh. from utils import posixToGpsTime @@ -423,7 +420,7 @@ class EMBBEventLog(models.Model): if not success: # XXX Should this be a custom exception? That way we could catch it # in the views that use it and give an informative error message. - raise Exception("Too many attempts to save log message. Something is wrong.") + raise Exception("Too many attempts to save EMBB entry. Something is wrong.") class Labelling(models.Model): event = models.ForeignKey(Event) diff --git a/gracedb/views.py b/gracedb/views.py index 1a0eb356ce582a8d0d8abdc3e7c627e3ac7cf178..b983692a785c0b56c12e0f702b6d1f7c728f716b 100644 --- a/gracedb/views.py +++ b/gracedb/views.py @@ -1327,10 +1327,7 @@ def create_eel(d, event, user): raise ValueError('Please specify a facility') # Assign a facility-specific footprint ID (if provided) - try: - eel.footprintID = d.get('footprintID') - except: - eel.footprintID = None + eel.footprintID = d.get('footprintID', '') # Assign the EM spectrum string try: @@ -1358,8 +1355,8 @@ def create_eel(d, event, user): except: raise ValueError('Please specify an observation status.') - eel.extra_info_dict = d.get('extra_info_dict', None) - eel.comment = d.get('comment', None) + eel.extra_info_dict = d.get('extra_info_dict', '') + eel.comment = d.get('comment', '') eel.save() # A view to create embb log entries