Maintenance will be performed on git.ligo.org, chat.ligo.org, containers.ligo.org, and docs.ligo.org on Tuesday 22nd September 2020 starting at approximately 9am MST.It is expected to take around 15 minutes and there will be a short period of downtime towards the end of the maintenance window. Please address any comments, questions, or concerns to computing-help@igwn.org.

Commit 695d3d25 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB

events: delete old form processing view for updating grbevents

parent afa8b10a
......@@ -473,76 +473,6 @@ class TestEventNeighborsView(EventSetup, GraceDbTestBase):
self.assertEqual(response.status_code, 403)
class TestEventModifyT90(EventSetup, GraceDbTestBase):
@classmethod
def setUpTestData(cls):
super(TestEventModifyT90, cls).setUpTestData()
# Create a grb event
ext_group = Group.objects.create(name='External')
fermi_pipeline = Pipeline.objects.create(name='Fermi')
grb_search = Search.objects.create(name='GRB')
cls.grb_event = GrbEvent.objects.create(group=ext_group,
pipeline=fermi_pipeline, search=grb_search,
submitter=cls.internal_user)
ctype = ContentType.objects.get_for_model(GrbEvent)
perm = Permission.objects.create(codename='view_grbevent',
content_type=ctype)
assign_default_event_perms(cls.grb_event)
@classmethod
def setUpClass(cls):
super(TestEventModifyT90, cls).setUpClass()
cls.t90_data = {
'redshift': 2,
}
def test_basic_internal_user_t90(self):
"""Basic internal user can't t90 GRB events"""
url = reverse('modify_t90', args=[self.grb_event.graceid])
response = self.request_as_user(url, "POST", self.internal_user,
data=self.t90_data)
self.assertEqual(response.status_code, 403)
self.assertEqual(response.content,
"You aren't authorized to modify GRB attributes.")
def test_privileged_internal_user_t90(self):
"""Privileged internal user can t90 GRB events"""
# Create permission and give to user
ctype = ContentType.objects.get_for_model(GrbEvent)
perm = Permission.objects.create(codename='t90_grbevent',
content_type=ctype)
perm.user_set.add(self.internal_user)
# Make request and check response
url = reverse('modify_t90', args=[self.grb_event.graceid])
response = self.request_as_user(url, "POST", self.internal_user,
data=self.t90_data)
# 302 response code means success since we were redirected to the
# event page
self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, reverse('view',
args=[self.grb_event.graceid]))
self.grb_event.refresh_from_db()
self.assertEqual(self.grb_event.redshift, self.t90_data['redshift'])
def test_lvem_user_t90(self):
"""LV-EM user can't t90 GRB events"""
url = reverse('modify_t90', args=[self.grb_event.graceid])
response = self.request_as_user(url, "POST", self.lvem_user,
data=self.t90_data)
self.assertEqual(response.status_code, 403)
self.assertEqual(response.templates[0].name, '403.html')
def test_public_user_t90(self):
"""Public user can't t90 GRB events"""
url = reverse('modify_t90', args=[self.grb_event.graceid])
response = self.request_as_user(url, "POST", data=self.t90_data)
self.assertEqual(response.status_code, 403)
self.assertEqual(response.templates[0].name, '403.html')
class TestEventModifyPermissions(EventSetup, GraceDbTestBase):
@classmethod
......
......@@ -26,9 +26,6 @@ urlpatterns = [
'(,(?P<delta2>[-+]?\d+)\)?)?/$'), views.neighbors, name="neighbors"),
# Form processing ---------------------------------------------------------
# Modify t90
url(r'^(?P<graceid>[GEHMT]\d+)/t90/$', views.modify_t90,
name="modify_t90"),
# Modify permissions
url(r'^(?P<graceid>[GEHMT]\d+)/perms/$', views.modify_permissions,
name="modify_permissions"),
......
......@@ -754,41 +754,6 @@ def emobservation_entry(request, event, num=None):
else:
return HttpResponseBadRequest("This URL only supports POST.")
#
# Despite the name, this view function will handle updates to all of the
# hand-entered GRB data, including t90, redshift, and event designation.
#
@event_and_auth_required
def modify_t90(request, event):
if not request.method=='POST':
msg = 'This URL only allows POST.'
return HttpResponseBadRequest(msg)
if not isinstance(event, GrbEvent):
msg = 'This method only works on GrbEvent objects.'
return HttpResponseBadRequest(msg)
if not request.user.has_perm('events.t90_grbevent'):
msg = "You aren't authorized to modify GRB attributes."
return HttpResponseForbidden(msg)
designation = request.POST.get('designation', None)
redshift = request.POST.get('redshift', None)
t90 = request.POST.get('t90', None)
if not (t90 or designation or redshift):
msg = 'This method requires one of: designation, redshift, or t90 in POST.'
return HttpResponseBadRequest(msg)
if t90:
event.t90 = t90
elif redshift:
event.redshift = redshift
elif designation:
event.designation = designation
event.save()
# Finished. Redirect back to the event.
return HttpResponseRedirect(reverse("view", args=[event.graceid]))
def get_signoff_type(stype):
for t in Signoff.SIGNOFF_TYPE_CHOICES:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment