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
0ce3be9f
Commit
0ce3be9f
authored
15 years ago
by
Brian Moe
Browse files
Options
Downloads
Patches
Plain Diff
On create notification, only user's own contacts are now displayed.
parent
51038a81
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
userprofile/forms.py
+21
-0
21 additions, 0 deletions
userprofile/forms.py
userprofile/views.py
+12
-8
12 additions, 8 deletions
userprofile/views.py
with
33 additions
and
8 deletions
userprofile/forms.py
+
21
−
0
View file @
0ce3be9f
...
...
@@ -4,6 +4,27 @@ from models import Trigger, Contact
from
django.forms.models
import
modelformset_factory
def
triggerFormFactory
(
postdata
=
None
,
user
=
None
):
class
TF
(
forms
.
ModelForm
):
class
Meta
:
model
=
Trigger
exclude
=
[
'
user
'
,
'
triggerType
'
]
contacts
=
forms
.
ModelMultipleChoiceField
(
queryset
=
Contact
.
objects
.
filter
(
user
=
user
),
required
=
False
)
# XXX should probably override is_valid and check for
# truth of (atypes or labels)
# and set field error attributes appropriately.
if
postdata
is
not
None
:
return
TF
(
postdata
)
else
:
return
TF
()
class
TriggerForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
Trigger
...
...
This diff is collapsed.
Click to expand it.
userprofile/views.py
+
12
−
8
View file @
0ce3be9f
...
...
@@ -10,7 +10,7 @@ from django.shortcuts import render_to_response
from
gracedb.userprofile.models
import
Trigger
,
Contact
from
forms
import
T
riggerForm
,
Cont
act
F
or
m
from
forms
import
ContactForm
,
t
riggerForm
F
actor
y
def
index
(
request
):
triggers
=
Trigger
.
objects
.
filter
(
user
=
request
.
ligouser
)
...
...
@@ -24,7 +24,7 @@ def create(request):
explanation
=
""
message
=
""
if
request
.
method
==
"
POST
"
:
form
=
T
riggerForm
(
request
.
POST
)
form
=
t
riggerForm
Factory
(
request
.
POST
,
user
=
request
.
ligouser
)
if
form
.
is_valid
():
# Create the Trigger
t
=
Trigger
(
user
=
request
.
ligouser
)
...
...
@@ -43,14 +43,18 @@ def create(request):
t
.
save
()
request
.
session
[
'
flash_msg
'
]
=
"
Created: %s
"
%
t
.
userlessDisplay
()
return
HttpResponseRedirect
(
reverse
(
index
))
# Data was bad
if
not
contacts
:
message
+=
"
You must specify at least one contact.
"
if
not
(
labels
or
atypes
):
message
+=
"
You need to indicate label(s) and/or analysis type(s).
"
try
:
if
not
contacts
:
message
+=
"
You must specify at least one contact.
"
if
not
(
labels
or
atypes
):
message
+=
"
You need to indicate label(s) and/or analysis type(s).
"
except
NameError
:
# form is not valid, so labels, contacts and atypes were not set.
# hopefully, there are error messages in the form.
pass
else
:
form
=
T
riggerForm
(
)
form
=
t
riggerForm
Factory
(
user
=
request
.
ligouser
)
if
message
:
request
.
session
[
'
flash_msg
'
]
=
message
return
render_to_response
(
'
profile/createNotification.html
'
,
...
...
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