player + character improvements
This commit is contained in:
parent
765cb98e13
commit
1f27ff7702
|
@ -14,7 +14,7 @@
|
|||
<div class="column">
|
||||
<a class="button button-clear" href="{% url 'guild:adventure_delete' adventure.id %}">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<p>{{adventure.description|md|safe}}</p>
|
||||
|
|
|
@ -3,14 +3,25 @@
|
|||
{% load guild_extras %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Character: {{ character.name }}</h1>
|
||||
|
||||
<h2>
|
||||
<div class="row">
|
||||
<div class="column column-75">
|
||||
<h1>Character: {{ character.name }}</h1>
|
||||
</div>
|
||||
<div class="column">
|
||||
<a class="button button-outline" href="{% url 'guild:character_update' character.id %}">Edit</a>
|
||||
</div>
|
||||
<div class="column">
|
||||
<a class="button button-clear" href="{% url 'guild:character_delete' character.id %}">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Played by:
|
||||
<a href="{% url 'guild:player_detail' character.player.id %}">
|
||||
{{ character.player.name }}
|
||||
</a>
|
||||
</h2>
|
||||
</p>
|
||||
|
||||
<p>{{character.description|md|safe}}</p>
|
||||
|
||||
|
|
|
@ -25,5 +25,25 @@
|
|||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h2>Characters</h2>
|
||||
|
||||
<ul>
|
||||
{% for character in characters %}
|
||||
<li>
|
||||
<a href="{% url 'guild:character_detail' character.id %}">{{ character.name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h2>Players</h2>
|
||||
|
||||
<ul>
|
||||
{% for player in players %}
|
||||
<li>
|
||||
<a href="{% url 'guild:player_detail' player.id %}">{{ player.name }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
|
||||
{% endblock content %}
|
|
@ -1,7 +1,17 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Player: {{ player.name }}</h1>
|
||||
<div class="row">
|
||||
<div class="column column-75">
|
||||
<h1>Player: {{ player.name }}</h1>
|
||||
</div>
|
||||
<div class="column">
|
||||
<a class="button button-outline" href="{% url 'guild:player_update' player.id %}">Edit</a>
|
||||
</div>
|
||||
<div class="column">
|
||||
<a class="button button-clear" href="{% url 'guild:player_delete' player.id %}">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>Characters</h2>
|
||||
|
||||
|
|
|
@ -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/<int:pk>/", player_views.PlayerDetailView.as_view(), name="player_detail"),
|
||||
path("players/<int:pk>/update/", player_views.PlayerUpdateView.as_view(), name="player_update"),
|
||||
path("players/<int:pk>/delete/", player_views.PlayerDeleteView.as_view(), name="player_delete"),
|
||||
path("characters/create/", character_views.CreateCharacterView.as_view(), name="create_character"),
|
||||
path("characters/<int:pk>/", character_views.CharacterDetailView.as_view(), name="character_detail"),
|
||||
path("characters/<int:pk>/update/", character_views.CharacterUpdateView.as_view(), name="character_update"),
|
||||
path("characters/<int:pk>/delete/", character_views.CharacterDeleteView.as_view(), name="character_delete"),
|
||||
path("adventures/create/", adventure_views.CreateAdventureView.as_view(), name="create_adventure"),
|
||||
path("adventures/<int:pk>/", adventure_views.AdventureDetailView.as_view(), name="adventure_detail"),
|
||||
path("adventures/<int:pk>/update/", adventure_views.AdventureUpdateView.as_view(), name="adventure_update"),
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -12,3 +12,11 @@ class CreateCharacterView(LoginRequiredMixin, CreateView):
|
|||
|
||||
class CharacterDetailView(LoginRequiredMixin, DetailView):
|
||||
model = Character
|
||||
|
||||
class CharacterUpdateView(LoginRequiredMixin, UpdateView):
|
||||
model = Character
|
||||
fields = ["name", "description", "player"]
|
||||
|
||||
class CharacterDeleteView(LoginRequiredMixin, DeleteView):
|
||||
model = Character
|
||||
success_url = "/"
|
|
@ -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
|
||||
|
@ -12,3 +12,11 @@ class CreatePlayerView(LoginRequiredMixin, CreateView):
|
|||
|
||||
class PlayerDetailView(LoginRequiredMixin, DetailView):
|
||||
model = Player
|
||||
|
||||
class PlayerUpdateView(LoginRequiredMixin, UpdateView):
|
||||
model = Player
|
||||
fields = ["name"]
|
||||
|
||||
class PlayerDeleteView(LoginRequiredMixin, DeleteView):
|
||||
model = Player
|
||||
success_url = "/"
|
Loading…
Reference in New Issue