from django.http import HttpResponseRedirect
from django.shortcuts import render

import hashlib

from domain.models import Domain
from revision.models import Revision

# Create your views here.
def index(request, customer_id, domain_id):
    try:
        customer = Customer.objects.get(pk=customer_id)
    except Customer.DoesNotExist:
        raise Http404
    
    try:
        domain = Domain.objects.get(pk=domain_id)
    except Domain.DoesNotExist:
        raise Http404


    revision_list = Revision.objects.filter(domain_id__exact=domain.id).order_by('created_at')[:10]
    return render( request, 'revision/index.html', {
        'customer': customer,
        'domain': domain,
        'revision_list': revision_list,
    })
