Skip to content
Snippets Groups Projects
Commit 399d0155 authored by Brian Moe's avatar Brian Moe
Browse files

Basic tag functionality.

cli_tag, non-functional form drop-down, show tags on event detail page.
parent a0d21e64
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,8 @@
from django import forms
from models import Event, User, Group
from tagging.models import Tag
class CreateEventForm(forms.Form):
groupChoices = [("","")]+[(g.name, g.name) for g in Group.objects.all()]
typeChoices= [("","")]+list(Event.ANALYSIS_TYPE_CHOICES)
......@@ -17,6 +19,8 @@ class EventSearchForm(forms.Form):
submitterList = User.objects.filter(id__in=submitterIds).order_by('name')
submitterChoices = [("","")]+ [ (u.id, u.name) for u in submitterList]
tagChoices = [(tag.name,tag.name) for tag in Tag.objects.all()]
graceidStart = forms.CharField(required=False)
graceidEnd = forms.CharField(required=False)
group = forms.ChoiceField(choices=groupChoices, required=False)
......@@ -25,6 +29,8 @@ class EventSearchForm(forms.Form):
gpsEnd = forms.IntegerField(min_value=0, required=False, label="GPS End")
submitter = forms.ChoiceField(choices=submitterChoices, required=False)
tags = forms.ChoiceField(choices=tagChoices, required=False)
ligoApproved = forms.BooleanField(initial=False, required=False, label="LIGO Approved Only")
virgoApproved = forms.BooleanField(initial=False, required=False, label="Virgo Approved Only")
......@@ -6,6 +6,7 @@ import os
from tagging.fields import TagField
from tagging.models import Tag
from tagging.utils import get_tag_list
from gracedb.ligolw.models import CoincEvent
......@@ -68,6 +69,11 @@ class Event(models.Model):
def get_tags(self):
return Tag.objects.get_for_object(self)
def add_tag(self, tag, must_already_exist=True):
if must_already_exist and not get_tag_list(tag):
raise ValueError("Tag '%s' does not exist." % tag)
Tag.objects.add_tag(self, tag)
class Meta:
ordering = ["-id"]
......
......@@ -242,6 +242,21 @@ def upload(request):
response['Content-length'] = len(msg)
return response
def cli_tag(request):
graceid = request.POST.get('graceid')
tagname = request.POST.get('tag')
event = graceid and Event.getByGraceid(graceid)
event.add_tag(tagname)
msg = str({})
response = HttpResponse(mimetype='application/json')
response.write(msg)
response['Content-length'] = len(msg)
return response
def log(request):
message = request.POST.get('message')
graceid = request.POST.get('graceid')
......
......@@ -24,6 +24,11 @@
<tr><th>Sumitter</th><td>{{ object.submitter.name }}</td></tr>
<tr><th>Created</th><td>{{ object.created|utc }}
</td></tr>
<tr><th>Tags</th><td>
{% for tag in object.get_tags %}
{{ tag.name }}
{% endfor %}
</td></tr>
</table>
{% if object.eventlog_set.count %}
......
......@@ -18,6 +18,7 @@ urlpatterns = patterns('',
(r'^cli/ping', 'gracedb.gracedb.views.ping'),
(r'^cli/log', 'gracedb.gracedb.views.log'),
(r'^cli/upload', 'gracedb.gracedb.views.upload'),
(r'^cli/tag', 'gracedb.gracedb.views.cli_tag'),
#(r'^cli/ping/(?P<arg>.*)', 'gracedb.gracedb.views.ping'),
(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed',
{'feed_dict': feeds}),
......
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