Beispiel #1
0
def world(request):
    if request.method == 'GET':
        form = AddLinkForm()
        news_list = []
        if request.user.is_authenticated():
            username = request.user.username
        else:
            username = "******"
        usr = userInfo(username)
        bookmarklist = usr.get_bookmarks()
        for news in bookmarklist[0:6]:
            news_to_render = ShowNewsList()
            news_to_render.theme = news['title']
            news_to_render.text = news['text'][0:200] + "..."
            news_to_render.author = news['author']
            news_to_render.day = '4'
            news_to_render.month = 'May'
            news_to_render.keywords = news['keywords']
            news_to_render.weblinks = news['url']
            news_list.append(news_to_render)

        template = loader.get_template('world.html')
        context = RequestContext(
            request,
            {
                'object_list': news_list,
                'form': form,
                # 'userInfo':userInfo,
            })
        return HttpResponse(template.render(context))
Beispiel #2
0
def index(request):
    if request.method == 'POST':
        if request.user.is_authenticated():
            username = request.user.username
            usr = userInfo(username)
            # create a form instance and populate it with data from the request:
            form = AddLinkForm(request.POST)
            # check whether it's valid:
            if form.is_valid():
                url = form.cleaned_data['LinkName']
                usr.set_bookmark(url)
            # if a GET (or any other method) we'll create a blank form
    else:
        form = AddLinkForm()
        news_list = []
        if request.user.is_authenticated():
            username = request.user.username
        else:
            username = "******"
        usr = userInfo(username)
        bookmarklist = usr.get_bookmarks()
        for news in bookmarklist[0:6]:
            news_to_render = ShowNewsList()
            news_to_render.theme = news['title']
            news_to_render.text = news['text'][0:200] + "..."
            news_to_render.author = news['author']
            news_to_render.day = '4'
            news_to_render.month = 'May'
            news_to_render.keywords = news['keywords']
            news_to_render.weblinks = news['url']
            news_list.append(news_to_render)

        template = loader.get_template('index.html')
        context = RequestContext(
            request,
            {
                'object_list': news_list,
                'form': form,
                # 'userInfo':userInfo,
            })
        return HttpResponse(template.render(context))
Beispiel #3
0
def get_data(request):
    if request.method == 'POST':
        mydata = request.read()
        str_list = mydata.split('&')
        [str1, number] = str_list[0].split('=')
        [str2, offset] = str_list[1].split('=')
        [str3, desc] = str_list[2].split('=')

    if desc == 'index':
        usr = userInfo("anonymous")
    else:
        usr = userInfo(desc)

    bookmarklist = usr.get_bookmark_scroll(int(number), int(offset))
    data = ""
    for news in bookmarklist:
        data += '<li><div class="date"><p><span>' + '4' + '</span>'
        data += 'May' + '</p></div><h2 ><a href='
        data += news['url'] + '>' + news['title']
        data += '</a></h2><p>' + news['text'][0:200] + "..." + '</p></li>'
    return HttpResponse(data)