Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hypha
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
ots
hypha
Commits
850f3e17
Commit
850f3e17
authored
6 years ago
by
Todd Dembrey
Browse files
Options
Downloads
Patches
Plain Diff
Add the comment creation and listing on the submission
parent
c96f3e3b
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
opentech/apply/funds/api_views.py
+34
-1
34 additions, 1 deletion
opentech/apply/funds/api_views.py
opentech/apply/funds/serializers.py
+8
-0
8 additions, 0 deletions
opentech/apply/funds/serializers.py
opentech/apply/funds/urls.py
+2
-0
2 additions, 0 deletions
opentech/apply/funds/urls.py
with
44 additions
and
1 deletion
opentech/apply/funds/api_views.py
+
34
−
1
View file @
850f3e17
...
...
@@ -8,11 +8,14 @@ from django_filters import rest_framework as filters
from
wagtail.core.models
import
Page
from
opentech.api.pagination
import
StandardResultsSetPagination
from
opentech.apply.activity.models
import
Activity
from
opentech.apply.activity.models
import
Activity
,
COMMENT
from
opentech.apply.activity.messaging
import
messenger
,
MESSAGES
from
.models
import
ApplicationSubmission
from
.models.applications
import
SubmittableStreamForm
from
.serializers
import
(
CommentSerializer
,
CommentCreateSerializer
,
RoundLabSerializer
,
SubmissionActionSerializer
,
SubmissionListSerializer
,
...
...
@@ -100,3 +103,33 @@ class CommentList(generics.ListAPIView):
def
get_queryset
(
self
):
return
super
().
get_queryset
().
visible_to
(
self
.
request
.
user
)
class
CommentListCreate
(
generics
.
ListCreateAPIView
):
queryset
=
Activity
.
comments
.
all
()
serializer_class
=
CommentCreateSerializer
permission_classes
=
(
permissions
.
IsAuthenticated
,
IsApplyStaffUser
,
)
filter_backends
=
(
filters
.
DjangoFilterBackend
,)
filter_fields
=
(
'
visibility
'
,)
pagination_class
=
StandardResultsSetPagination
def
get_queryset
(
self
):
return
super
().
get_queryset
().
filter
(
submission
=
self
.
kwargs
[
'
pk
'
]
).
visible_to
(
self
.
request
.
user
)
def
perform_create
(
self
,
serializer
):
obj
=
serializer
.
save
(
type
=
COMMENT
,
user
=
self
.
request
.
user
,
submission_id
=
self
.
kwargs
[
'
pk
'
]
)
messenger
(
MESSAGES
.
COMMENT
,
request
=
self
.
request
,
user
=
self
.
request
.
user
,
submission
=
obj
.
submission
,
related
=
obj
,
)
This diff is collapsed.
Click to expand it.
opentech/apply/funds/serializers.py
+
8
−
0
View file @
850f3e17
...
...
@@ -90,3 +90,11 @@ class CommentSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
Activity
fields
=
(
'
id
'
,
'
timestamp
'
,
'
user
'
,
'
submission
'
,
'
message
'
,
'
visibility
'
)
class
CommentCreateSerializer
(
serializers
.
ModelSerializer
):
user
=
serializers
.
StringRelatedField
()
class
Meta
:
model
=
Activity
fields
=
(
'
id
'
,
'
timestamp
'
,
'
user
'
,
'
message
'
,
'
visibility
'
)
This diff is collapsed.
Click to expand it.
opentech/apply/funds/urls.py
+
2
−
0
View file @
850f3e17
...
...
@@ -12,6 +12,7 @@ from .views import (
)
from
.api_views
import
(
CommentList
,
CommentListCreate
,
RoundLabDetail
,
SubmissionAction
,
SubmissionList
,
...
...
@@ -46,6 +47,7 @@ api_urls = ([
path
(
''
,
SubmissionList
.
as_view
(),
name
=
'
list
'
),
path
(
'
<int:pk>/
'
,
SubmissionDetail
.
as_view
(),
name
=
'
detail
'
),
path
(
'
<int:pk>/actions/
'
,
SubmissionAction
.
as_view
(),
name
=
'
actions
'
),
path
(
'
<int:pk>/comments/
'
,
CommentListCreate
.
as_view
(),
name
=
'
comments
'
),
],
'
submissions
'
))),
path
(
'
rounds/
'
,
include
(([
path
(
'
<int:pk>/
'
,
RoundLabDetail
.
as_view
(),
name
=
'
detail
'
),
...
...
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