Quantcast

[Django] #27991: InlineModelAdmin's has_add_permission method doesn't accept instance argument

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Django] #27991: InlineModelAdmin's has_add_permission method doesn't accept instance argument

Django
#27991: InlineModelAdmin's has_add_permission method doesn't accept instance
argument
-----------------------------------------+------------------------
               Reporter:  Olivier        |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  1.10
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 Hi !

 {{{InlineModelAdmin}}} has the following methods :

 {{{
 def has_add_permission(self, request):
     ...
 def has_change_permission(self, request, obj=None):
     ...
 def has_delete_permission(self, request, obj=None):
     ...
 }}}

 In those methods, the {{{obj}}} parameter represents the parent instance.
 So, by overriding {{{ModelInline.has_change_permission}}} you can have
 some specific logic to define whether an user can change inlines objects
 depending on the parent object.

 The thing is that the {{{has_add_permission}}} misses this argument. It
 probably came from a confusion between the parent instance (the {{{obj}}}
 argument) and the child instance (not accessible).

 Still, exactly as it makes sense overriding
 {{{ModelInline.has_change_permission}}}, we may need to have some specific
 logic to define whether an user can add inlines objects depending on the
 parent object.

 I suggest we add the {{{obj}}} argument to
 {{{ModelInline.has_add_permission}}}, and make it more clear (both in the
 doc and as comments in the code) that {{{obj}}} refers to the parent
 instance, and not the inline instance.

 It would be awesome if those methods also took the inline instance as a
 parameter (eg. {{{def has_change_permission(self, request, obj=None,
 childObj=None):}}} to keep it backwards compatible ) but that would
 probably be for another ticket.

 Thanks !

 Olivier

--
Ticket URL: <https://code.djangoproject.com/ticket/27991>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/056.505d782a7680473b6ee1a44c3ff9cd22%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Django] #27991: Add 'obj' kwarg to InlineModelAdmin's.has_add_permission() (was: InlineModelAdmin's has_add_permission method doesn't accept instance argument)

Django
#27991: Add 'obj' kwarg to InlineModelAdmin's.has_add_permission()
--------------------------------------+------------------------------------
     Reporter:  Olivier               |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  contrib.admin         |                  Version:  1.10
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------
Changes (by Tim Graham):

 * component:  Uncategorized => contrib.admin
 * type:  Uncategorized => Cleanup/optimization
 * stage:  Unreviewed => Accepted


Comment:

 Seems okay at first glance. For backwards compatibility, each
 `has_add_permission()`call that starts passing `obj` needs to check if the
 `has_add_permission()` method accepts an `obj` parameter and give a
 deprecation warning if not; see a7c256cb5491bf2a77abdff01638239db5bfd9d5
 for a similar deprecation.

--
Ticket URL: <https://code.djangoproject.com/ticket/27991#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.2d2f923caeab4cfcddf3c23611eac6f9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Django] #27991: Add 'obj' kwarg to InlineModelAdmin.has_add_permission() (was: Add 'obj' kwarg to InlineModelAdmin's.has_add_permission())

Django
In reply to this post by Django
#27991: Add 'obj' kwarg to InlineModelAdmin.has_add_permission()
--------------------------------------+------------------------------------
     Reporter:  Olivier               |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  contrib.admin         |                  Version:  1.10
     Severity:  Normal                |               Resolution:
     Keywords:                        |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  0                     |                    UI/UX:  0
--------------------------------------+------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/27991#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.74e38fe9d1458435a038aec0215b6eab%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Django] #27991: Add 'obj' kwarg to InlineModelAdmin.has_add_permission()

Django
In reply to this post by Django
#27991: Add 'obj' kwarg to InlineModelAdmin.has_add_permission()
-------------------------------------+-------------------------------------
     Reporter:  Olivier              |                    Owner:  Vladimir
         Type:                       |  Ivanov
  Cleanup/optimization               |                   Status:  assigned
    Component:  contrib.admin        |                  Version:  1.10
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Vladimir Ivanov):

 * owner:  nobody => Vladimir Ivanov
 * status:  new => assigned
 * has_patch:  0 => 1


Comment:

 https://github.com/django/django/pull/8304

--
Ticket URL: <https://code.djangoproject.com/ticket/27991#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.e41444ca730714dd0927067f69a7264c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Django] #27991: Add 'obj' kwarg to InlineModelAdmin.has_add_permission()

Django
In reply to this post by Django
#27991: Add 'obj' kwarg to InlineModelAdmin.has_add_permission()
-------------------------------------+-------------------------------------
     Reporter:  Olivier              |                    Owner:  Vladimir
         Type:                       |  Ivanov
  Cleanup/optimization               |                   Status:  assigned
    Component:  contrib.admin        |                  Version:  1.10
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * needs_better_patch:  0 => 1


Comment:

 When updating, please also check your patch using the
 PatchReviewChecklist, then uncheck "Patch needs improvement" on this
 ticket.

--
Ticket URL: <https://code.djangoproject.com/ticket/27991#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.6d5fb65c38235761cf0ddd551fd7f284%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Django] #27991: Add 'obj' kwarg to InlineModelAdmin.has_add_permission()

Django
In reply to this post by Django
#27991: Add 'obj' kwarg to InlineModelAdmin.has_add_permission()
-------------------------------------+-------------------------------------
     Reporter:  Olivier              |                    Owner:  Vladimir
         Type:                       |  Ivanov
  Cleanup/optimization               |                   Status:  assigned
    Component:  contrib.admin        |                  Version:  1.10
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Vladimir Ivanov):

 * needs_better_patch:  1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/27991#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.4a8b3ee4c397b0eeedd8f46c9933b39c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Django] #27991: Add 'obj' kwarg to InlineModelAdmin.has_add_permission()

Django
In reply to this post by Django
#27991: Add 'obj' kwarg to InlineModelAdmin.has_add_permission()
-------------------------------------+-------------------------------------
     Reporter:  Olivier              |                    Owner:  Vladimir
         Type:                       |  Ivanov
  Cleanup/optimization               |                   Status:  assigned
    Component:  contrib.admin        |                  Version:  1.10
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by felixxm):

 * needs_better_patch:  0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/27991#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.5adc6a37d75fc397a4d5ab6e67082272%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Django] #27991: Add 'obj' kwarg to InlineModelAdmin.has_add_permission()

Django
In reply to this post by Django
#27991: Add 'obj' kwarg to InlineModelAdmin.has_add_permission()
-------------------------------------+-------------------------------------
     Reporter:  Olivier              |                    Owner:  Vladimir
         Type:                       |  Ivanov
  Cleanup/optimization               |                   Status:  assigned
    Component:  contrib.admin        |                  Version:  1.10
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Vladimir Ivanov):

 Is there anything I can improve else? Why is it in 'Patch needs
 improvement'?

--
Ticket URL: <https://code.djangoproject.com/ticket/27991#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.5c88c880862db3b55107910399e16cdb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Loading...