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)
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)
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
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, )
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, )
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()
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);
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)
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)