From ed20650289effbf0c2a5497cc20eb2be75793da7 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Thu, 2 Oct 2014 12:11:50 +0200 Subject: [PATCH] [TASK] Make mapping wizards success_url work. --- frontend/views.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/frontend/views.py b/frontend/views.py index 3334910..f109e05 100644 --- a/frontend/views.py +++ b/frontend/views.py @@ -6,13 +6,13 @@ from django.core.files.storage import default_storage from django.core.files.base import ContentFile from django.conf import settings -from django.http import HttpResponse, HttpResponseRedirect from django.views.generic import TemplateView, FormView, CreateView, UpdateView from django.views.generic.detail import SingleObjectMixin from django.contrib.auth.decorators import login_required from django.utils.decorators import method_decorator from django.contrib.auth.views import login, logout -from django.forms import ValidationError + +from django.core.urlresolvers import reverse from frontend.forms import NewProjectForm, FileUploadForm, PersonMapForm @@ -210,6 +210,7 @@ class ProjectPersonView(ProtectedFormView, SingleObjectMixin): class ProjectMapPersonView(ProtectedFormView, SingleObjectMixin): + """ View containing the person mapping 'wizard'. """ template_name = u'project/map-person.html' page_title = u'Person Mapping' form_class = PersonMapForm @@ -218,10 +219,19 @@ class ProjectMapPersonView(ProtectedFormView, SingleObjectMixin): def get_context_data(self, **kwargs): project = self.object - kwargs[u'person'] = person_mapper.get_person_by_uuid(project, self.person_uuid) return super(ProjectMapPersonView, self).get_context_data(**kwargs) + def get_success_url(self): + unmapped_persons = person_mapper.get_unmapped_identities(self.object) + project_id = self.object.id + person = unmapped_persons.itervalues().next() + kwargs = { + u"project_id": project_id, + u"person_uuid": person.ID + } + return reverse('frontend-project-map-person', kwargs=kwargs) + def get(self, request, *args, **kwargs): self.project_id = kwargs[u'project_id'] self.person_uuid = kwargs[u'person_uuid']