fix: Replace obsolete curry() with functools.partialmethod()

This commit is contained in:
Jennifer Richards 2023-05-08 22:55:15 -03:00
parent 9fda268853
commit 6d4d09542f
No known key found for this signature in database
GPG key ID: 9B2BF5C5ADDA6A6E
2 changed files with 9 additions and 8 deletions

View file

@ -17,6 +17,7 @@ import tempfile
from calendar import timegm
from collections import OrderedDict, Counter, deque, defaultdict, namedtuple
from functools import partialmethod
from urllib.parse import parse_qs, unquote, urlencode, urlsplit, urlunsplit
from tempfile import mkstemp
from wsgiref.handlers import format_date_time
@ -38,7 +39,6 @@ from django.template import TemplateDoesNotExist
from django.template.loader import render_to_string
from django.utils import timezone
from django.utils.encoding import force_str
from django.utils.functional import curry
from django.utils.text import slugify
from django.views.decorators.cache import cache_page
from django.views.decorators.csrf import ensure_csrf_cookie, csrf_exempt
@ -3210,8 +3210,8 @@ def interim_request(request):
if meeting_type in ('single', 'multi-day'):
meeting = form.save(date=get_earliest_session_date(formset))
# need to use curry here to pass custom variable to form init
SessionFormset.form.__init__ = curry(
# need to use partialmethod here to pass custom variable to form init
SessionFormset.form.__init__ = partialmethod(
InterimSessionModelForm.__init__,
user=request.user,
group=group,
@ -3233,7 +3233,7 @@ def interim_request(request):
# subsequently dealt with individually
elif meeting_type == 'series':
series = []
SessionFormset.form.__init__ = curry(
SessionFormset.form.__init__ = partialmethod(
InterimSessionModelForm.__init__,
user=request.user,
group=group,
@ -3453,7 +3453,7 @@ def interim_request_edit(request, number):
group = Group.objects.get(pk=form.data['group'])
is_approved = is_interim_meeting_approved(meeting)
SessionFormset.form.__init__ = curry(
SessionFormset.form.__init__ = partialmethod(
InterimSessionModelForm.__init__,
user=request.user,
group=group,

View file

@ -4,10 +4,11 @@
import datetime
from functools import partialmethod
from django.contrib import messages
from django.forms.formsets import formset_factory
from django.shortcuts import render, get_object_or_404, redirect
from django.utils.functional import curry
import debug # pyflakes:ignore
@ -215,7 +216,7 @@ def doc_detail(request, date, name):
initial_state = {'state':doc.get_state(state_type).pk,
'substate':tag}
# need to use curry here to pass custom variable to form init
# need to use partialmethod here to pass custom variable to form init
if doc.active_ballot():
ballot_type = doc.active_ballot().ballot_type
elif doc.type.slug == 'draft':
@ -223,7 +224,7 @@ def doc_detail(request, date, name):
else:
ballot_type = BallotType.objects.get(doc_type=doc.type)
BallotFormset = formset_factory(BallotForm, extra=0)
BallotFormset.form.__init__ = curry(BallotForm.__init__, ballot_type=ballot_type)
BallotFormset.form.__init__ = partialmethod(BallotForm.__init__, ballot_type=ballot_type)
agenda = agenda_data(date=date)
header = get_section_header(doc, agenda)