Example #1
0
def import_bookmark(request, template_name='bookmark/import_bookmark.html'):
    file_form = FileForm(request.POST or None, request.FILES or None)
    if request.method == 'POST' and file_form.is_valid():
        file = request.FILES['file']
        tags_input = file_form.cleaned_data['tags']
        public = file_form.cleaned_data['public']
        try:
            bookmarks = parse_firefox_bookmark(file)
            for bk in bookmarks:
                try:
                    bookmark = Bookmark.objects.create(url=bk['url'],
                                                       title=bk['title'],
                                                       owner=request.user,
                                                       public=public)
                    if tags_input:
                        tags = tags_input
                    else:
                        tags = parse_tags(bk['tags'])
                    for tag in tags:
                        bookmark.tags.add(tag)
                    # Update the screen shot
                    update_bk_screen_shot_async(bookmark)
                except Exception:
                    pass
            return HttpResponseRedirect(reverse("my_bookmark"))
        except Exception, e:
            file_form._errors[NON_FIELD_ERRORS] = ErrorList([e.message])
Example #2
0
def import_bookmark(request, template_name='bookmark/import_bookmark.html'):
    file_form = FileForm(request.POST or None, request.FILES or None)
    if request.method == 'POST' and file_form.is_valid():
        file = request.FILES['file']
        tags_input = file_form.cleaned_data['tags']
        public =file_form.cleaned_data['public']
        try:
            bookmarks = parse_firefox_bookmark(file)
            for bk in bookmarks:
                try:
                    bookmark = Bookmark.objects.create(url=bk['url'], title=bk['title'], owner=request.user, public=public)
                    if tags_input:
                        tags = tags_input
                    else:
                        tags=parse_tags(bk['tags'])
                    for tag in tags:
                        bookmark.tags.add(tag)
                    # Update the screen shot
                    update_bk_screen_shot_async(bookmark)
                except Exception:
                    pass
            return HttpResponseRedirect(reverse("my_bookmark"))
        except Exception, e:
            file_form._errors[NON_FIELD_ERRORS] = ErrorList([e.message])
Example #3
0
 def update_bk_image():
     bookmarks = Bookmark.objects.all()
     for bookmark in bookmarks:
         if bookmark.screen_shot:
             continue
         utils.update_bk_screen_shot_async(bookmark)