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
d4d6d522
Commit
d4d6d522
authored
6 years ago
by
Todd Dembrey
Browse files
Options
Downloads
Patches
Plain Diff
GH-877: Allow to find newer comments easily
parent
ca4132c0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
opentech/apply/activity/models.py
+3
-0
3 additions, 0 deletions
opentech/apply/activity/models.py
opentech/apply/funds/api_views.py
+11
-2
11 additions, 2 deletions
opentech/apply/funds/api_views.py
with
14 additions
and
2 deletions
opentech/apply/activity/models.py
+
3
−
0
View file @
d4d6d522
...
...
@@ -41,6 +41,9 @@ class BaseActivityQuerySet(models.QuerySet):
def
visible_to
(
self
,
user
):
return
self
.
filter
(
visibility__in
=
self
.
model
.
visibility_for
(
user
))
def
newer
(
self
,
activity
):
return
self
.
filter
(
timestamp__gt
=
activity
.
timestamp
)
class
ActivityQuerySet
(
BaseActivityQuerySet
):
def
comments
(
self
):
...
...
This diff is collapsed.
Click to expand it.
opentech/apply/funds/api_views.py
+
11
−
2
View file @
d4d6d522
...
...
@@ -108,13 +108,22 @@ class RoundLabList(generics.ListAPIView):
pagination_class
=
StandardResultsSetPagination
class
NewerThanFilter
(
filters
.
ModelChoiceFilter
):
def
filter
(
self
,
qs
,
value
):
if
not
value
:
return
qs
return
qs
.
newer
(
value
)
class
CommentFilter
(
filters
.
FilterSet
):
since
=
filters
.
DateTimeFilter
(
field_name
=
"
timestamp
"
,
lookup_expr
=
'
gte
'
)
before
=
filters
.
DateTimeFilter
(
field_name
=
"
timestamp
"
,
lookup_expr
=
'
lte
'
)
newer
=
NewerThanFilter
(
queryset
=
Activity
.
comments
.
all
())
class
Meta
:
model
=
Activity
fields
=
[
'
submission
'
,
'
visibility
'
,
'
since
'
,
'
before
'
]
fields
=
[
'
submission
'
,
'
visibility
'
,
'
since
'
,
'
before
'
,
'
newer
'
]
class
CommentList
(
generics
.
ListAPIView
):
...
...
@@ -138,7 +147,7 @@ class CommentListCreate(generics.ListCreateAPIView):
permissions
.
IsAuthenticated
,
IsApplyStaffUser
,
)
filter_backends
=
(
filters
.
DjangoFilterBackend
,)
filter_
fields
=
(
'
visibility
'
,)
filter_
class
=
CommentFilter
pagination_class
=
StandardResultsSetPagination
def
get_queryset
(
self
):
...
...
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