]> git.parisson.com Git - teleforma.git/commitdiff
fix url pk
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 3 Feb 2016 23:03:44 +0000 (00:03 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 3 Feb 2016 23:03:44 +0000 (00:03 +0100)
teleforma/urls.py
teleforma/views/crfpa.py

index 1e1c1cdec606d5e09cb0f617af29c62e1152066d..2a4498194567a3e5a8ea5fe9184b2a8affd93b5f 100644 (file)
@@ -58,7 +58,7 @@ urlpatterns = patterns('',
     # (r'^accounts/register0/$', RegistrationView.as_view(), {'form_class':CustomRegistrationForm}),
     url(r'^accounts/register/$', UserAddView.as_view(), name="teleforma-register"),
     url(r'^accounts/complete/$', UserCompleteView.as_view(), name="teleforma-register-complete"),
-    url(r'^accounts/register/(?P<username>.*)/download/$', RegistrationPDFViewDowload.as_view(),
+    url(r'^accounts/register/(?P<pk>.*)/download/$', RegistrationPDFViewDowload.as_view(),
                                                     name="teleforma-registration-download"),
 
     url(r'^captcha/', include('captcha.urls')),
index 5130795e3488dfb606e03674138505e926d9a5a4..005347dfdadacf013c23d7676f118ef052a91ee1 100644 (file)
@@ -405,11 +405,10 @@ class UserAddView(CreateWithInlinesView):
 
     def forms_valid(self, form, inlines):
         messages.info(self.request, _("You have successfully register your account."))
-        username = get_unique_username(form.cleaned_data['first_name'], form.cleaned_data['last_name'])
-        form.cleaned_data['username'] = username
-        self.user = form.save()
-        self.user.is_active = False
-        self.user.save()
+        user = form.save()
+        user.username = get_unique_username(user.first_name, user.last_name)
+        user.is_active = False
+        user.save()
         return super(UserAddView, self).forms_valid(form, inlines)
 
 
@@ -432,7 +431,8 @@ class RegistrationPDFView(PDFTemplateResponseMixin, DetailView):
 
     def get_context_data(self, **kwargs):
         context = super(RegistrationPDFView, self).get_context_data(**kwargs)
-        user = User.objects.get(username=kwargs['username'])
+        user = User.objects.get(pk=kwargs['pk'])
+        user = self.get_object()
         student = user.student.all()[0]
         if student.training and not student.trainings:
             student.trainings.add(student.training)