__init__.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. """
  2. Provides models and utilities for displaying different types of Twitter feeds.
  3. """
  4. from __future__ import unicode_literals
  5. from django.utils.translation import ugettext_lazy as _
  6. from mezzanine import __version__ # noqa
  7. # Constants/choices for the different query types.
  8. QUERY_TYPE_USER = "user"
  9. QUERY_TYPE_LIST = "list"
  10. QUERY_TYPE_SEARCH = "search"
  11. QUERY_TYPE_CHOICES = (
  12. (QUERY_TYPE_USER, _("User")),
  13. (QUERY_TYPE_LIST, _("List")),
  14. (QUERY_TYPE_SEARCH, _("Search")),
  15. )
  16. def get_auth_settings():
  17. """
  18. Returns all the key/secret settings for Twitter access,
  19. only if they're all defined.
  20. """
  21. from mezzanine.conf import settings
  22. try:
  23. auth_settings = (settings.TWITTER_CONSUMER_KEY,
  24. settings.TWITTER_CONSUMER_SECRET,
  25. settings.TWITTER_ACCESS_TOKEN_KEY,
  26. settings.TWITTER_ACCESS_TOKEN_SECRET)
  27. except AttributeError:
  28. return None
  29. else:
  30. return auth_settings if all(auth_settings) else None