From fc748f85968b08bb668371c4270d1dda355d96ab Mon Sep 17 00:00:00 2001 From: Niko Abeler Date: Sat, 10 Jun 2023 22:32:45 +0200 Subject: [PATCH] more basic setup --- guild/forms.py | 17 ++++++++ guild/models.py | 5 ++- guild/templates/guild/adventure_detail.html | 28 +++++++++++++ guild/templates/guild/adventure_form.html | 9 +++++ guild/templates/guild/character_detail.html | 4 +- guild/templates/guild/home.html | 13 ++++++- guild/templates/guild/player_detail.html | 2 +- guild/templates/guild/playsession_detail.html | 17 ++++++++ guild/templates/guild/playsession_form.html | 9 +++++ guild/templatetags/__init__.py | 0 guild/templatetags/guild_extras.py | 10 +++++ guild/urls.py | 5 +++ guild/views/adventure.py | 39 +++++++++++++++++++ 13 files changed, 153 insertions(+), 5 deletions(-) create mode 100644 guild/forms.py create mode 100644 guild/templates/guild/adventure_detail.html create mode 100644 guild/templates/guild/adventure_form.html create mode 100644 guild/templates/guild/playsession_detail.html create mode 100644 guild/templates/guild/playsession_form.html create mode 100644 guild/templatetags/__init__.py create mode 100644 guild/templatetags/guild_extras.py create mode 100644 guild/views/adventure.py diff --git a/guild/forms.py b/guild/forms.py new file mode 100644 index 0000000..b0af882 --- /dev/null +++ b/guild/forms.py @@ -0,0 +1,17 @@ + + +from django import forms +from guild.models import PlaySession + + +class PlaySessionForm(forms.ModelForm): + + class Meta: + model = PlaySession + fields = ["date", "characters", "summary"] + # set date wideget to type="date" + widgets = { + "date": forms.DateInput(attrs={"type": "date"}), + + } + diff --git a/guild/models.py b/guild/models.py index 6639dc7..001a94a 100644 --- a/guild/models.py +++ b/guild/models.py @@ -82,7 +82,10 @@ class PlaySession(models.Model): return self.name def get_absolute_url(self): - return reverse("guild:playsession_detail", kwargs={"pk": self.pk}) + return reverse( + "guild:playsession_detail", + kwargs={"pk": self.adventure.pk, "playsession_pk": self.pk} + ) class ResourceEarned(models.Model): diff --git a/guild/templates/guild/adventure_detail.html b/guild/templates/guild/adventure_detail.html new file mode 100644 index 0000000..4c4a678 --- /dev/null +++ b/guild/templates/guild/adventure_detail.html @@ -0,0 +1,28 @@ +{% extends 'base.html' %} + +{% load guild_extras %} + +{% block content %} +

Adventure: {{ adventure.name }}

+ +

{{adventure.description|md|safe}}

+ +Add new Session + + +{% if not adventure.playsession_set.count %} +

No sessions found.

+{% else %} + +{% endif %} + + +{% endblock content %} \ No newline at end of file diff --git a/guild/templates/guild/adventure_form.html b/guild/templates/guild/adventure_form.html new file mode 100644 index 0000000..b40688e --- /dev/null +++ b/guild/templates/guild/adventure_form.html @@ -0,0 +1,9 @@ +{% extends 'base.html' %} + +{% block content %} +
+ {% csrf_token %} + {{ form.as_p }} + +
+{% endblock content %} \ No newline at end of file diff --git a/guild/templates/guild/character_detail.html b/guild/templates/guild/character_detail.html index d433512..d1fca82 100644 --- a/guild/templates/guild/character_detail.html +++ b/guild/templates/guild/character_detail.html @@ -1,5 +1,7 @@ {% extends 'base.html' %} +{% load guild_extras %} + {% block content %}

Character: {{ character.name }}

@@ -10,6 +12,6 @@ -

{{character.description}}

+

{{character.description|md|safe}}

{% endblock content %} \ No newline at end of file diff --git a/guild/templates/guild/home.html b/guild/templates/guild/home.html index 54302c4..22a2e86 100644 --- a/guild/templates/guild/home.html +++ b/guild/templates/guild/home.html @@ -3,8 +3,17 @@ {% block content %}

Home

-Create New Player -Create New Character + {% 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 0f6e30f..c6ee65d 100644 --- a/guild/templates/guild/player_detail.html +++ b/guild/templates/guild/player_detail.html @@ -5,7 +5,7 @@

Characters

-{% if not player.character_set %} +{% if not player.character_set.count %}

No characters found.

{% else %}