|
Revision 863, 1.4 kB
(checked in by rafael.soares, 2 years ago)
|
|
version number added in the foot page, close #251
|
| Line | |
|---|
| 1 | from django.conf import settings |
|---|
| 2 | from django.core.cache import cache |
|---|
| 3 | import urllib |
|---|
| 4 | from django.utils.safestring import mark_safe |
|---|
| 5 | |
|---|
| 6 | def polyglot(request): |
|---|
| 7 | context_extra = {} |
|---|
| 8 | |
|---|
| 9 | context_extra['MANAGED_LANGUAGES_CHOICES'] = settings.MANAGED_LANGUAGES_CHOICES |
|---|
| 10 | context_extra['TARGET_LANGUAGES'] = settings.TARGET_LANGUAGES |
|---|
| 11 | context_extra['MANAGED_LANGUAGES_LC'] = [c.lower() for c in settings.MANAGED_LANGUAGES] |
|---|
| 12 | |
|---|
| 13 | return context_extra |
|---|
| 14 | |
|---|
| 15 | def google_analytics(request): |
|---|
| 16 | context_extra = {} |
|---|
| 17 | |
|---|
| 18 | if hasattr(settings, 'GOOGLE_ANALYTICS_ID') and settings.GOOGLE_ANALYTICS_ID != '': |
|---|
| 19 | context_extra['GOOGLE_ANALYTICS_ID'] = settings.GOOGLE_ANALYTICS_ID |
|---|
| 20 | |
|---|
| 21 | return context_extra |
|---|
| 22 | |
|---|
| 23 | def latest_tweets(request): |
|---|
| 24 | if not settings.TWITTER: |
|---|
| 25 | return {"tweets": ""} |
|---|
| 26 | |
|---|
| 27 | tweets = cache.get('tweets', '') |
|---|
| 28 | |
|---|
| 29 | if tweets: |
|---|
| 30 | return {"tweets": tweets} |
|---|
| 31 | |
|---|
| 32 | tweets = urllib.urlopen("http://twitter.com/statuses/user_timeline/"+ settings.TWITTER +".json?callback=twitterCallback2&count=2").readlines() |
|---|
| 33 | if len(tweets) > 0: |
|---|
| 34 | tweets = mark_safe(tweets[0]) |
|---|
| 35 | cache.set('tweets', tweets, settings.TWITTER_TIMEOUT) |
|---|
| 36 | |
|---|
| 37 | return {"tweets": tweets} |
|---|
| 38 | |
|---|
| 39 | def debug(request): |
|---|
| 40 | return {'DEBUG': settings.DEBUG} |
|---|
| 41 | |
|---|
| 42 | def default_from_email(request): |
|---|
| 43 | return {'DEFAULT_FROM_EMAIL': settings.DEFAULT_FROM_EMAIL} |
|---|
| 44 | |
|---|
| 45 | def opentrials_version(request): |
|---|
| 46 | return {'OPENTRIALS_VERSION': settings.OPENTRIALS_VERSION} |
|---|