more linking of pages
This commit is contained in:
parent
64f2c74ea8
commit
3a6e3a02d3
6
TODO.md
6
TODO.md
|
@ -1,8 +1,2 @@
|
|||
|
||||
- Bigger default summary input
|
||||
- Preview Markdown in summary input
|
||||
- add player to charater in session list and edit/create
|
||||
- {{charater}} ({{player}})
|
||||
- add list of npcs
|
||||
- status of character
|
||||
- alive, dead, retired, unknown
|
|
@ -1,14 +1,25 @@
|
|||
from django import forms
|
||||
from guild.models import PlaySession
|
||||
from guild.models import PlaySession, Character
|
||||
|
||||
|
||||
class PlaySessionCharacterForm(forms.ModelMultipleChoiceField):
|
||||
def label_from_instance(self, character):
|
||||
if character.player:
|
||||
return "{} ({})".format(character.name, character.player.name)
|
||||
else:
|
||||
return character.name
|
||||
|
||||
|
||||
class PlaySessionForm(forms.ModelForm):
|
||||
characters = PlaySessionCharacterForm(
|
||||
queryset=Character.objects.all(), widget=forms.CheckboxSelectMultiple
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = PlaySession
|
||||
fields = ["date", "characters", "summary"]
|
||||
# set date wideget to type="date"
|
||||
widgets = {
|
||||
"date": forms.DateInput(attrs={"type": "date"}),
|
||||
"characters": forms.CheckboxSelectMultiple(),
|
||||
"summary": forms.Textarea(attrs={"rows": 32}),
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
# Generated by Django 4.2.1 on 2023-06-19 17:48
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("guild", "0002_resource_alter_player_name_resourceearned"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="character",
|
||||
name="status",
|
||||
field=models.CharField(
|
||||
choices=[
|
||||
("ALIVE", "Alive"),
|
||||
("DEAD", "Dead"),
|
||||
("RETIRED", "Retired"),
|
||||
("UNKNOWN", "Unknown"),
|
||||
],
|
||||
default="ALIVE",
|
||||
max_length=16,
|
||||
),
|
||||
),
|
||||
]
|
|
@ -60,8 +60,17 @@ class Adventure(models.Model):
|
|||
|
||||
|
||||
class Character(models.Model):
|
||||
class Status(models.TextChoices):
|
||||
ALIVE = "ALIVE", _("Alive")
|
||||
DEAD = "DEAD", _("Dead")
|
||||
RETIRED = "RETIRED", _("Retired")
|
||||
UNKNOWN = "UNKNOWN", _("Unknown")
|
||||
|
||||
name = models.CharField(max_length=255)
|
||||
description = models.TextField()
|
||||
status = models.CharField(
|
||||
max_length=16, choices=Status.choices, default=Status.ALIVE
|
||||
)
|
||||
|
||||
player = models.ForeignKey(
|
||||
"Player",
|
||||
|
@ -94,6 +103,7 @@ class PlaySession(models.Model):
|
|||
class Meta:
|
||||
verbose_name = _("playsession")
|
||||
verbose_name_plural = _("playsessions")
|
||||
ordering = ["-date"]
|
||||
|
||||
def __str__(self):
|
||||
return str(self.date)
|
||||
|
|
|
@ -6,7 +6,14 @@
|
|||
|
||||
<div class="row">
|
||||
<div class="column column-75">
|
||||
<hrgroup>
|
||||
<h1>Adventure: {{ adventure.name }}</h1>
|
||||
<h4>Mastered by:
|
||||
<a href="{% url 'guild:player_detail' adventure.master.id %}">
|
||||
{{ adventure.master }}
|
||||
</a>
|
||||
</h4>
|
||||
</hrgroup>
|
||||
</div>
|
||||
<div class="column">
|
||||
<a class="button button-outline" href="{% url 'guild:adventure_update' adventure.id %}">Edit</a>
|
||||
|
|
|
@ -6,7 +6,16 @@
|
|||
|
||||
<div class="row">
|
||||
<div class="column column-75">
|
||||
<hrgroup>
|
||||
<h1>Character: {{ character.name }}</h1>
|
||||
<h4>
|
||||
{{ character.get_status_display }}
|
||||
, played by:
|
||||
<a href="{% url 'guild:player_detail' character.player.id %}">
|
||||
{{ character.player.name }}
|
||||
</a>
|
||||
</h4>
|
||||
</hrgroup>
|
||||
</div>
|
||||
<div class="column">
|
||||
<a class="button button-outline" href="{% url 'guild:character_update' character.id %}">Edit</a>
|
||||
|
@ -16,13 +25,21 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
Played by:
|
||||
<a href="{% url 'guild:player_detail' character.player.id %}">
|
||||
{{ character.player.name }}
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p>{{character.description|md|safe}}</p>
|
||||
|
||||
<h2>Session History</h2>
|
||||
|
||||
{% if not character.playsession_set.count %}
|
||||
<p>No sessions played.</p>
|
||||
{% else %}
|
||||
<ul>
|
||||
{% for session in character.playsession_set.all %}
|
||||
<li>
|
||||
<a href="{% url 'guild:adventure_detail' session.adventure.id %}">
|
||||
{{session.date}} - {{ session.adventure.name }}
|
||||
</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% endblock content %}
|
|
@ -20,7 +20,19 @@
|
|||
{% else %}
|
||||
<ul>
|
||||
{% for character in player.character_set.all %}
|
||||
<li><a href="{% url 'guild:character_detail' character.id %}">{{ character.name }}</a></li>
|
||||
<li><a href="{% url 'guild:character_detail' character.id %}">{{ character.name }} ({{character.get_status_display}})</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
<h2>Game Master Adventures</h2>
|
||||
|
||||
{% if not player.adventure_set.count %}
|
||||
<p>No dungeon masters found.</p>
|
||||
{% else %}
|
||||
<ul>
|
||||
{% for adventure in player.adventure_set.all %}
|
||||
<li><a href="{% url 'guild:adventure_detail' adventure.id %}">{{ adventure.name }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
|
|
@ -12,7 +12,7 @@ class CharacterListView(LoginRequiredMixin, ListView):
|
|||
|
||||
class CreateCharacterView(LoginRequiredMixin, CreateView):
|
||||
model = Character
|
||||
fields = ["name", "description", "player"]
|
||||
fields = ["name", "description", "player", "status"]
|
||||
|
||||
|
||||
class CharacterDetailView(LoginRequiredMixin, DetailView):
|
||||
|
@ -21,7 +21,7 @@ class CharacterDetailView(LoginRequiredMixin, DetailView):
|
|||
|
||||
class CharacterUpdateView(LoginRequiredMixin, UpdateView):
|
||||
model = Character
|
||||
fields = ["name", "description", "player"]
|
||||
fields = ["name", "description", "player", "status"]
|
||||
|
||||
|
||||
class CharacterDeleteView(LoginRequiredMixin, DeleteView):
|
||||
|
|
Loading…
Reference in New Issue