Skip to content
Snippets Groups Projects
Commit 48d8b751 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by Alexander Pace
Browse files

Updating web interface for creating contacts and notifications.

parent c416b9b2
No related branches found
No related tags found
No related merge requests found
...@@ -13,15 +13,4 @@ ...@@ -13,15 +13,4 @@
<input type="submit" value="Submit"/> <input type="submit" value="Submit"/>
</form> </form>
{% if creating == 'Notification' %}
<p> <b>NOTE:</b>
For the label query, label names can be combined with binary AND: '&amp;' or ','; or binary OR: '|'.
For N labels, there must be exactly N-1 binary operators. (Parentheses are not
allowed.) Additionally, any of the labels in a query string can be negated with
'~' or '-'. Labels can either be selected with the select box at the top, or a query
can be specified, <i>but not both</i>.
</p>
{% endif %}
{% endblock %} {% endblock %}
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}Options | Notifications{% endblock %} {% block title %}Options | Notifications{% endblock %}
{% block heading %}Notifications (LVC Users){% endblock %} {% block heading %}<!-- leave heading blank -->{% endblock %}
{% block pageid %}userprofile{% endblock %} {% block pageid %}userprofile{% endblock %}
{% block content %} {% block content %}
{% for trigger in triggers %}
<ul>
<li>
<!-- <a href="{% url "userprofile-edit" trigger.id %}">Edit</a> -->
<a href="{% url "userprofile-delete" trigger.id %}">Delete</a>
{{ trigger.userlessDisplay }}
</li>
</ul>
{% endfor %}
<a href="{% url "userprofile-create" %}">Create New Notification (LVC users)</a>
<br/><br/>
<h2>Contacts (LVC Users)</h2> <h2>Contacts (LVC Users)</h2>
{% for contact in contacts %} {% for contact in contacts %}
<ul> <ul>
...@@ -33,6 +20,20 @@ ...@@ -33,6 +20,20 @@
<a href="{% url "userprofile-create-contact" %}">Create New Contact</a> <a href="{% url "userprofile-create-contact" %}">Create New Contact</a>
<br/><br/> <br/><br/>
<h2>Notifications (LVC Users)</h2>
{% for trigger in triggers %}
<ul>
<li>
<!-- <a href="{% url "userprofile-edit" trigger.id %}">Edit</a> -->
<a href="{% url "userprofile-delete" trigger.id %}">Delete</a>
{{ trigger.userlessDisplay }}
</li>
</ul>
{% endfor %}
<a href="{% url "userprofile-create" %}">Create New Notification (LVC users)</a>
<br/><br/>
<h2>Passwords for Scripted Access (LV-EM users)</h2> <h2>Passwords for Scripted Access (LV-EM users)</h2>
<a href="{% url "userprofile-manage-password" %}">Manage Password</a> <a href="{% url "userprofile-manage-password" %}">Manage Password</a>
......
...@@ -7,17 +7,21 @@ from gracedb.pyparsing import ParseException ...@@ -7,17 +7,21 @@ from gracedb.pyparsing import ParseException
def triggerFormFactory(postdata=None, user=None): def triggerFormFactory(postdata=None, user=None):
class TF(forms.ModelForm): class TF(forms.ModelForm):
farThresh = forms.FloatField(label='FAR Threshold (Hz)', required=False, farThresh = forms.FloatField(label='FAR Threshold (Hz)', required=False,
help_text="Leave blank to recieve all events, regardless of FAR.") help_text="Leave blank to receive all events, regardless of FAR.")
class Meta: class Meta:
model = Trigger model = Trigger
exclude = ['user', 'triggerType'] fields = ['contacts', 'pipelines', 'farThresh', 'labels', 'label_query']
widgets = {'label_query': forms.TextInput(attrs={'size': 50})} widgets = {'label_query': forms.TextInput(attrs={'size': 50})}
help_texts = {
'label_query': 'Label names can be combined with binary AND: \'&amp;\' or \',\'; or binary OR: \'|\'. For N labels, there must be exactly N-1 binary operators. Parentheses are not allowed. Additionally, any of the labels in a query string can be negated with \'~\' or \'-\'. Labels can either be selected with the select box at the top, or a query can be specified, <i>but not both</i>.'
}
contacts = forms.ModelMultipleChoiceField( contacts = forms.ModelMultipleChoiceField(
queryset=Contact.objects.filter(user=user), queryset=Contact.objects.filter(user=user),
required=False required=False,
) help_text="If blank, go back and create a Contact first.")
# XXX should probably override is_valid and check for # XXX should probably override is_valid and check for
# truth of (atypes or labels) # truth of (atypes or labels)
# and set field error attributes appropriately. # and set field error attributes appropriately.
...@@ -38,12 +42,16 @@ def triggerFormFactory(postdata=None, user=None): ...@@ -38,12 +42,16 @@ def triggerFormFactory(postdata=None, user=None):
else: else:
return TF() return TF()
# 11/29/2016 (TP): pretty sure this is deprecated in favor of
# triggerFormFactory; may remove at a later date.
class TriggerForm(forms.ModelForm): class TriggerForm(forms.ModelForm):
class Meta: class Meta:
model = Trigger model = Trigger
exclude = ['user', 'triggerType'] exclude = ['user', 'triggerType']
class ContactForm(forms.ModelForm): class ContactForm(forms.ModelForm):
desc = forms.CharField(label='Description')
class Meta: class Meta:
model = Contact model = Contact
fields = ['desc','email','phone'] fields = ['desc','email','phone']
......
...@@ -85,6 +85,6 @@ class Trigger(models.Model): ...@@ -85,6 +85,6 @@ class Trigger(models.Model):
"|".join([a.name for a in self.pipelines.all()]) or "any pipeline", "|".join([a.name for a in self.pipelines.all()]) or "any pipeline",
label_disp, label_disp,
thresh, thresh,
",".join([x.desc for x in self.contacts.all()]) ", ".join([x.desc for x in self.contacts.all()])
) )
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