<commit_before>from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib import auth
from django.utils import html
from django.contrib.auth.decorators import login_required
from django.core.exceptions import ValidationError
from django.contrib.auth.password_validation import validate_password
from django.forms import ModelForm
from django.conf import settings
from .models import Book, Subscription
from .forms import AccountForm, AccountEditForm


# Create your views here.
def index(request):
    context = {'nbar': 'home', 
                'heading': 'Amazing Textbook Store',
                'mission': 'home of amazingly cheap college textbooks',
                'deals': [('black friday deal', 'https://placehold.it/150x80?text=IMAGE', 'Buy 50 mobiles and get a gift card'),
                ('christmas deal', 'https://placehold.it/150x80?text=No+Image', 'Buy 1 mobile and get 1 free')]
            }
    return render(request, 'books/index.html', context)

def book_list(request):
    context = {
                'nbar': 'books',
                'pageTitle': 'Books',
                #'books': Book.objects.all(),
                'books': Book.objects.filter(available=True)
            }
    return render(request, 'books/list.html', context)

def book_detail(request, id, slug):
    book = get_object_or_404(Book, id=id, slug=slug, available=True)
    context = {
                'nbar': 'books',
                'pageTitle': book.title,
                'book': book
    }
    return render(request, 'books/detail.html', context)

def subscribe(request):
    errors = []
    context = {}
    if 'email' in request.GET:
        email_id = request.GET.get('email')
        if not email_id:
            errors.append('Please enter a valid email address.')
        else:
            subs = Subscription.objects.create(email=email_id)
            context['pageTitle']= 'Thank you!'
            context['panelTitle'] = 'Thank you!'
            context['panelBody'] = 'Thank you for subscribing to our mailing list.'
            return render(request, 'books/static.html', context)
    else:
        return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))

def deals(request):
    context = {
        'nbar': 'deals',
        'pageTitle': 'Deals',
        'panelTitle': 'Deals',
        'panelBody': '<strong>Sorry! There are no deals at this time. Sign up to get deals deliver to your inbox...</strong>'
    }
    return render(request, 'books/static.html', context)

def contact(request):
    context = {
        'nbar': 'contact',
        'pageTitle': 'Contact',
        'panelTitle': 'Contact',
        'panelBody': """
            <!-- List group -->
            <ul class="list-group">
            <li class="list-group-item"><strong>Corporate Office: </strong><br />
                <address>111 University Blvd<br>
                        Grand Junction, CO 81501 <br>
                        &phone;: (970) 123-4567<br>
                        <span class="glyphicon glyphicon-envelope"></span>: <EMAIL><br>
            </li>
            <li class="list-group-item"><strong>Denver Office: </strong><br />
                <address>123 Amazing Street</br>
                        Denver, CO 81111 <br>
                        &phone;: (970) 123-1234<br>
                        <span class="glyphicon glyphicon-envelope"></span>: <EMAIL><br>
            </li>
            <li class="list-group-item">Porta ac consectetur ac</li>
            <li class="list-group-item">Vestibulum at eros</li>
            </ul>
            
        """,
    }
    return render(request, 'books/static.html', context)<commit_msg>added missing end html tags<commit_after>from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.contrib import auth
from django.utils import html
from django.contrib.auth.decorators import login_required
from django.core.exceptions import ValidationError
from django.contrib.auth.password_validation import validate_password
from django.forms import ModelForm
from django.conf import settings
from .models import Book, Subscription
from .forms import AccountForm, AccountEditForm


# Create your views here.
def index(request):
    context = {'nbar': 'home', 
                'heading': 'Amazing Textbook Store',
                'mission': 'home of amazingly cheap college textbooks',
                'deals': [('black friday deal', 'https://placehold.it/150x80?text=IMAGE', 'Buy 50 mobiles and get a gift card'),
                ('christmas deal', 'https://placehold.it/150x80?text=No+Image', 'Buy 1 mobile and get 1 free')]
            }
    return render(request, 'books/index.html', context)

def book_list(request):
    context = {
                'nbar': 'books',
                'pageTitle': 'Books',
                #'books': Book.objects.all(),
                'books': Book.objects.filter(available=True)
            }
    return render(request, 'books/list.html', context)

def book_detail(request, id, slug):
    book = get_object_or_404(Book, id=id, slug=slug, available=True)
    context = {
                'nbar': 'books',
                'pageTitle': book.title,
                'book': book
    }
    return render(request, 'books/detail.html', context)

def subscribe(request):
    errors = []
    context = {}
    if 'email' in request.GET:
        email_id = request.GET.get('email')
        if not email_id:
            errors.append('Please enter a valid email address.')
        else:
            subs = Subscription.objects.create(email=email_id)
            context['pageTitle']= 'Thank you!'
            context['panelTitle'] = 'Thank you!'
            context['panelBody'] = 'Thank you for subscribing to our mailing list.'
            return render(request, 'books/static.html', context)
    else:
        return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))

def deals(request):
    context = {
        'nbar': 'deals',
        'pageTitle': 'Deals',
        'panelTitle': 'Deals',
        'panelBody': '<strong>Sorry, no deals at this time. Sign up to get deals delivered right to your inbox...</strong>'
    }
    return render(request, 'books/static.html', context)

def contact(request):
    context = {
        'nbar': 'contact',
        'pageTitle': 'Contact',
        'panelTitle': 'Contact',
        'panelBody': """
            <!-- List group -->
            <ul class="list-group">
            <li class="list-group-item"><strong>Corporate Office: </strong><br />
                <address>111 University Blvd<br>
                        Grand Junction, CO 81501 <br>
                        &phone;: (970) 123-4567<br>
                        <span class="glyphicon glyphicon-envelope"></span>: <EMAIL><br>
                </address>
            </li>
            <li class="list-group-item"><strong>Denver Office: </strong><br />
                <address>123 Amazing Street</br>
                        Denver, CO 81111 <br>
                        &phone;: (970) 123-1234<br>
                        <span class="glyphicon glyphicon-envelope"></span>: <EMAIL><br>
                </address>
            </li>
            <li class="list-group-item">Porta ac consectetur ac</li>
            <li class="list-group-item">Vestibulum at eros</li>
            </ul>
            
        """,
    }
    return render(request, 'books/static.html', context)
{'fraction_non_alphanumeric': 0.12755905511811025, 'fraction_numerical': 0.014698162729658792, 'mean_word_length': 2.2512798634812285, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 75, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2827689', 'n_tokens_mistral': 2232, 'n_tokens_neox': 2076, 'n_words': 562}