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
a0208664
Commit
a0208664
authored
5 years ago
by
Tanner Prestegard
Committed by
GraceDB
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Improve display for contacts and notifications in web views
parent
7d3138f8
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
gracedb/alerts/fields.py
+6
-0
6 additions, 0 deletions
gracedb/alerts/fields.py
gracedb/alerts/forms.py
+3
-1
3 additions, 1 deletion
gracedb/alerts/forms.py
gracedb/alerts/models.py
+3
-3
3 additions, 3 deletions
gracedb/alerts/models.py
with
12 additions
and
4 deletions
gracedb/alerts/fields.py
+
6
−
0
View file @
a0208664
import
phonenumbers
from
django.db
import
models
from
django
import
forms
from
.validators
import
validate_phone
...
...
@@ -32,3 +33,8 @@ class PhoneNumberField(models.CharField):
phone
=
phonenumbers
.
parse
(
value
,
'
US
'
)
return
phonenumbers
.
format_number
(
phone
,
getattr
(
phonenumbers
.
PhoneNumberFormat
,
self
.
format
))
class
ContactMultipleChoiceField
(
forms
.
ModelMultipleChoiceField
):
def
label_from_instance
(
self
,
obj
):
return
obj
.
display
()
This diff is collapsed.
Click to expand it.
gracedb/alerts/forms.py
+
3
−
1
View file @
a0208664
...
...
@@ -16,6 +16,7 @@ from django.utils.translation import ugettext_lazy as _
from
core.forms
import
MultipleForm
from
events.models
import
Group
,
Search
,
Label
from
.fields
import
ContactMultipleChoiceField
from
.models
import
Notification
,
Contact
from
.utils
import
parse_label_query
...
...
@@ -31,6 +32,8 @@ class BaseNotificationForm(forms.ModelForm):
Base model for Notification forms. Should not be used on its own
(essentially an abstract model)
"""
contacts
=
ContactMultipleChoiceField
(
queryset
=
Contact
.
objects
.
all
(),
required
=
False
,
widget
=
forms
.
widgets
.
SelectMultiple
(
attrs
=
{
'
size
'
:
6
}))
class
Meta
:
model
=
Notification
fields
=
[
'
description
'
]
# dummy placeholder
...
...
@@ -63,7 +66,6 @@ class BaseNotificationForm(forms.ModelForm):
'
< 3.0 M<sub>sun</sub>.
'
),
}
widgets
=
{
'
contacts
'
:
forms
.
widgets
.
SelectMultiple
(
attrs
=
{
'
size
'
:
5
}),
'
far_threshold
'
:
forms
.
widgets
.
TextInput
(),
'
labels
'
:
forms
.
widgets
.
SelectMultiple
(
attrs
=
{
'
size
'
:
8
}),
}
...
...
This diff is collapsed.
Click to expand it.
gracedb/alerts/models.py
+
3
−
3
View file @
a0208664
...
...
@@ -52,8 +52,8 @@ class Contact(CleanSaveModel):
verification_expiration
=
models
.
DateTimeField
(
null
=
True
,
editable
=
False
)
def
__
unicode
__
(
self
):
return
u
"
{0}: {1}
"
.
format
(
self
.
user
.
username
,
self
.
description
)
def
__
str
__
(
self
):
return
"
{0}: {1}
"
.
format
(
self
.
user
.
username
,
self
.
description
)
def
clean
(
self
):
# Mostly used for preventing creation of bad Contact
...
...
@@ -251,6 +251,6 @@ class Notification(models.Model):
# Add contacts
output
+=
'
-> {contacts}
'
kwargs
[
'
contacts
'
]
=
\
"
,
"
.
join
([
c
.
d
escription
for
c
in
self
.
contacts
.
all
()])
"
,
"
.
join
([
c
.
d
isplay
()
for
c
in
self
.
contacts
.
all
()])
return
output
.
format
(
**
kwargs
)
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