freedomofpress / securethenews

An automated scanner and web dashboard for tracking TLS deployment across news organizations
https://securethe.news
GNU Affero General Public License v3.0
100 stars 25 forks source link

Mix-in whitenoise library #183

Closed msheiny closed 5 years ago

msheiny commented 5 years ago

Allow serving static assets via whitenoise library. This simplifies the deployment story significantly :clap:

Please review and merge https://github.com/freedomofpress/securethenews/pull/182 to get a more accurate representation of changes this PR introduces

msheiny commented 5 years ago

So I've seen this error sporadically during my testing and it's also showing up in CI. I might need some help on this one @harrislapiroff / @chigby . I wouldn't merge this PR until we are confident that its not a persistent problem.

Traceback (most recent call last):
  File "./manage.py", line 13, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/test.py", line 29, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/test.py", line 62, in handle
    failures = test_runner.run_tests(test_labels)
  File "/usr/local/lib/python3.6/site-packages/django/test/runner.py", line 602, in run_tests
    self.run_checks()
  File "/usr/local/lib/python3.6/site-packages/django/test/runner.py", line 562, in run_checks
    call_command('check', verbosity=self.verbosity)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 131, in call_command
    return command.execute(*args, **defaults)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/check.py", line 68, in handle
    fail_level=getattr(checks, options['fail_level']),
  File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
    include_deployment_checks=include_deployment_checks,
  File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "/usr/local/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/usr/local/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
    return check_resolver(resolver)
  File "/usr/local/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
    return check_method()
  File "/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 256, in check
    for pattern in self.url_patterns:
  File "/usr/local/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 407, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.6/site-packages/django/urls/resolvers.py", line 400, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/django/securethenews/urls.py", line 8, in <module>
    from wagtail.wagtailadmin import urls as wagtailadmin_urls
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailadmin/urls/__init__.py", line 8, in <module>
    from wagtail.wagtailadmin.api import urls as api_urls
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailadmin/api/urls.py", line 13, in <module>
    for fn in hooks.get_hooks('construct_admin_api'):
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailcore/hooks.py", line 49, in get_hooks
    search_for_hooks()
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailcore/hooks.py", line 43, in search_for_hooks
    list(get_app_submodules('wagtail_hooks'))
  File "/usr/local/lib/python3.6/site-packages/wagtail/utils/apps.py", line 25, in get_app_submodules
    yield name, import_module('%s.%s' % (name, submodule_name))
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailembeds/wagtail_hooks.py", line 8, in <module>
    from wagtail.wagtailadmin.rich_text import HalloPlugin
  File "/usr/local/lib/python3.6/site-packages/wagtail/wagtailadmin/rich_text.py", line 77, in <module>
    static('wagtailadmin/js/hallo-plugins/hallo-requireparagraphs.js'),
  File "/usr/local/lib/python3.6/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py", line 12, in static
    return _static(path)
  File "/usr/local/lib/python3.6/site-packages/django/templatetags/static.py", line 166, in static
    return StaticNode.handle_simple(path)
  File "/usr/local/lib/python3.6/site-packages/django/templatetags/static.py", line 117, in handle_simple
    return staticfiles_storage.url(path)
  File "/usr/local/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 162, in url
    return self._url(self.stored_name, name, force)
  File "/usr/local/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 141, in _url
    hashed_name = hashed_name_func(*args)
  File "/usr/local/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 432, in stored_name
    raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name)
ValueError: Missing staticfiles manifest entry for 'wagtailadmin/js/hallo-plugins/hallo-requireparagraphs.js'
msheiny commented 5 years ago

So i think i'm hitting https://github.com/wagtail/wagtail/issues/3829

Which basically will require a wagtail bump to fix. I don't want to do that quite yet (and go down a rabbit hole) and since @freedomofpress/fpf-web-developers are on that in other tickets... im going with the work-around which is to run migrate AFTER collect static :)

msheiny commented 5 years ago

Ahhh this is passing.. Quick merge it!!