class DelegateFilter(Filter):
param = 'delegate'
+ no_delegate_str = 'Nobody'
AnyDelegate = 1
def __init__(self, filters):
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):
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 {}
return ''
def _form(self):
- return mark_safe('<input type="text" name="delegate" '
- 'id="delegate_input" class="form-control">')
+ delegates = User.objects.filter(
+ profile__maintainer_projects__isnull=False)
+
+ out = '<select name="delegate" class="form-control">'
+
+ selected = ''
+ if not self.applied:
+ selected = 'selected'
+ out += '<option %s value="">------</option>' % selected
+
+ selected = ''
+ if self.applied and self.delegate is None:
+ selected = 'selected'
+ out += '<option %s value="%s">%s</option>' % (
+ selected, self.no_delegate_str, self.no_delegate_str)
+
+ for delegate in delegates:
+ selected = ''
+ if delegate == self.delegate:
+ selected = ' selected'
+
+ out += '<option %s value="%s">%s</option>' % (
+ selected, delegate.id, delegate.username)
+ out += '</select>'
+ return mark_safe(out)
def key(self):
if self.delegate:
});
}
});
-
- $('#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};
- }));
- }
- });
- }
- });
});
</script>
--- /dev/null
+---
+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.