[4/7] REST: Remove ProjectFilterMixin

Message ID 20180411161338.420-5-stephen@that.guru
State Accepted
Headers show
Series
  • Add support for multiple filters
Related show

Commit Message

Stephen Finucane April 11, 2018, 4:13 p.m.
Whatever benefits this was giving us in the past are no more and it
simply confuses matters now.

Signed-off-by: Stephen Finucane <stephen@that.guru>
---
 patchwork/api/filters.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

Comments

Daniel Axtens May 8, 2018, 3:47 p.m. | #1
Stephen Finucane <stephen@that.guru> writes:

> Whatever benefits this was giving us in the past are no more and it
> simply confuses matters now.

I strongly endorse the removal of this mixin in particular (and most
mixins, in general).

Reviewed-by: Daniel Axtens <dja@axtens.net>

Regards,
Daniel
>
> Signed-off-by: Stephen Finucane <stephen@that.guru>
> ---
>  patchwork/api/filters.py | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/patchwork/api/filters.py b/patchwork/api/filters.py
> index b30499d0..7d94d5ed 100644
> --- a/patchwork/api/filters.py
> +++ b/patchwork/api/filters.py
> @@ -141,22 +141,19 @@ class TimestampMixin(FilterSet):
>      since = IsoDateTimeFilter(name='date', lookup_expr='gte')
>  
>  
> -class ProjectMixin(FilterSet):
> -
> -    project = ProjectFilter(queryset=Project.objects.all())
> -
> -
> -class SeriesFilter(ProjectMixin, TimestampMixin, FilterSet):
> +class SeriesFilter(TimestampMixin, FilterSet):
>  
>      submitter = PersonFilter(queryset=Person.objects.all())
> +    project = ProjectFilter(queryset=Project.objects.all())
>  
>      class Meta:
>          model = Series
>          fields = ('submitter', 'project')
>  
>  
> -class CoverLetterFilter(ProjectMixin, TimestampMixin, FilterSet):
> +class CoverLetterFilter(TimestampMixin, FilterSet):
>  
> +    project = ProjectFilter(queryset=Project.objects.all())
>      submitter = PersonFilter(queryset=Person.objects.all())
>  
>      class Meta:
> @@ -164,8 +161,9 @@ class CoverLetterFilter(ProjectMixin, TimestampMixin, FilterSet):
>          fields = ('project', 'series', 'submitter')
>  
>  
> -class PatchFilter(ProjectMixin, TimestampMixin, FilterSet):
> +class PatchFilter(TimestampMixin, FilterSet):
>  
> +    project = ProjectFilter(queryset=Project.objects.all())
>      submitter = PersonFilter(queryset=Person.objects.all())
>      delegate = UserFilter(queryset=User.objects.all())
>      state = StateFilter(queryset=State.objects.all())
> @@ -185,15 +183,18 @@ class CheckFilter(TimestampMixin, FilterSet):
>          fields = ('user', 'state', 'context')
>  
>  
> -class EventFilter(ProjectMixin, TimestampMixin, FilterSet):
> +class EventFilter(TimestampMixin, FilterSet):
> +
> +    project = ProjectFilter(queryset=Project.objects.all())
>  
>      class Meta:
>          model = Event
>          fields = ('project', 'category', 'series', 'patch', 'cover')
>  
>  
> -class BundleFilter(ProjectMixin, FilterSet):
> +class BundleFilter(FilterSet):
>  
> +    project = ProjectFilter(queryset=Project.objects.all())
>      owner = UserFilter(queryset=User.objects.all())
>  
>      class Meta:
> -- 
> 2.14.3
>
> _______________________________________________
> Patchwork mailing list
> Patchwork@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork

Patch

diff --git a/patchwork/api/filters.py b/patchwork/api/filters.py
index b30499d0..7d94d5ed 100644
--- a/patchwork/api/filters.py
+++ b/patchwork/api/filters.py
@@ -141,22 +141,19 @@  class TimestampMixin(FilterSet):
     since = IsoDateTimeFilter(name='date', lookup_expr='gte')
 
 
-class ProjectMixin(FilterSet):
-
-    project = ProjectFilter(queryset=Project.objects.all())
-
-
-class SeriesFilter(ProjectMixin, TimestampMixin, FilterSet):
+class SeriesFilter(TimestampMixin, FilterSet):
 
     submitter = PersonFilter(queryset=Person.objects.all())
+    project = ProjectFilter(queryset=Project.objects.all())
 
     class Meta:
         model = Series
         fields = ('submitter', 'project')
 
 
-class CoverLetterFilter(ProjectMixin, TimestampMixin, FilterSet):
+class CoverLetterFilter(TimestampMixin, FilterSet):
 
+    project = ProjectFilter(queryset=Project.objects.all())
     submitter = PersonFilter(queryset=Person.objects.all())
 
     class Meta:
@@ -164,8 +161,9 @@  class CoverLetterFilter(ProjectMixin, TimestampMixin, FilterSet):
         fields = ('project', 'series', 'submitter')
 
 
-class PatchFilter(ProjectMixin, TimestampMixin, FilterSet):
+class PatchFilter(TimestampMixin, FilterSet):
 
+    project = ProjectFilter(queryset=Project.objects.all())
     submitter = PersonFilter(queryset=Person.objects.all())
     delegate = UserFilter(queryset=User.objects.all())
     state = StateFilter(queryset=State.objects.all())
@@ -185,15 +183,18 @@  class CheckFilter(TimestampMixin, FilterSet):
         fields = ('user', 'state', 'context')
 
 
-class EventFilter(ProjectMixin, TimestampMixin, FilterSet):
+class EventFilter(TimestampMixin, FilterSet):
+
+    project = ProjectFilter(queryset=Project.objects.all())
 
     class Meta:
         model = Event
         fields = ('project', 'category', 'series', 'patch', 'cover')
 
 
-class BundleFilter(ProjectMixin, FilterSet):
+class BundleFilter(FilterSet):
 
+    project = ProjectFilter(queryset=Project.objects.all())
     owner = UserFilter(queryset=User.objects.all())
 
     class Meta: