Revision c14ab89f okeanos_site/views.py

b/okeanos_site/views.py
1
import urllib2
2

  
1 3
from django.views.generic.simple import direct_to_template
2 4
from django.conf import settings
3 5

  
6
OKEANOS_NEWS_CONTENT_URL = getattr(settings, 'OKEANOS_NEWS_CONTENT_URL', False)
7

  
4 8
OKEANOS_STATIC = getattr(settings, 'OKEANOS_STATIC_URL', '/okeanos_static/')
5 9
OKEANOS_SITE_URL = getattr(settings, 'OKEANOS_SITE_URL', '/okeanos')
6 10
OKEANOS_VIDEO_URL = getattr(settings, 'OKEANOS_VIDEO_URL', '')
......
21 25
    'VIDEO_HEIGHT': 360
22 26
}
23 27

  
28
def _load_news_content():
29
    """
30
    Import news html content from external location
31
    """
32
    data = ""
33
    if not OKEANOS_NEWS_CONTENT_URL:
34
        return data
35

  
36
    try:
37
        response = urllib2.urlopen(OKEANOS_NEWS_CONTENT_URL, '', 5)
38
        data = response.read()
39
    except:
40
        pass
41

  
42
    return data
43

  
24 44
def intro(request):
25 45
    return direct_to_template(request, "okeanos/intro.html", context)
26 46

  
27 47
def index(request):
48
    news_context = {'news_content':_load_news_content()}
49
    context.update(news_context)
28 50
    return direct_to_template(request, "okeanos/index.html", context)
29 51

  

Also available in: Unified diff