예제 #1
0
def get_youtube_img(story):
    if story.video != "":
        video_id = story.video.split('?v=')[1]
        return "http://img.youtube.com/vi/%s/sddefault.jpg" % video_id
    else:
        logger.log(
            "story.video equals empty string. Can't grab image for this story: ",
            story)
예제 #2
0
def get_youtube_img(story):
    if story.video:
        video_id = story.video.split('?v=')[1]
        if '&' in video_id:
            video_id = video_id[0:video_id.index('&')]
        return "https://img.youtube.com/vi/%s/hqdefault.jpg" % video_id
    else:
        logger.log(
            "story.video equals empty string. Can't grab image for this story: ",
            story)
예제 #3
0
def update_story(form, story):
    logger.log("save_story called")
    data = form.cleaned_data
    story.title = data['title']
    story.date = data['date']
    story.source = data['source']
    if data['text'] != u'':
        story.text = data['text']
    elif data['image'] != u'':        
        story.image = data['image'] 
    elif data['video'] != u'':        
        story.video = data['video']
    return story
예제 #4
0
def update_story(form, story):
    logger.log("save_story called")
    data = form.cleaned_data
    story.title = data['title']
    story.date = data['date']
    story.source = data['source']
    if data['text'] != u'':
        story.text = data['text']
    elif data['image'] != u'':
        story.image = data['image']
    elif data['video'] != u'':
        story.video = data['video']
    return story
예제 #5
0
 def __init__(self, content, status=None, content_type='application/json'):
     if isinstance(content, BaseModel):
         content = serializers.serialize("json", [content])
     elif isinstance(content, dict):
         content = json.dumps(content)
     elif isinstance(content, list):
         content = serializers.serialize("json", content)
     else:
         logger.log("", "JsonResponse content is of unknown type.")
     super(JsonResponse, self).__init__(
         content=content,
         status=status,
         content_type=content_type,
     )
예제 #6
0
 def __init__(self, content, mimetype='application/json', status=None, content_type=None):
     if isinstance(content, BaseModel):
         content = serializers.serialize("json", [content])
     elif isinstance(content, dict):
         content = simplejson.dumps(content)
     elif isinstance(content, list):
         content = serializers.serialize("json", content)
     else:
         logger.log("", "JsonResponse content is of unknown type.")
     super(JsonResponse, self).__init__(
         content=content,
         mimetype=mimetype,
         status=status,
         content_type=content_type,
     )
예제 #7
0
def add_page(request):
    if not request.user.is_authenticated():
        return redirect('/accounts/login/')
    if request.method == 'POST':
        form = PageForm(request.POST)
        if form.is_valid():
            # Create the Page
            page = create_page(form, request)
            page.save()
            return redirect('/edit/page/{}'.format(page.vanity_url))
        else:
            logger.log("Form Errors: ", form.errors)
    else:
        form = PageForm()

    return locals()
예제 #8
0
def add_page(request):
    if not request.user.is_authenticated():
        return redirect('/accounts/login/')
    if request.method == 'POST':
        form = PageForm(request.POST)
        if form.is_valid():
            # Create the Page
            page = create_page(form, request)
            page.save()
            return redirect('/edit/page/{}'.format(page.vanity_url))
        else:
            logger.log("Form Errors: ", form.errors)
    else:
        form = PageForm()

    return locals()
예제 #9
0
def timeline(request):
    pages = Page.objects.filter(published=True)
    pages_json = serializers.serialize("json", pages)
    logger.log("pages_json: ", pages_json)
    return JsonResponse(pages_json);
예제 #10
0
def get_youtube_img(story):
    if story.video != "":
        video_id = story.video.split('?v=')[1]
        return "http://img.youtube.com/vi/%s/sddefault.jpg" % video_id
    else:
        logger.log("story.video equals empty string. Can't grab image for this story: ", story)
예제 #11
0
def timeline(request):
    pages = Page.objects.filter(published=True)
    pages_json = serializers.serialize("json", pages)
    logger.log("pages_json: ", pages_json)
    return JsonResponse(pages_json)