From: Mauro Carvalho Chehab Date: Tue, 4 Jun 2019 21:31:39 +0000 (-0300) Subject: filters: re-add the possibility of filtering undelegated patches X-Git-Tag: v2.1.3~1 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=b0b7e5dab2d1a8016cb90836134f42174ac5df31;p=thirdparty%2Fpatchwork.git filters: re-add the possibility of filtering undelegated patches The filters.py redesign that happened for patchwork 1.1 removed a functionality that we use a lot: to filter patches that weren't delegated to anyone. Also, it is a way harder to find someone to delegate with a free text input. Use, instead a combo-box just like before. Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Stephen Finucane Fixes: f439f541 ("Add delegate filter autocomplete support") Closes: #60 [stephenfin: Rework release note and fix some style issues] (cherry picked from commit e99490cf28e8104f42746d71f11618f4e6f427e1) --- diff --git a/patchwork/filters.py b/patchwork/filters.py index f6e48394..2ddeb18d 100644 --- a/patchwork/filters.py +++ b/patchwork/filters.py @@ -375,6 +375,7 @@ class ArchiveFilter(Filter): class DelegateFilter(Filter): param = 'delegate' + no_delegate_str = 'Nobody' AnyDelegate = 1 def __init__(self, filters): @@ -391,6 +392,11 @@ class DelegateFilter(Filter): if not key: return + if key == self.no_delegate_str: + self.delegate_match = key + self.applied = True + return + try: self.delegate = User.objects.get(id=int(key)) except (ValueError, User.DoesNotExist): @@ -410,6 +416,9 @@ class DelegateFilter(Filter): if self.delegate: return {'delegate': self.delegate} + if self.delegate_match == self.no_delegate_str: + return {'delegate__username__isnull': True} + if self.delegate_match: return {'delegate__username__icontains': self.delegate_match} return {} @@ -422,8 +431,31 @@ class DelegateFilter(Filter): return '' def _form(self): - return mark_safe('') + delegates = User.objects.filter( + profile__maintainer_projects__isnull=False) + + out = '' + return mark_safe(out) def key(self): if self.delegate: diff --git a/patchwork/templates/patchwork/filters.html b/patchwork/templates/patchwork/filters.html index 9b0c4cb2..a689b2eb 100644 --- a/patchwork/templates/patchwork/filters.html +++ b/patchwork/templates/patchwork/filters.html @@ -76,44 +76,6 @@ $(document).ready(function() { }); } }); - - $('#delegate_input').selectize({ - plugins: ['enter_key_submit'], - maxItems: 1, - persist: false, - onInitialize: function() { - this.on('submit', function() { - if (!this.items.length) - this.$input.val(this.lastValue); - this.$input.closest('form').submit(); - }, this); - }, -{% if "delegate" in filters.applied_filters %} -{% with delegate_filter=filters.applied_filters.delegate %} - options: [ - { - value: "{{ delegate_filter.key }}", - text: "{{ delegate_filter.condition }}", - }, - ], - items: ["{{ delegate_filter.key }}"], -{% endwith %} -{% endif %} - load: function(query, callback) { - req = $.ajax({ - url: "{% url 'api-delegates' %}", - data: {q: query, l: 10}, - error: function() { - callback(); - }, - success: function(res) { - callback($.map(res, function (obj) { - return {value: obj.pk, text: obj.name}; - })); - } - }); - } - }); }); diff --git a/releasenotes/notes/issue-60-9d4fc111242f7db6.yaml b/releasenotes/notes/issue-60-9d4fc111242f7db6.yaml new file mode 100644 index 00000000..79886592 --- /dev/null +++ b/releasenotes/notes/issue-60-9d4fc111242f7db6.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + In the past, Patchwork used to support filtering patches that weren't + delegated to anyone. This feature was removed in v1.1.0, as part of a patch + designed to support delegation to anyone. However, that feature didn't scale + and was later removed. The ability to delegate to anyone is now itself + re-introduced.