Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GraceDB Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael Coughlin
GraceDB Server
Commits
005bd722
Commit
005bd722
authored
7 years ago
by
Tanner Prestegard
Committed by
gracedb-dev1
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
updating notification creation interface
parent
a8b561f0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
userprofile/forms.py
+13
-3
13 additions, 3 deletions
userprofile/forms.py
userprofile/models.py
+6
-4
6 additions, 4 deletions
userprofile/models.py
userprofile/views.py
+7
-16
7 additions, 16 deletions
userprofile/views.py
with
26 additions
and
23 deletions
userprofile/forms.py
+
13
−
3
View file @
005bd722
...
...
@@ -31,8 +31,9 @@ def triggerFormFactory(postdata=None, user=None):
contacts
=
forms
.
ModelMultipleChoiceField
(
queryset
=
Contact
.
objects
.
filter
(
user
=
user
),
required
=
False
,
help_text
=
"
If blank, go back and create a Contact first.
"
)
required
=
True
,
help_text
=
"
If this box is empty, go back and create a contact first.
"
,
error_messages
=
{
'
required
'
:
'
You must specify at least one contact.
'
})
# XXX should probably override is_valid and check for
# truth of (atypes or labels)
...
...
@@ -41,12 +42,21 @@ def triggerFormFactory(postdata=None, user=None):
def
clean
(
self
):
cleaned_data
=
super
(
TF
,
self
).
clean
()
label_query
=
self
.
cleaned_data
[
'
label_query
'
]
if
(
self
.
cleaned_data
[
'
label_query
'
]
and
self
.
cleaned_data
[
'
labels
'
]):
raise
forms
.
ValidationError
(
'
Cannot specify labels and label query, choose one or the other.
'
)
if
not
(
self
.
cleaned_data
[
'
labels
'
]
or
self
.
cleaned_data
[
'
pipelines
'
]):
raise
forms
.
ValidationError
(
'
Choose labels and/or pipelines for this notification.
'
)
if
len
(
label_query
)
>
0
:
# now try parsing it
try
:
parseLabelQuery
(
label_query
)
except
ParseException
:
raise
forms
.
ValidationError
(
"
Invalid label query.
"
)
raise
forms
.
ValidationError
(
{
'
label_query
'
:
'
Invalid label query.
'
}
)
return
cleaned_data
if
postdata
is
not
None
:
...
...
This diff is collapsed.
Click to expand it.
userprofile/models.py
+
6
−
4
View file @
005bd722
...
...
@@ -6,6 +6,8 @@ from gracedb.models import Label, Pipeline
from
django.core.exceptions
import
ValidationError
from
django.contrib.auth.models
import
User
import
phonenumbers
import
logging
log
=
logging
.
getLogger
(
__name__
)
def
validate_phone
(
value
):
try
:
...
...
@@ -81,14 +83,14 @@ class Contact(models.Model):
self
.
call_phone
,
self
.
text_phone
))
class
Trigger
(
models
.
Model
):
# TP 6 Jul 2017: TYPES and triggerType don't seem to be used anywhere...
TYPES
=
(
(
"
create
"
,
"
create
"
),
(
"
change
"
,
"
change
"
),
(
"
label
"
,
"
label
"
)
)
user
=
models
.
ForeignKey
(
User
,
null
=
False
)
#new_user = models.ForeignKey(DjangoUser, null=True)
triggerType
=
models
.
CharField
(
max_length
=
20
,
choices
=
TYPES
,
blank
=
True
)
user
=
models
.
ForeignKey
(
User
,
null
=
False
)
labels
=
models
.
ManyToManyField
(
Label
,
blank
=
True
)
#atypes = models.ManyToManyField(AnalysisType, blank=True, verbose_name="Analysis Types")
pipelines
=
models
.
ManyToManyField
(
Pipeline
,
blank
=
True
)
contacts
=
models
.
ManyToManyField
(
Contact
,
blank
=
Tru
e
)
contacts
=
models
.
ManyToManyField
(
Contact
,
blank
=
Fals
e
)
farThresh
=
models
.
FloatField
(
blank
=
True
,
null
=
True
)
label_query
=
models
.
CharField
(
max_length
=
100
,
blank
=
True
)
...
...
This diff is collapsed.
Click to expand it.
userprofile/views.py
+
7
−
16
View file @
005bd722
...
...
@@ -19,7 +19,7 @@ import logging
log
=
logging
.
getLogger
(
__name__
)
from
.models
import
Trigger
,
Contact
from
.forms
import
ContactForm
,
triggerFormFactory
from
.forms
import
ContactForm
,
triggerFormFactory
,
TriggerForm
from
gracedb.permission_utils
import
internal_user_required
,
lvem_user_required
from
gracedb.query
import
labelQuery
from
gracedb.models
import
Label
...
...
@@ -86,15 +86,9 @@ def create(request):
farThresh
=
form
.
cleaned_data
[
'
farThresh
'
]
label_query
=
form
.
cleaned_data
[
'
label_query
'
]
if
len
(
label_query
)
>
0
and
labels
.
count
()
>
0
:
msg
=
"
Cannot both select labels and define label query. Choose one or the other.
"
return
HttpResponseBadRequest
(
msg
)
# If we've got a label query defined for this trigger, then we want
# each label mentioned in the query to be listed in the events labels.
# It would be smarter to make sure the label isn't being negated, but
# we can just leave that for later.
if
len
(
label_query
)
>
0
:
toks
=
labelQuery
(
label_query
,
names
=
True
)
...
...
@@ -121,15 +115,12 @@ def create(request):
request
.
session
[
'
flash_msg
'
]
=
"
Created: %s
"
%
t
.
userlessDisplay
()
return
HttpResponseRedirect
(
reverse
(
index
))
# Data was bad
try
:
if
not
contacts
:
message
+=
"
You must specify at least one contact.
"
if
not
(
labels
or
pipelines
):
message
+=
"
You need to indicate label(s) and/or pipeline(s).
"
except
NameError
:
# form is not valid, so labels, contacts and pipelines were not set.
# hopefully, there are error messages in the form.
pass
else
:
# Get non-field errors and display them in the message box.
# Remove them from the form so they don't display in the table too.
while
form
.
errors
[
'
__all__
'
]:
message
+=
form
.
errors
[
'
__all__
'
].
pop
().
message
else
:
form
=
triggerFormFactory
(
user
=
request
.
user
)
if
message
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment