Exemple #1
0
def video_widget(context, request, default_video='intro'):
    videos = utility_finder(context, 'videos')
    try:
        video = videos.get(context.default_video, default_video)
    except:
        video = videos.get(default_video)
    return ResponseTemplate('widgets/video.html', context=context, request=request, video=video)
Exemple #2
0
def edit_channel_action(context, request):
    form = request.POST
    name = context.__name__
    channels = utility_finder(context, 'channels')
    videos = utility_finder(context, 'videos')
    if not channels.is_stored(name):
        logging.info(context)
        channels[name] = Channel(name)
        transaction.commit()
        context = channels[name]
    
    for att in ['title', 'description']:
        setattr(context, att, form.get('channel.%s' % att))
    
    context.pre_roll = form.get('sting.pre_roll', '')
    context.end_roll = form.get('sting.end_roll', '')
    transaction.commit()
    sting_videos = [('', 'No Video')]
    sting_videos.extend([(video.__name__, video.name) for video in videos.values()])
    return ResponseTemplate('pages/edit_channel.html', context=context, sting_videos=sting_videos, message='Channel updated successfully')
Exemple #3
0
 def __call__(self, environ, start_response):
     root = environ['webob.adhoc_attrs']['root']
     path = environ['PATH_INFO'].lstrip('/').split('/')
     res = HTTPNotFound()
     if len(path) == 1:
         path = path[0]
         # we should have a look to see if we want to forward to a resource
         for util in utility_finder.utilities():
             utility = utility_finder(root, util).keys()
             if path in utility:
                 res = HTTPMovedPermanently(location = '/%s/%s' % (util, path))
     return res(environ, start_response)
Exemple #4
0
def video(context, request):
    channels = utility_finder(context, 'channels')
    pre = []
    post = []
    for tag in context.tags:
        channel = channels[tag]
        if channel.pre_roll:
            pre.append(channel.pre_roll)
        if channel.end_roll:
            post.append(channel.end_roll)
    playlist = context.get_playlist(pre, post)
    return ResponseTemplate('pages/video.html', context=context, playlist=playlist)
Exemple #5
0
def not_found(context, request):
    environ = request.environ
    root = environ['webob.adhoc_attrs']['root']
    path = environ['PATH_INFO'].lstrip('/').split('/')
    res = HTTPNotFound()
    if len(path) == 1:
        path = path[0]
        # we should have a look to see if we want to forward to a resource
        for util in utility_finder.utilities():
            utility = utility_finder(root, util).keys()
            if path in utility:
                res = HTTPMovedPermanently(location = '/%s/%s' % (util, path))
    return res
Exemple #6
0
def tag(context, request):
    p_root = getUtility(IRootFactory).get_root(request.environ)
    videos = utility_finder(p_root, 'videos')
    videos = [render_view(video,request,'video_listing_widget') for video in videos.values()]
    return ResponseTemplate('pages/tag.html', context=context, videos=videos)
Exemple #7
0
def set_default_video_action(context, request):
    form = request.POST
    video = form.get('video.name')
    if not video:
        return ResponseTemplate('pages/set_default_video.html', context=context, message='Please select a video', videos=utility_finder(context, 'videos').values())
    context.default_video = video
    import transaction
    transaction.commit()
    return ResponseTemplate('pages/set_default_video.html', context=context, message='Default video set to %s' % video, videos=utility_finder(context, 'videos').values())
Exemple #8
0
def set_default_video_form(context, request):
    videos = utility_finder(context, 'videos')
    return ResponseTemplate('pages/set_default_video.html', context=context, message='Please select the video you would like to play on the home page', videos=videos.values())
Exemple #9
0
 def get_listings(self):
     from mint.repoze.root import utility_finder
     videos = utility_finder(self, 'videos')
     return [video for video in videos.values() if self.__name__ in video.tags]
Exemple #10
0
def edit_channel_form(context, request):
    videos = utility_finder(context, 'videos')
    sting_videos = [('', 'No Video')]
    sting_videos.extend([(video.__name__, video.name) for video in videos.values()])
    return ResponseTemplate('pages/edit_channel.html', context=context, sting_videos=sting_videos, message='please update the information in the form below')