diff --git a/guild/templates/guild/adventure_detail.html b/guild/templates/guild/adventure_detail.html index fd5ea4f..760602b 100644 --- a/guild/templates/guild/adventure_detail.html +++ b/guild/templates/guild/adventure_detail.html @@ -14,7 +14,7 @@
Delete
- +

{{adventure.description|md|safe}}

diff --git a/guild/templates/guild/character_detail.html b/guild/templates/guild/character_detail.html index d1fca82..36d5ccd 100644 --- a/guild/templates/guild/character_detail.html +++ b/guild/templates/guild/character_detail.html @@ -3,14 +3,25 @@ {% load guild_extras %} {% block content %} -

Character: {{ character.name }}

-

+
+
+

Character: {{ character.name }}

+
+
+ Edit +
+
+ Delete +
+
+ +

Played by: {{ character.player.name }} -

+

{{character.description|md|safe}}

diff --git a/guild/templates/guild/home.html b/guild/templates/guild/home.html index c6445d3..c86e91c 100644 --- a/guild/templates/guild/home.html +++ b/guild/templates/guild/home.html @@ -25,5 +25,25 @@ {% endfor %} +

Characters

+ + + +

Players

+ + + {% endblock content %} \ No newline at end of file diff --git a/guild/templates/guild/player_detail.html b/guild/templates/guild/player_detail.html index c6ee65d..03191bd 100644 --- a/guild/templates/guild/player_detail.html +++ b/guild/templates/guild/player_detail.html @@ -1,7 +1,17 @@ {% extends 'base.html' %} {% block content %} -

Player: {{ player.name }}

+
+
+

Player: {{ player.name }}

+
+
+ Edit +
+
+ Delete +
+

Characters

diff --git a/guild/urls.py b/guild/urls.py index 6d4b20e..69c1c27 100644 --- a/guild/urls.py +++ b/guild/urls.py @@ -9,8 +9,12 @@ urlpatterns = [ # path("players/", views.PlayerListView.as_view(), name="player_list"), path("players/create/", player_views.CreatePlayerView.as_view(), name="create_player"), path("players//", player_views.PlayerDetailView.as_view(), name="player_detail"), + path("players//update/", player_views.PlayerUpdateView.as_view(), name="player_update"), + path("players//delete/", player_views.PlayerDeleteView.as_view(), name="player_delete"), path("characters/create/", character_views.CreateCharacterView.as_view(), name="create_character"), path("characters//", character_views.CharacterDetailView.as_view(), name="character_detail"), + path("characters//update/", character_views.CharacterUpdateView.as_view(), name="character_update"), + path("characters//delete/", character_views.CharacterDeleteView.as_view(), name="character_delete"), path("adventures/create/", adventure_views.CreateAdventureView.as_view(), name="create_adventure"), path("adventures//", adventure_views.AdventureDetailView.as_view(), name="adventure_detail"), path("adventures//update/", adventure_views.AdventureUpdateView.as_view(), name="adventure_update"), diff --git a/guild/views/__init__.py b/guild/views/__init__.py index 1807868..9ca226b 100644 --- a/guild/views/__init__.py +++ b/guild/views/__init__.py @@ -2,7 +2,7 @@ from django.views.generic import TemplateView, ListView, DetailView from django.views.generic.edit import CreateView from django.contrib.auth.mixins import LoginRequiredMixin -from guild.models import Adventure, Player +from guild.models import Adventure, Character, Player # Create your views here. class HomeView(LoginRequiredMixin, TemplateView): @@ -11,6 +11,8 @@ class HomeView(LoginRequiredMixin, TemplateView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["adventures"] = Adventure.objects.all() + context["players"] = Player.objects.all() + context["characters"] = Character.objects.all() return context diff --git a/guild/views/character.py b/guild/views/character.py index a741454..0681ce5 100644 --- a/guild/views/character.py +++ b/guild/views/character.py @@ -1,6 +1,6 @@ from django.views.generic import TemplateView, ListView, DetailView -from django.views.generic.edit import CreateView +from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.contrib.auth.mixins import LoginRequiredMixin from guild.models import Character @@ -11,4 +11,12 @@ class CreateCharacterView(LoginRequiredMixin, CreateView): fields = ["name", "description", "player"] class CharacterDetailView(LoginRequiredMixin, DetailView): - model = Character \ No newline at end of file + model = Character + +class CharacterUpdateView(LoginRequiredMixin, UpdateView): + model = Character + fields = ["name", "description", "player"] + +class CharacterDeleteView(LoginRequiredMixin, DeleteView): + model = Character + success_url = "/" \ No newline at end of file diff --git a/guild/views/player.py b/guild/views/player.py index 7812981..2639e76 100644 --- a/guild/views/player.py +++ b/guild/views/player.py @@ -1,6 +1,6 @@ from django.views.generic import TemplateView, ListView, DetailView -from django.views.generic.edit import CreateView +from django.views.generic.edit import CreateView, UpdateView, DeleteView from django.contrib.auth.mixins import LoginRequiredMixin from guild.models import Player @@ -11,4 +11,12 @@ class CreatePlayerView(LoginRequiredMixin, CreateView): fields = ["name"] class PlayerDetailView(LoginRequiredMixin, DetailView): - model = Player \ No newline at end of file + model = Player + +class PlayerUpdateView(LoginRequiredMixin, UpdateView): + model = Player + fields = ["name"] + +class PlayerDeleteView(LoginRequiredMixin, DeleteView): + model = Player + success_url = "/" \ No newline at end of file