def mcglenn(request):
    homepage = HomePage.objects.get(the_url=request.path)
    context = {
        'homepage': homepage,
        'site': SITENAME,
        'navigation': get_navigation(),
    }
    return render_to_response(
        'index.html',
        context,
        context_instance=RequestContext(request)
    )
def blog_page(request):
    '''
        blog_page: This is the main view for all blog entries

        Arguments:
             request
        Returns: Page with content values
    '''
    # DONE - Start adding the content to the page
    entries = Posts.objects.order_by('-timestamp')
    content = {'blog': entries,
               'site': SITENAME,
               'navigation': get_navigation(),
              }
    return render_to_response(
        "blog.html",
        content,
        context_instance=RequestContext(request)
    )
def appointment(request):
    ''' appointment:  This is the main view for all appointment entries
        Arguments:
            request:        The POST request from Browser
        Returns: Page with content values
    '''
    # TODO - Insure that this page is only available to admin users
    # DONE - Start adding the content to the page
    # DONE - Refactor to function
    # This section of code retrieves the POST from template and changes the values
    # in the database
    entries_list = Appointment.objects.order_by('-date_requested', 'time_requested').filter(report_completed=False, remove=False)
    inspectors = Inspector.objects.exclude(slug='default-default')
    paginator = Paginator(entries_list, 5)

    if request.method == 'POST':
        entry = entries_list.get(pk=request.POST['app_id'])
        route_command(request.POST, entry)

    # Pagination
    # Get the page number
    try:
        page = int(request.GET.get('page', '1'))
    except:
        page = 1
    #Assign entries to paginator
    try:
        entries = paginator.page(page)
    except (EmptyPage, InvalidPage):
        entries = paginator.page(paginator.num_pages)

    content = {'entries': entries,
               'inspectors': inspectors,
               'navigation': get_navigation(),
               'now': date.today(),
               'site': SITENAME,
              }
    return render_to_response(
        "appointment.html",
        content,
        context_instance=RequestContext(request)
    )
def glossary_page(request):
    '''
        This is the main view for all glossary entries

        Arguments:
            request:
        Returns:
            Page with content values
    '''
    # DONE - Start adding the content to the page
    # DONE - Add pagination
    entries_list = Term.objects.order_by('title')
    paginator = Paginator(entries_list, 20)

    # Pagination
    # Get the page number
    try:
        page = int(request.GET.get('page', '1'))
    except:
        page = 1
    #Assign entries to paginator
    try:
        entries = paginator.page(page)
    except (EmptyPage, InvalidPage):
        entries = paginator.page(paginator.num_pages)

    content = {'entries': entries,
               'navigation': get_navigation(),
               'site': SITENAME,
              }

    return render_to_response(
        "glossary.html",
        content,
        context_instance=RequestContext(request)
    )
def appointment_details(request, appointment_slug):
    ''' appointment_details:  This is the detail view for each appointment entries
        Arguments:
            request
        Returns: Page with content values
    '''
    # DONE - Start adding the content to the page
    entry = Appointment.objects.get(slug=appointment_slug)
    email = CustomerEmail.objects.filter(name=entry.pk)
    phone = CustomerPhone.objects.filter(name=entry.pk)
    if request.method == 'POST' and route_command(request.POST, entry):
        print "Success"

    content = {'detail': entry,
               'email': email,
               'phone': phone,
               'navigation': get_navigation(),
               'site': SITENAME,
              }
    return render_to_response(
        'appointment_details.html',
        content,
        context_instance=RequestContext(request)
    )