Changeset - ffa2889acb73
[Not reviewed]
0 1 0
Ben Sturmfels (bsturmfels) - 2 months ago 2024-02-23 04:01:01
ben@sturm.com.au
podjango: Use `or_` instead of lambda

Easier to read.
1 file changed with 2 insertions and 1 deletions:
0 comments (0 inline, 0 general)
conservancy/podjango/views.py
Show inline comments
...
 
@@ -15,22 +15,23 @@
 
# You should have received a copy of the GNU Affero General Public License
 
# along with this program in a file in the toplevel directory called
 
# "AGPLv3".  If not, see <http://www.gnu.org/licenses/>.
 
#
 
from datetime import datetime
 
from functools import reduce
 
from operator import or_
 

	
 
from django.shortcuts import get_object_or_404, render
 
from django.views.generic.list import ListView
 

	
 
from .models import Cast, CastTag
 

	
 

	
 
def OR_filter(field_name, objs):
 
    from django.db.models import Q
 
    return reduce(lambda x, y: x | y,
 
    return reduce(or_,
 
                  [Q(**{field_name: x.id}) for x in objs])
 

	
 
def last_name(person):
 
    return person.formal_name.rpartition(' ')[2]
 

	
 
def custom_index(request, queryset, *args, **kwargs):
0 comments (0 inline, 0 general)