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'))

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/db836e73-e86b-486f-a691-45900ae00e27%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to