freedomofpress / pressfreedomtracker.us

Code for the U.S. Press Freedom Tracker project website
https://pressfreedomtracker.us
GNU Affero General Public License v3.0
17 stars 7 forks source link

Search includes pages that are not accessible #422

Closed nmorduch closed 7 years ago

nmorduch commented 7 years ago

Search for journalists and the organization page for cpj comes up, but you can't go to that page

image

emilyhorsman commented 7 years ago

Request Method: GET
Request URL: http://localhost:8000/organizations/committee-protect-journalists/

Django Version: 1.11.3
Python Version: 3.4.6
Installed Applications:
['autocomplete',
 'search',
 'blog',
 'common',
 'forms',
 'incident',
 'statistics',
 'menus',
 'styleguide',
 'dashboard',
 'home',
 'wagtail.contrib.settings',
 'wagtail.contrib.wagtailroutablepage',
 'wagtail.wagtailforms',
 'wagtail.wagtailredirects',
 'wagtail.wagtailembeds',
 'wagtail.wagtailsites',
 'wagtail.wagtailusers',
 'wagtail.wagtailsnippets',
 'wagtail.wagtaildocs',
 'wagtail.wagtailimages',
 'wagtail.wagtailsearch',
 'wagtail.wagtailadmin',
 'wagtail.wagtailcore',
 'modelcluster',
 'taggit',
 'webpack_loader',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
['django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'wagtail.wagtailcore.middleware.SiteMiddleware',
 'wagtail.wagtailredirects.middleware.RedirectMiddleware']

Template loader postmortem
Django tried loading these templates, in this order:

Using engine django:
    * django.template.loaders.filesystem.Loader: /var/www/django/pressfreedom/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /var/www/django/autocomplete/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /var/www/django/search/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /var/www/django/blog/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /var/www/django/common/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /var/www/django/forms/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /var/www/django/incident/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /var/www/django/statistics/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /var/www/django/styleguide/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /var/www/django/dashboard/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /var/www/django/home/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/site-packages/wagtail/contrib/settings/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/site-packages/wagtail/wagtailforms/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/site-packages/wagtail/wagtailredirects/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/site-packages/wagtail/wagtailembeds/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/site-packages/wagtail/wagtailsites/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/site-packages/wagtail/wagtailusers/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/site-packages/wagtail/wagtailsnippets/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/site-packages/wagtail/wagtaildocs/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/site-packages/wagtail/wagtailimages/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/site-packages/wagtail/wagtailsearch/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/site-packages/wagtail/wagtailadmin/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/site-packages/wagtail/wagtailcore/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/site-packages/django/contrib/admin/templates/common/organization_page.html (Source does not exist)
    * django.template.loaders.app_directories.Loader: /usr/local/lib/python3.4/site-packages/django/contrib/auth/templates/common/organization_page.html (Source does not exist)

Traceback:

File "/usr/local/lib/python3.4/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/usr/local/lib/python3.4/site-packages/django/core/handlers/base.py" in _get_response
  217.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python3.4/site-packages/django/core/handlers/base.py" in _get_response
  215.                 response = response.render()

File "/usr/local/lib/python3.4/site-packages/django/template/response.py" in render
  107.             self.content = self.rendered_content

File "/usr/local/lib/python3.4/site-packages/django/template/response.py" in rendered_content
  82.         template = self.resolve_template(self.template_name)

File "/usr/local/lib/python3.4/site-packages/django/template/response.py" in resolve_template
  66.             return get_template(template, using=self.using)

File "/usr/local/lib/python3.4/site-packages/django/template/loader.py" in get_template
  25.     raise TemplateDoesNotExist(template_name, chain=chain)

Exception Type: TemplateDoesNotExist at /organizations/committee-protect-journalists/
Exception Value: common/organization_page.html
msheiny commented 7 years ago

Here's more data from the logs:

ERROR - {"exception":{"message":"common/organization_page.html","type":"django.template.exceptions.TemplateDoesNotExist","request":{"path":"/organizations/committee-protect-journalists/","data":{},"method":"GET","scheme":"https","meta":{"path_info":"/organizations/committee-protect-journalists/","remote_addr":"127.0.0.1","http_x_forwarded_for":"xxxxxxxxxxx","http_authorization":"Basic xxxxxxxxxxxxxxxxxxxxxx","http_host":"pressfreedomtracker.us","http_user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"},"user":"AnonymousUser"}}

Traceback:

 {
  "file": "/home/gcorn/pressfreedom/lib/python3.4/site-packages/django/core/handlers/base.py",
  "method": "_get_response",
  "line": 215
},
{
  "file": "/home/gcorn/pressfreedom/lib/python3.4/site-packages/django/template/response.py",
  "method": "render",
  "line": 107
},
{
  "file": "/home/gcorn/pressfreedom/lib/python3.4/site-packages/django/template/response.py",
  "method": "rendered_content",
  "line": 82
},
{
  "file": "/home/gcorn/pressfreedom/lib/python3.4/site-packages/django/template/response.py",
  "method": "resolve_template",
  "line": 66
},
{
  "file": "/home/gcorn/pressfreedom/lib/python3.4/site-packages/django/template/loader.py",
  "method": "get_template",
  "line": 25
}
nmorduch commented 7 years ago

Unless I am incorrect, the issue is not the error, and is that you should not be offered that link, because organizations are only pages for the purposes of Wagtail. @harrislapiroff ?

nmorduch commented 7 years ago

Waitttt we do have org pages.

...But through the blog. Hm.

chigby commented 7 years ago

I think I added those links in the blog. No idea if that was correct. I assumed they were meant to be displayed?

nmorduch commented 7 years ago

They appear to be two different pages.

harrislapiroff commented 7 years ago

You're correct the first time, @nmorduch. We have those as page models, but we never made templates because we don't use them anywhere. The purpose of creating the blog filtering was to have links to the filtered BlogIndexPage instead.

harrislapiroff commented 7 years ago

I guess we need to remove any links that were added to the blog and exclude some page types from search. I assume that's a thing we can do.

nmorduch commented 7 years ago

The links in the blog are not those links, is what I'm saying. I think Cameron mistakenly thought he used them?

harrislapiroff commented 7 years ago

Okay, so then the ticket here should just be to exclude OrganizationPage and AuthorPage from search results.