Beispiel #1
0
def gedcom(request, gedcom_id):
    g = get_object_or_404(Gedcom, id=gedcom_id)
    post = BlogPost.objects.all().order_by("-created")
    if post:
        post = post[0]

    if request.method == 'POST':
        form = comment_action(request, 'Gedcom #' + str(g.id))
        return render_to_response('gedgo/gedcom.html', {
            'gedcom': g,
            'post': post,
            'form': form
        },
                                  context_instance=RequestContext(
                                      request, site_context(request)))
    else:
        form = CommentForm()

    return render_to_response('gedgo/gedcom.html', {
        'gedcom': g,
        'post': post,
        'form': form
    },
                              context_instance=RequestContext(
                                  request, site_context(request)))
Beispiel #2
0
def person(request, gedcom_id, person_id):
    g = get_object_or_404(Gedcom, id=gedcom_id)
    p = get_object_or_404(Person, gedcom=g, pointer=person_id)
    posts = BlogPost.objects.filter(tagged_people=p)
    events, hindex = timeline(p)
    ancestral_tree = json_tree(p)

    if request.method == 'POST':
        form = comment_action(request, p.full_name() + ' (' + p.pointer + ')')
        return render_to_response('gedgo/person.html', {
            'person': p,
            'posts': posts,
            'gedcom': g,
            'events': events,
            'hindex': hindex,
            'tree': ancestral_tree,
            'form': form
        },
                                  context_instance=RequestContext(
                                      request, site_context(request)))
    else:
        form = CommentForm()

    return render_to_response('gedgo/person.html', {
        'person': p,
        'posts': posts,
        'gedcom': g,
        'events': events,
        'hindex': hindex,
        'tree': ancestral_tree,
        'form': form
    },
                              context_instance=RequestContext(
                                  request, site_context(request)))
Beispiel #3
0
def family(request, family_id, gedcom_id):
    g = get_object_or_404(Gedcom, id=gedcom_id)
    f = get_object_or_404(Family, gedcom=g, pointer=family_id)

    if request.method == 'POST':
        form = comment_action(request, f.family_name() + ' (' + f.pointer + ')')
        return render_to_response('gedgo/family.html',
            {'family': f, 'gedcom': g, 'form': form},
            context_instance=RequestContext(request, site_context(request)))
    else:
        form = CommentForm()

    return render_to_response('gedgo/family.html',
        {'family': f, 'gedcom': g, 'form': form},
        context_instance=RequestContext(request, site_context(request)))
Beispiel #4
0
def gedcom(request, gedcom_id):
    g = get_object_or_404(Gedcom, id=gedcom_id)
    post = BlogPost.objects.all().order_by("-created")
    if post:
        post = post[0]

    if request.method == 'POST':
        form = comment_action(request, 'Gedcom #' + str(g.id))
        return render_to_response('gedgo/gedcom.html', {'gedcom': g, 'post': post, 'form': form},
            context_instance=RequestContext(request, site_context(request)))
    else:
        form = CommentForm()

    return render_to_response('gedgo/gedcom.html', {'gedcom': g, 'post': post, 'form': form},
        context_instance=RequestContext(request, site_context(request)))
Beispiel #5
0
def blog(request, year, month):
    "Blog front page - listing posts by creation date."
    posts = BlogPost.objects.all().order_by("-created")

    if year:
        posts = posts & BlogPost.objects.filter(created__year=year)
    if month:
        posts = posts & BlogPost.objects.filter(created__month=month)

    paginator = Paginator(posts, 2)

    try:
        page = int(request.GET.get("page", '1'))
    except ValueError:
        page = 1

    try:
        posts = paginator.page(page)
    except (InvalidPage, EmptyPage):
        posts = paginator.page(paginator.num_pages)

    months = set((d.year, d.month, datetime(2012, d.month, 1).strftime('%B'))
                 for d in BlogPost.objects.values_list('created', flat=True))

    return render_to_response("gedgo/blogpost_list.html", {
        'posts': posts,
        'months': months
    },
                              context_instance=RequestContext(
                                  request, site_context(request)))
Beispiel #6
0
def researchfiles(request, pathname):
    try:
        root = settings.RESEARCH_FILES_ROOT
    except:
        raise Http404

    r = path.join(root, pathname)

    if path.isfile(r):
        return serve_content(r)
    elif path.isdir(r):
        dir_contents = filter(lambda c: not c[0] == '.', listdir(r))
        dir_contents = map(lambda c: (path.isdir(path.join(r, c)), c), dir_contents)

        if (len(pathname) > 0) and (not pathname[0] == '/'):
            pathname = '/' + pathname
        pathname = path.normpath(pathname)
        if pathname == '.':
            pathname = ''

        levels = pathname.split('/')  # Is there a better way than this?

        if len(pathname) < 2:
            current_level = 'Research Files'
        else:
            current_level = levels[-1]

        return render_to_response('gedgo/researchfiles.html',
            {'contents': dir_contents, 'levels': levels, 'path': pathname,
            'current_level': current_level},
            context_instance=RequestContext(request, site_context(request)))
    else:
        raise Http404
Beispiel #7
0
def documentaries(request):
    documentaries = Documentary.objects.all().order_by('-last_updated')

    return render_to_response("gedgo/documentaries.html",
                              {'documentaries': documentaries},
                              context_instance=RequestContext(
                                  request, site_context(request)))
Beispiel #8
0
Datei: blog.py Projekt: RaD/gedgo
def blog(request, year, month):
    "Blog front page - listing posts by creation date."
    posts = BlogPost.objects.all().order_by("-created")

    if year:
        posts = posts & BlogPost.objects.filter(created__year=year)
    if month:
        posts = posts & BlogPost.objects.filter(created__month=month)

    paginator = Paginator(posts, 2)

    try:
        page = int(request.GET.get("page", '1'))
    except ValueError:
        page = 1

    try:
        posts = paginator.page(page)
    except (InvalidPage, EmptyPage):
        posts = paginator.page(paginator.num_pages)

    months = set(
        (d.year, d.month, datetime(2012, d.month, 1).strftime('%B'))
        for d in BlogPost.objects.values_list('created', flat=True))

    return render_to_response(
        "gedgo/blogpost_list.html",
        {'posts': posts, 'months': months},
        context_instance=RequestContext(request, site_context(request)))
Beispiel #9
0
Datei: blog.py Projekt: RaD/gedgo
def blogpost(request, post_id):
    "Single post."
    post = get_object_or_404(BlogPost, id=post_id)

    if request.method == 'POST':
        form = comment_action(request, post.title + ' (blog post comment)')
        return render_to_response(
            'gedgo/blogpost.html',
            {'post': post, 'form': form},
            context_instance=RequestContext(request, site_context(request)))
    else:
        form = CommentForm()

    return render_to_response(
        "gedgo/blogpost.html",
        {'post': post, 'form': form},
        context_instance=RequestContext(request, site_context(request)))
Beispiel #10
0
def person(request, gedcom_id, person_id):
    g = get_object_or_404(Gedcom, id=gedcom_id)
    p = get_object_or_404(Person, gedcom=g, pointer=person_id)
    posts = BlogPost.objects.filter(tagged_people=p)
    events, hindex = timeline(p)
    ancestral_tree = json_tree(p)

    if request.method == 'POST':
        form = comment_action(request, p.full_name() + ' (' + p.pointer + ')')
        return render_to_response('gedgo/person.html',
            {'person': p, 'posts': posts, 'gedcom': g, 'events': events,
            'hindex': hindex, 'tree': ancestral_tree, 'form': form},
            context_instance=RequestContext(request, site_context(request)))
    else:
        form = CommentForm()

    return render_to_response('gedgo/person.html',
        {'person': p, 'posts': posts, 'gedcom': g, 'events': events,
        'hindex': hindex, 'tree': ancestral_tree, 'form': form},
        context_instance=RequestContext(request, site_context(request)))
Beispiel #11
0
def blogpost(request, post_id):
    "Single post."
    post = get_object_or_404(BlogPost, id=post_id)

    if request.method == 'POST':
        form = comment_action(request, post.title + ' (blog post comment)')
        return render_to_response('gedgo/blogpost.html', {
            'post': post,
            'form': form
        },
                                  context_instance=RequestContext(
                                      request, site_context(request)))
    else:
        form = CommentForm()

    return render_to_response("gedgo/blogpost.html", {
        'post': post,
        'form': form
    },
                              context_instance=RequestContext(
                                  request, site_context(request)))
Beispiel #12
0
def search(request):
    if "q" in request.GET and request.GET["q"]:
        q = request.GET["q"]

        g = Gedcom.objects.all()
        if len(g) > 0:
            g = g[0]

        people = Person.objects.all()
        posts = BlogPost.objects.all()

        for term in findall("\w+", q):  # Throw away non-word characters.
            people = people & (
                Person.objects.filter(last_name__icontains=term)
                | Person.objects.filter(first_name__icontains=term)
                | Person.objects.filter(suffix__icontains=term)
            )
            posts = posts & (
                BlogPost.objects.filter(title__icontains=term) | BlogPost.objects.filter(body__icontains=term)
            )

        if (len(people) == 1) & (len(posts) == 0):
            person = people[0]
            return redirect("/gedgo/" + str(person.gedcom.id) + "/" + person.pointer)

        return render_to_response(
            "gedgo/search_results.html",
            {"people": people, "gedcom": g, "posts": posts, "query": q},
            context_instance=RequestContext(request, site_context(request)),
        )
    else:
        return render_to_response(
            "gedgo/search_results.html",
            {"people": Person.objects.none(), "gedcom": g, "posts": BlogPost.objects.none()},
            context_instance=RequestContext(request, site_context(request)),
        )
Beispiel #13
0
def family(request, family_id, gedcom_id):
    g = get_object_or_404(Gedcom, id=gedcom_id)
    f = get_object_or_404(Family, gedcom=g, pointer=family_id)

    if request.method == 'POST':
        form = comment_action(request,
                              f.family_name() + ' (' + f.pointer + ')')
        return render_to_response('gedgo/family.html', {
            'family': f,
            'gedcom': g,
            'form': form
        },
                                  context_instance=RequestContext(
                                      request, site_context(request)))
    else:
        form = CommentForm()

    return render_to_response('gedgo/family.html', {
        'family': f,
        'gedcom': g,
        'form': form
    },
                              context_instance=RequestContext(
                                  request, site_context(request)))
Beispiel #14
0
def update_view(request, gedcom_id):
    if not request.user.is_superuser:
        return redirect('/gedgo')

    g = get_object_or_404(Gedcom, id=gedcom_id)
    message = ''
    celerystate = inspect()

    if celerystate.active() is not None:  # TODO: Check task names.
        form = ''
        message = 'This gedcom is currently being updated already. Please check back later.'
    elif request.method == 'POST':
        form = UpdateForm(request.POST, request.FILES)
        # check for temp file
        if form.is_valid():
            # TODO: Make friendly to other OSes.
            content = request.FILES['gedcom_file'].read().split("\r")

            # Call celery worker
            async_update.delay(g, content)

            # Redirect to the document list after POST
            form = ''
            message = 'Upload successful. Gedcom updating.'
        else:
            form = UpdateForm()
            message = 'Did you correctly upload a gedcom file?'

    else:
        form = UpdateForm()

    # Render list page with the documents and the form
    return render_to_response('gedgo/update.html', {
        'form': form,
        'message': message,
        'gedcom': g
    },
                              context_instance=RequestContext(
                                  request, site_context(request)))
Beispiel #15
0
def researchfiles(request, pathname):
    try:
        root = settings.RESEARCH_FILES_ROOT
    except:
        raise Http404

    r = path.join(root, pathname)

    if path.isfile(r):
        return serve_content(r)
    elif path.isdir(r):
        dir_contents = filter(lambda c: not c[0] == '.', listdir(r))
        dir_contents = map(lambda c: (path.isdir(path.join(r, c)), c),
                           dir_contents)

        if (len(pathname) > 0) and (not pathname[0] == '/'):
            pathname = '/' + pathname
        pathname = path.normpath(pathname)
        if pathname == '.':
            pathname = ''

        levels = pathname.split('/')  # Is there a better way than this?

        if len(pathname) < 2:
            current_level = 'Research Files'
        else:
            current_level = levels[-1]

        return render_to_response('gedgo/researchfiles.html', {
            'contents': dir_contents,
            'levels': levels,
            'path': pathname,
            'current_level': current_level
        },
                                  context_instance=RequestContext(
                                      request, site_context(request)))
    else:
        raise Http404
Beispiel #16
0
def update_view(request, gedcom_id):
    if not request.user.is_superuser:
        return redirect('/gedgo')

    g = get_object_or_404(Gedcom, id=gedcom_id)
    message = ''
    celerystate = inspect()

    if celerystate.active() is not None:  # TODO: Check task names.
        form = ''
        message = 'This gedcom is currently being updated already. Please check back later.'
    elif request.method == 'POST':
        form = UpdateForm(request.POST, request.FILES)
        # check for temp file
        if form.is_valid():
            # TODO: Make friendly to other OSes.
            content = request.FILES['gedcom_file'].read().split("\r")

            # Call celery worker
            async_update.delay(g, content)

            # Redirect to the document list after POST
            form = ''
            message = 'Upload successful. Gedcom updating.'
        else:
            form = UpdateForm()
            message = 'Did you correctly upload a gedcom file?'

    else:
        form = UpdateForm()

    # Render list page with the documents and the form
    return render_to_response(
        'gedgo/update.html',
        {'form': form, 'message': message, 'gedcom': g},
        context_instance=RequestContext(request, site_context(request)))
Beispiel #17
0
def documentaries(request):
    documentaries = Documentary.objects.all().order_by('-last_updated')

    return render_to_response("gedgo/documentaries.html",
        {'documentaries': documentaries},
        context_instance=RequestContext(request, site_context(request)))