Esempio n. 1
0
def tv(request):
    q = models.ContentNode.with_metadata()
    q = q.filter(kind=models.KIND_SERIES)
    return render_to_response("venclave/simple.html", request, {
        'nodes': q,
        'kind': models.KIND_SERIES
    })
Esempio n. 2
0
def browse(request):
    q = models.ContentNode.with_metadata().order_by('-created')
    recent_movies = q.filter(kind=models.KIND_MOVIE)[:10]
    recent_tv = q.filter(kind=models.KIND_TV)[:10]
    return render_to_response("venclave/browse.html", request,
                              {'recent_movies': recent_movies,
                               'recent_tv': recent_tv})
Esempio n. 3
0
def browse(request):
    q = models.ContentNode.with_metadata().order_by('-created')
    recent_movies = q.filter(kind=models.KIND_MOVIE)[:10]
    recent_tv = q.filter(kind=models.KIND_TV)[:10]
    return render_to_response("venclave/browse.html", request, {
        'recent_movies': recent_movies,
        'recent_tv': recent_tv
    })
Esempio n. 4
0
def series(request, series):
    series_node = get_object_or_404(models.ContentNode, title=series,
                                    kind=models.KIND_SERIES)
    q = models.ContentNode.objects.select_related(
            'parent', *models.ContentNode.metadata_attrs)
    q = q.filter(kind=models.KIND_SEASON, parent=series_node)
    return render_to_response("venclave/simple.html", request,
                              {'nodes': q,
                               'kind': models.KIND_SEASON})
Esempio n. 5
0
def series(request, series):
    series_node = get_object_or_404(models.ContentNode,
                                    title=series,
                                    kind=models.KIND_SERIES)
    q = models.ContentNode.objects.select_related(
        'parent', *models.ContentNode.metadata_attrs)
    q = q.filter(kind=models.KIND_SEASON, parent=series_node)
    return render_to_response("venclave/simple.html", request, {
        'nodes': q,
        'kind': models.KIND_SEASON
    })
Esempio n. 6
0
def request(request):
    # POST requests are probably the best way to handle these kinds of
    # requests.  We always want to end up at the same page after processing the
    # request, and using POST will usually prevent the user from refreshing.
    if request.POST.get('make_request', '') == 'true':
        content_request = ContentRequest(name=request.POST['name'],
                                         user=request.user, votes=1)
        content_request.save()
    if request.POST.get('mark_satisfied', '') == 'true':
        id = int(request.POST['id'])
        content_request = get_object_or_404(ContentRequest, id=id)
        content_request.satisfied = bool(request.POST['satisfied'] == 'true')
        content_request.satisfied_on = datetime.datetime.now()
        content_request.save()

    q = ContentRequest.objects.select_related('user')
    active = q.filter(satisfied=False).order_by('-votes', '-added')
    satisfied = q.filter(satisfied=True).order_by('-satisfied_on')
    return render_to_response("venclave/request.html", request,
                              {'active_requests': active,
                               'satisfied_requests': satisfied})
Esempio n. 7
0
def home(request):
    browse_redirect = HttpResponseRedirect(reverse('venclave-browse'))
    # If already authenticated, go right in.
    if request.user.is_authenticated():
        return browse_redirect

    ## If SSL auth works, go right in.
    #user = auth.authenticate(request=request)
    #if user:
        #auth.login(request, user)
        #logging.info("User %s logged in via SSL", user.username)
        #return browse_redirect

    reg_form = VenclaveUserCreationForm()
    if request.method == 'POST':
        # login
        if request.POST.get('f') == 'l':
            username = request.POST['username']
            password = request.POST['password']
            user = auth.authenticate(username=username, password=password)
            if user is not None:
                auth.login(request, user)
                logging.info("User %s logged in via password", user.username)
                return browse_redirect
        # register
        elif settings.VENCLAVE_ALLOW_REGISTRATION and request.POST['f'] == 'r':
            reg_form = VenclaveUserCreationForm(request.POST)
            if reg_form.is_valid():
                reg_form.save()
                username = reg_form.cleaned_data['username']
                password = reg_form.cleaned_data['password1']
                user = auth.authenticate(username=username, password=password)
                auth.login(request, user)
                return browse_redirect
    return render_to_response("venclave/index.html", request,
                              {'reg_form': reg_form, 'settings': settings})
Esempio n. 8
0
def movies(request):
    q = models.ContentNode.with_metadata().filter(kind=models.KIND_MOVIE)
    return render_to_response("venclave/simple.html", request, {
        'nodes': q,
        'kind': models.KIND_MOVIE
    })
Esempio n. 9
0
def generic_detail(request, node):
    return render_to_response("venclave/detail.html", request, {'node': node})
Esempio n. 10
0
def other(request):
    q = models.ContentNode.with_metadata()
    q = q.exclude(kind__in=(models.KIND_MOVIE, models.KIND_SERIES,
                            models.KIND_TV, models.KIND_SEASON))
    return render_to_response("venclave/simple.html", request, {'nodes': q})
Esempio n. 11
0
def other(request):
    q = models.ContentNode.with_metadata()
    q = q.exclude(kind__in=(models.KIND_MOVIE, models.KIND_SERIES,
                            models.KIND_TV, models.KIND_SEASON))
    return render_to_response("venclave/simple.html", request,
                              {'nodes': q})
Esempio n. 12
0
def tv(request):
    q = models.ContentNode.with_metadata()
    q = q.filter(kind=models.KIND_SERIES)
    return render_to_response("venclave/simple.html", request,
                              {'nodes': q,
                               'kind': models.KIND_SERIES})
Esempio n. 13
0
def movies(request):
    q = models.ContentNode.with_metadata().filter(kind=models.KIND_MOVIE)
    return render_to_response("venclave/simple.html", request,
                              {'nodes': q,
                               'kind': models.KIND_MOVIE})
Esempio n. 14
0
def generic_detail(request, node):
    return render_to_response("venclave/detail.html", request, {'node': node})
Esempio n. 15
0
def exhibit(request):
    result = {'settings': settings}
    return render_to_response('venclave/exhibit.html', request, result,
                              context_instance=RequestContext(request))