30 lines
801 B
Python
30 lines
801 B
Python
from django.views.generic import TemplateView, ListView, DetailView
|
|
from django.views.generic.edit import CreateView, UpdateView, DeleteView
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
|
|
|
from guild.models import Character
|
|
|
|
|
|
class CharacterListView(LoginRequiredMixin, ListView):
|
|
model = Character
|
|
context_object_name = "characters"
|
|
|
|
|
|
class CreateCharacterView(LoginRequiredMixin, CreateView):
|
|
model = Character
|
|
fields = ["name", "description", "player"]
|
|
|
|
|
|
class CharacterDetailView(LoginRequiredMixin, DetailView):
|
|
model = Character
|
|
|
|
|
|
class CharacterUpdateView(LoginRequiredMixin, UpdateView):
|
|
model = Character
|
|
fields = ["name", "description", "player"]
|
|
|
|
|
|
class CharacterDeleteView(LoginRequiredMixin, DeleteView):
|
|
model = Character
|
|
success_url = "/"
|