[Django] #18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect

Django
#18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect
--------------------------------------+--------------------
     Reporter:  mtigas                |      Owner:  nobody
         Type:  Cleanup/optimization  |     Status:  new
    Component:  contrib.contenttypes  |    Version:  1.4
     Severity:  Normal                |   Keywords:
 Triage Stage:  Unreviewed            |  Has patch:  0
Easy pickings:  0                     |      UI/UX:  0
--------------------------------------+--------------------
 Given an object with a many-to-many relationship to
 `django.contrib.sites.models.Site`, the
 `django.contrib.contenttypes.views.shortcut` view simply picks the first
 domain returned, basically `obj.<field>[0].domain`.
 (https://github.com/django/django/blob/4a103086/django/contrib/contenttypes/views.py#L45
 -- it even notes that the ordering is arbitrary.)

 This can be confusing when operating several (shared database) Django
 sites where sometimes content is cross-posted between said sites.

 Example that led to my noticing this issue: A story being edited on
 www.spokesman.com but posted to sites [www.spokesman.com,
 www.downtoearthnw.com] redirects you to story's representation on the
 latter website when clicking "view on site" in the admin (or using
 anything else that uses that underlying `shortcut` view). (Ostensibly
 because "www.downtoearthnw.com" sorts before "www.spokesman.com" and is
 therefore picked by the simple code I linked above.) Although this is a
 ''theoretically acceptable'' thing to happen, it's confusing to (even
 technical) users because they're ''on'' one of the acceptable sites for
 the content object and do not expect to be redirected to another site.

 I propose that the view should prefer the current site in the event that
 both of the following are true:

 a) the content object "Site" field is an M2M
 b) the current Site object is one of the values set in that M2M

 This shouldn't change behavior in any other circumstance (current site not
 in that M2M, site field is not M2M, etc), but it should alleviate some
 confusion to this specific usecase.

 Have code and will post in a GitHub fork shortly.

--
Ticket URL: <https://code.djangoproject.com/ticket/18620>
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 post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: [Django] #18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect

Django
#18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect
--------------------------------------+------------------------------------
     Reporter:  mtigas                |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  contrib.contenttypes  |                  Version:  1.4
     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 aaugustin):

 * needs_better_patch:   => 0
 * needs_docs:   => 0
 * needs_tests:   => 0
 * stage:  Unreviewed => Accepted


Comment:

 This makes sense and is backwards compatible.

--
Ticket URL: <https://code.djangoproject.com/ticket/18620#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 post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: [Django] #18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect

Django
In reply to this post by Django
#18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect
--------------------------------------+------------------------------------
     Reporter:  mtigas                |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  contrib.contenttypes  |                  Version:  1.4
     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 mtigas):

 * has_patch:  0 => 1


Comment:

 Fork: https://github.com/mtigas/django/tree/patches/ticket-18620

 Pull request: https://github.com/django/django/pull/203

 Test isn't the best but does fail without the views.py patch.

--
Ticket URL: <https://code.djangoproject.com/ticket/18620#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 post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: [Django] #18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect

Django
In reply to this post by Django
#18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect
--------------------------------------+------------------------------------
     Reporter:  mtigas                |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  contrib.contenttypes  |                  Version:  1.4
     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
--------------------------------------+------------------------------------

Comment (by mtigas):

 Also I'm on the fence as to whether or not it should optimize and not
 query for `current_site` until absolutely necessary (i.e. use `lazy` or
 use some if-blocks). Basically to avoid one unnecessary query in the
 situation if we have a site FK.

--
Ticket URL: <https://code.djangoproject.com/ticket/18620#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 post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.

Reply | Threaded
Open this post in threaded view
|

Re: [Django] #18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect

Django
In reply to this post by Django
#18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect
--------------------------------------+------------------------------------
     Reporter:  mtigas                |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  contrib.contenttypes  |                  Version:  1.4
     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 timo):

 * needs_better_patch:  0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/18620#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/064.058a476e303d33af078c49ed8f5c42d3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect

Django
In reply to this post by Django
#18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect
--------------------------------------+------------------------------------
     Reporter:  Mike Tigas            |                    Owner:  Paulo
         Type:  Cleanup/optimization  |                   Status:  assigned
    Component:  contrib.contenttypes  |                  Version:  1.4
     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 Paulo):

 * owner:  nobody => Paulo
 * status:  new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/18620#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/064.43ac473f7ba255eb9bf49c455acdb49d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect

Django
In reply to this post by Django
#18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect
--------------------------------------+------------------------------------
     Reporter:  Mike Tigas            |                    Owner:  Paulo
         Type:  Cleanup/optimization  |                   Status:  assigned
    Component:  contrib.contenttypes  |                  Version:  1.4
     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 Paulo):

 * needs_better_patch:  1 => 0


Comment:

 PR: https://github.com/django/django/pull/9120

--
Ticket URL: <https://code.djangoproject.com/ticket/18620#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/064.6db9b4b5389c96ee637098a7c320fda7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect

Django
In reply to this post by Django
#18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect
-------------------------------------+-------------------------------------
     Reporter:  Mike Tigas           |                    Owner:  Paulo
         Type:                       |                   Status:  assigned
  Cleanup/optimization               |
    Component:                       |                  Version:  1.4
  contrib.contenttypes               |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * stage:  Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/18620#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/064.0a7f4308adaa62b114ec16427de1e624%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect

Django
In reply to this post by Django
#18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect
--------------------------------------+------------------------------------
     Reporter:  Mike Tigas            |                    Owner:  Paulo
         Type:  Cleanup/optimization  |                   Status:  assigned
    Component:  contrib.contenttypes  |                  Version:  1.4
     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
 * stage:  Ready for checkin => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/18620#comment:8>
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/064.c3fb0a9b110928420faaebb9d4471536%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect

Django
In reply to this post by Django
#18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect
--------------------------------------+------------------------------------
     Reporter:  Mike Tigas            |                    Owner:  Paulo
         Type:  Cleanup/optimization  |                   Status:  assigned
    Component:  contrib.contenttypes  |                  Version:  1.4
     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 Tim Graham):

 * needs_better_patch:  1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/18620#comment:9>
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/064.37d54187483e24e94a6183cafebb21f7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect

Django
In reply to this post by Django
#18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" redirect
-------------------------------------+-------------------------------------
     Reporter:  Mike Tigas           |                    Owner:  Paulo
         Type:                       |                   Status:  assigned
  Cleanup/optimization               |
    Component:                       |                  Version:  1.4
  contrib.contenttypes               |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * stage:  Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/18620#comment:10>
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/064.db53722f67c0f60cc334c7c68e445ce6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.