Hi guys any idea how the following view could be refactored into class based view? I want to convert this view into more structured class based view.
def student_application(request, project_slug):
profile = StudentProfile.objects.get(user=request.user)
project = Project.objects.get(slug=project_slug)
new_invitation = ProjectInvitation(student=profile, project=project, state_student=ProjectInvitationState.ACCEPTED,
student_application=True)
form_application = ProjectApplicationForm(request.POST, instance=new_invitation)
form_application.fields["previous_experience"].queryset = profile.practical_experiences
if form_application.is_valid():
form_application.save()
action.send(profile, verb='has applied for', target=project)
messages.add_message(request, messages.SUCCESS, 'Thank you! Your application for project %s was successful and '
'will be reviewed shortly.' % project)
return HttpResponseRedirect(reverse('invitation_index'))
else:
messages.add_message(request, messages.ERROR, 'There was a problem with your application.')
return HttpResponseRedirect(reverse('project_index'))