Django

Code

Ticket #8433 (closed: fixed)

Opened 3 months ago

Last modified 3 months ago

auth add_view popup

Reported by: sorl Assigned to: nobody
Milestone: 1.0 Component: django.contrib.admin
Version: SVN Keywords:
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description (Last modified by jacob)

add_view should probably be:

                if "_addanother" in request.POST:
                    request.user.message_set.create(message=msg)
                    return HttpResponseRedirect(request.path)
+                elif '_popup' in request.REQUEST:
+                    return self.response_add(request, new_user)
                else:     
                    request.user.message_set.create(message=msg + ' ' + ugettext("You may edit it again below."))
                    return HttpResponseRedirect('../%s/' % new_user.id)

Attachments

8433.authpopup.diff (0.7 kB) - added by julien on 08/24/08 21:14:02.
sorl's patch in a diff

Change History

08/19/08 18:36:04 changed by sorl

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.
                if "_addanother" in request.POST:
                    request.user.message_set.create(message=msg)
                    return HttpResponseRedirect(request.path)
+               elif '_popup' in request.REQUEST:
+                   return self.response_add(request, new_user)
                else:     
                    request.user.message_set.create(message=msg + ' ' + ugettext("You may edit it again below."))
                    return HttpResponseRedirect('../%s/' % new_user.id)

08/22/08 20:09:05 changed by jacob

  • description changed.

(fix formatting)

08/22/08 20:09:42 changed by jacob

  • milestone changed from 1.0 maybe to 1.0.

Please explain more about why it should do this -- I can't tell from the patch what the problem is.

08/23/08 09:56:27 changed by sorl

When FK to User in a model and you add a new user by clicking the green plus. If you don't check for popup you will be presented to editing the options for the user in the popup window, which doesn't look very good. The downside (which I think is ok since its a popup) is that you wont be presented to the options editing for the new user at all.

08/24/08 12:07:52 changed by jacob

  • stage changed from Unreviewed to Accepted.

08/24/08 21:14:02 changed by julien

  • attachment 8433.authpopup.diff added.

sorl's patch in a diff

08/24/08 21:19:11 changed by julien

I can confirm this is an annoying bug (the new user is not added to the FK field in the admin interface after the popup is closed or after the user's details are saved). sorl's patch works, and I've attached a diff with it so it's easier to commit.

However, while the patch prevents the bug, you cannot edit the new user's details (first name, last name etc.). You'd need to edit those details separately at a later stage. A proper and long term solution would be to detect the popup in the change_view and treat the request as if it were an add, not a change.

08/24/08 21:19:50 changed by julien

  • has_patch set to 1.

08/31/08 16:24:34 changed by brosner

  • status changed from new to closed.
  • resolution set to fixed.

(In [8776]) Fixed #8433 -- Deal with the add user popup on models that foreign key to User correctly. Thanks sorl for the report and fix.


Add/Change #8433 (auth add_view popup)




Change Properties
Action