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 %}
+
+{% 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 %}
+{% endblock content %}
\ No newline at end of file
diff --git a/guild/templatetags/__init__.py b/guild/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/guild/templatetags/guild_extras.py b/guild/templatetags/guild_extras.py
new file mode 100644
index 0000000..18e06ff
--- /dev/null
+++ b/guild/templatetags/guild_extras.py
@@ -0,0 +1,10 @@
+import markdown
+from django import template
+from django.template.defaultfilters import stringfilter
+
+register = template.Library()
+
+@register.filter(name='md')
+@stringfilter
+def md(value):
+ return markdown.markdown(value)
\ No newline at end of file
diff --git a/guild/urls.py b/guild/urls.py
index af9044f..e494887 100644
--- a/guild/urls.py
+++ b/guild/urls.py
@@ -2,6 +2,7 @@ from django.urls import path
import guild.views as views
import guild.views.player as player_views
import guild.views.character as character_views
+import guild.views.adventure as adventure_views
urlpatterns = [
path("", views.HomeView.as_view(), name="home"),
@@ -10,4 +11,8 @@ urlpatterns = [
path("players//", player_views.PlayerDetailView.as_view(), name="player_detail"),
path("characters/create/", character_views.CreateCharacterView.as_view(), name="create_character"),
path("characters//", character_views.CharacterDetailView.as_view(), name="character_detail"),
+ path("adventures/create/", adventure_views.CreateAdventureView.as_view(), name="create_adventure"),
+ path("adventures//", adventure_views.AdventureDetailView.as_view(), name="adventure_detail"),
+ path("adventures//playsession/create/", adventure_views.CreatePlaySessionView.as_view(), name="create_playsession"),
+ path("adventures//playsession//", adventure_views.PlaySessionDetailView.as_view(), name="playsession_detail"),
]
diff --git a/guild/views/adventure.py b/guild/views/adventure.py
new file mode 100644
index 0000000..769a307
--- /dev/null
+++ b/guild/views/adventure.py
@@ -0,0 +1,39 @@
+
+from typing import Any, Dict, Optional, Type
+from django.forms.models import BaseModelForm
+from django.http import HttpResponse
+from django.shortcuts import get_object_or_404
+from django.views.generic import TemplateView, ListView, DetailView
+from django.views.generic.edit import CreateView
+from django.contrib.auth.mixins import LoginRequiredMixin
+from guild.forms import PlaySessionForm
+
+from guild.models import Adventure, PlaySession
+
+
+class CreateAdventureView(LoginRequiredMixin, CreateView):
+ model = Adventure
+ fields = ["name", "description", "master"]
+
+class AdventureDetailView(LoginRequiredMixin, DetailView):
+ model = Adventure
+
+class CreatePlaySessionView(LoginRequiredMixin, CreateView):
+ model = PlaySession
+ form_class = PlaySessionForm
+
+ def dispatch(self, request, *args, **kwargs):
+ self.adventure = get_object_or_404(Adventure, pk=kwargs["pk"])
+ return super().dispatch(request, *args, **kwargs)
+
+ def form_valid(self, form: BaseModelForm) -> HttpResponse:
+ form.instance.adventure = self.adventure
+ return super().form_valid(form)
+
+
+class PlaySessionDetailView(LoginRequiredMixin, DetailView):
+ model = PlaySession
+ pk_url_kwarg = "playsession_pk"
+
+ def get_queryset(self):
+ return super().get_queryset().filter(adventure_id=self.kwargs["pk"])