<commit_before>from django.http import HttpResponse


def index(request):
    return HttpResponse("Hallo Welt!")<commit_msg>Add views for deck CRUD<commit_after># coding=utf-8
# TODO: User authentication
from django.contrib.localflavor import kw

from django.http import HttpResponse
from django.http.response import HttpResponseForbidden
from django.template import context
from django.views.generic import ListView, DetailView
from django.views.generic import CreateView, UpdateView, DeleteView
from django.core.urlresolvers import reverse_lazy

from cardbox.deck_forms import DeckForm
from cardbox.deck_model import Deck

class DeckList(ListView):
    model = Deck


class DeckCreate(CreateView):
    model = Deck
    form_class = DeckForm
    success_url = reverse_lazy('deck:deck_list')

    def get_context_data(self, **kwargs):
        context = super(DeckCreate, self).get_context_data(**kwargs)
        context['action'] = "erstellen"
        context['button_text'] = "Erstellen"
        return context

class DeckDetailView(DetailView):
    model = Deck


class DeckUpdate(UpdateView):
    model = Deck
    form_class = DeckForm
    success_url = reverse_lazy('deck:deck_list')

    def get_context_data(self, **kwargs):
        context = super(DeckUpdate, self).get_context_data(**kwargs)
        context['action'] = "bearbeiten"
        context['button_text'] = "Änderungen übernehmen"
        return context


class DeckDelete(DeleteView):
    model = Deck
    success_url = reverse_lazy('deck:deck_list')
    
    def get(selfself, request, *args, **kwargs):
        """Never get the confirm_delete template!"""
        print "test"
        return HttpResponseForbidden("<h1>Access denied</h1>")

    def post(self, *args, **kwargs):
        # TODO: user authentication
        return super(DeckDelete, self).post(self, args, kwargs)
{'fraction_non_alphanumeric': 0.09745533297238766, 'fraction_numerical': 0.0016242555495397943, 'mean_word_length': 4.133333333333334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '6679045', 'n_tokens_mistral': 547, 'n_tokens_neox': 542, 'n_words': 138}