from django.contrib.auth import authenticate, login, logout
from django.shortcuts import render, redirect

from meetuppizza.forms import RegistrationForm
from meetup.models import Meetup
from meetup.services.meetup_service import MeetupService

def index(request):
  meetups = Meetup.objects.all()
  meetup_presenters = []
  for meetup in meetups:
    service = MeetupService(meetup)
    meetup_presenters.append(service.get_decorated_meetup())
  return render(request, 'index.html', {"meetups": meetup_presenters})

from django.contrib.auth import authenticate, login, logout
from django.shortcuts import render, redirect

from meetuppizza.forms import RegistrationForm
from meetup.models import Meetup
from meetup.services.meetup_service import MeetupService

def index(request):
  meetups = Meetup.objects.all()
  meetup_presenters = [MeetupService(meetup).get_decorated_meetup() for meetup in meetups]

  return render(request, 'index.html', {"meetups": meetup_presenters})

Use list comprehension to generate MeetupPresentor list in index view
Use list comprehension to generate MeetupPresentor list in index view

  from django.contrib.auth import authenticate, login, logout
  from django.shortcuts import render, redirect
  
  from meetuppizza.forms import RegistrationForm
  from meetup.models import Meetup
  from meetup.services.meetup_service import MeetupService
  
  def index(request):
    meetups = Meetup.objects.all()
+   meetup_presenters = [MeetupService(meetup).get_decorated_meetup() for meetup in meetups]
+ 
-   meetup_presenters = []
-   for meetup in meetups:
-     service = MeetupService(meetup)
-     meetup_presenters.append(service.get_decorated_meetup())
    return render(request, 'index.html', {"meetups": meetup_presenters})
  
Use list comprehension to generate MeetupPresentor list in index view
## Code Before:
from django.contrib.auth import authenticate, login, logout
from django.shortcuts import render, redirect

from meetuppizza.forms import RegistrationForm
from meetup.models import Meetup
from meetup.services.meetup_service import MeetupService

def index(request):
  meetups = Meetup.objects.all()
  meetup_presenters = []
  for meetup in meetups:
    service = MeetupService(meetup)
    meetup_presenters.append(service.get_decorated_meetup())
  return render(request, 'index.html', {"meetups": meetup_presenters})

## Instruction:
Use list comprehension to generate MeetupPresentor list in index view
## Code After:
from django.contrib.auth import authenticate, login, logout
from django.shortcuts import render, redirect

from meetuppizza.forms import RegistrationForm
from meetup.models import Meetup
from meetup.services.meetup_service import MeetupService

def index(request):
  meetups = Meetup.objects.all()
  meetup_presenters = [MeetupService(meetup).get_decorated_meetup() for meetup in meetups]

  return render(request, 'index.html', {"meetups": meetup_presenters})
