def get_form_kwargs(self, **kwargs):
numMonths = <NUM_LIT:12><EOL>lastStart = (<EOL>Event.objects.annotate(Min('<STR_LIT>'))<EOL>.order_by('<STR_LIT>')<EOL>.values_list('<STR_LIT>', flat=True)<EOL>.first()<EOL>)<EOL>if lastStart:<EOL><INDENT>month = lastStart.month<EOL>year = lastStart.year<EOL><DEDENT>else:<EOL><INDENT>month = timezone.now().month<EOL>year = timezone.now().year<EOL><DEDENT>months = [('<STR_LIT>', _('<STR_LIT:None>'))]<EOL>for i in range(<NUM_LIT:0>, numMonths):<EOL><INDENT>newmonth = (month - i - <NUM_LIT:1>) % <NUM_LIT:12> + <NUM_LIT:1><EOL>newyear = year<EOL>if month - i - <NUM_LIT:1> < <NUM_LIT:0>:<EOL><INDENT>newyear = year - <NUM_LIT:1><EOL><DEDENT>newdate = datetime(year=newyear, month=newmonth, day=<NUM_LIT:1>)<EOL>newdateStr = newdate.strftime("<STR_LIT>")<EOL>monthStr = newdate.strftime("<STR_LIT>")<EOL>months.append((newdateStr, monthStr))<EOL><DEDENT>cutoff = timezone.now() - timedelta(days=<NUM_LIT>)<EOL>allEvents = Event.objects.filter(startTime__gte=cutoff).order_by('<STR_LIT>')<EOL>recentSeries = [('<STR_LIT>', '<STR_LIT:None>')] + [(x.id, '<STR_LIT>' % (month_name[x.month], x.year, x.name)) for x in allEvents]<EOL>kwargs = super(SendEmailView, self).get_form_kwargs(**kwargs)<EOL>kwargs.update({<EOL>"<STR_LIT>": months,<EOL>"<STR_LIT>": recentSeries,<EOL>"<STR_LIT>": self.customers,<EOL>})<EOL>return kwargs<EOL>
Get the list of recent months and recent series to pass to the form