Serotonin Storm

source>core>context_processors.py
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
from django.conf import settings
from elsewhere.models import SocialNetworkProfile
from basic.blog.models import Category
import os
from random import choice

PICS = (
    'http://farm3.static.flickr.com/2530/3840686350_59a58fc406_o.png',
    'http://farm3.static.flickr.com/2440/3839898101_1fa62aa53e_o.png',
    'http://farm3.static.flickr.com/2474/3840686850_fa6cf00f8c_o.png',
    'http://farm3.static.flickr.com/2614/3840687032_f6596cc065_o.png',
    'http://farm3.static.flickr.com/2624/3840687240_fa1b2328f8_o.png',
    'http://farm3.static.flickr.com/2508/3839898847_1be5bba795_o.png',
    'http://farm4.static.flickr.com/3428/3840687754_78bf23d74c_o.png',
    'http://farm3.static.flickr.com/2531/3839899421_4f91838a2a_o.png',
    'http://farm3.static.flickr.com/2462/3840688156_fe52ce6919_o.png',
    'http://farm3.static.flickr.com/2671/3839899879_de1e7c04a3_o.png',
    'http://farm3.static.flickr.com/2467/3840688588_52662c7403_o.png',
    'http://farm3.static.flickr.com/2604/3840688802_23e4a7e7dc_o.png',
    'http://farm3.static.flickr.com/2521/3839900451_638995a510_o.png',
    'http://farm3.static.flickr.com/2590/3840689346_db62914360_o.png',
    'http://farm3.static.flickr.com/2544/3839900995_356a301d29_o.png',
    'http://farm3.static.flickr.com/2676/3840689702_90d3321e76_o.png',
    'http://farm4.static.flickr.com/3425/3839901395_8234bde5c8_o.png',
    'http://farm3.static.flickr.com/2505/3840690040_5cafe6a2b1_o.png',
    'http://farm3.static.flickr.com/2514/3839901775_5264750844_o.png',
    'http://farm3.static.flickr.com/2486/3839901893_efc885c0dd_o.png',
    'http://farm3.static.flickr.com/2596/3839902085_c077389e94_o.png',
    'http://farm3.static.flickr.com/2604/3839902279_17b791d326_o.png',
    'http://farm3.static.flickr.com/2439/3840690960_6a7f8cdc05_o.png',
    'http://farm3.static.flickr.com/2506/3839902673_cd055fae8d_o.png',
    'http://farm4.static.flickr.com/3503/3840691460_4f04f4de11_o.png',
    'http://farm3.static.flickr.com/2500/3840691634_b290ed5ec1_o.png',
    'http://farm4.static.flickr.com/3497/3840691868_32b9bf06fd_o.png',
    'http://farm3.static.flickr.com/2649/3839903613_38a9ff1756_o.png',
    'http://farm3.static.flickr.com/2496/3840692270_310e9af846_o.png',
    'http://farm3.static.flickr.com/2425/3840692598_709b811000_o.png',
    'http://farm3.static.flickr.com/2590/3840692824_ef4b5f9827_o.png',
    'http://farm4.static.flickr.com/3486/3839904519_328fbf250f_o.png',
    'http://farm3.static.flickr.com/2636/3840693226_be78c11e0b_o.png',
    'http://farm3.static.flickr.com/2462/3839904847_359ce5aeb4_o.png',
    'http://farm4.static.flickr.com/3569/3840693636_c7358dc204_o.png',
    'http://farm4.static.flickr.com/3519/3839905251_eb330dab52_o.png',
    'http://farm4.static.flickr.com/3517/3840694036_a66c4a3540_o.png',
    'http://farm4.static.flickr.com/3506/3839905665_3ef37b668a_o.png',
    'http://farm3.static.flickr.com/2652/3840694396_5e6157e828_o.png',
    'http://farm3.static.flickr.com/2582/3839906125_6fbffd76c6_o.png',
    'http://farm3.static.flickr.com/2631/3840694926_2ec7da3ba6_o.png',
    'http://farm4.static.flickr.com/3457/3840695146_32fb93fc87_o.png',
    'http://farm3.static.flickr.com/2443/3840695330_8c7f759ed5_o.png',
    'http://farm3.static.flickr.com/2586/3840695552_c666743937_o.png',
    'http://farm4.static.flickr.com/3514/3840695750_a36b91aa78_o.png',
    'http://farm3.static.flickr.com/2432/3840695938_7f32e1f212_o.png',
    'http://farm3.static.flickr.com/2603/3840696124_1271fa14c3_o.png',
    'http://farm4.static.flickr.com/3463/3839907965_9bab69f178_o.png',
    'http://farm3.static.flickr.com/2575/3839908143_7a0a0b0cda_o.png',
    'http://farm3.static.flickr.com/2458/3839908329_681a077506_o.png',
    'http://farm3.static.flickr.com/2646/3840696868_d71e1fa05d_o.png',
    'http://farm4.static.flickr.com/3580/3839908619_c86eba7e8c_o.png',
    'http://farm4.static.flickr.com/3522/3839908779_b4b1b1ea34_o.png',
    'http://farm3.static.flickr.com/2525/3839908949_72608aa33e_o.png',
    'http://farm4.static.flickr.com/3427/3840697696_78eaa1f465_o.png',
    'http://farm4.static.flickr.com/3495/3840697892_2a967d5b3a_o.png',
    'http://farm3.static.flickr.com/2496/3840698088_0d8f4906bd_o.png',
    'http://farm4.static.flickr.com/3481/3840698258_12817ae8ef_o.png',    
)


def site_info(request):
    """
    Adds site-specific meta information to the context.
    
    To employ, add the site_info method reference to your project 
    settings TEMPLATE_CONTEXT_PROCESSORS.
    
    Example:
        TEMPLATE_CONTEXT_PROCESSORS = (
            ...
            "mingus.core.context_processors.site_info",
        )
    """
    
    SITE_NAME = getattr(settings, 'SITE_NAME', '')
    SITE_DOMAIN = getattr(settings, 'SITE_DOMAIN', '')
    SITE_URL = getattr(settings, 'SITE_URL', '')
    FEED_SUBSCRIBE_RSS = getattr(settings, 'FEED_SUBSCRIBE_RSS', '')
    FEED_SUBSCRIBE_EMAIL = getattr(settings, 'FEED_SUBSCRIBE_EMAIL', '')
    ELSEWHERE = SocialNetworkProfile.objects.all()
    CATEGORIES = Category.objects.all().order_by('title')
    STATIC_URL = getattr(settings,'STATIC_URL', '')
    return {
        'request':request,
        'PICS': [choice(PICS) for _ in range(3)],
        'STATIC_URL': STATIC_URL,
        'SITE_NAME': SITE_NAME,
        'SITE_DOMAIN': SITE_DOMAIN,
        'SITE_URL': SITE_URL,
        'FEED_SUBSCRIBE_RSS':FEED_SUBSCRIBE_RSS,
        'FEED_SUBSCRIBE_EMAIL':FEED_SUBSCRIBE_EMAIL,
        'ELSEWHERE': ELSEWHERE,
        'CATEGORIES': CATEGORIES,
    }