more context

This commit is contained in:
Niko Abeler 2023-06-13 22:09:25 +02:00
parent 8fd6b78025
commit 64f2c74ea8
12 changed files with 74 additions and 29 deletions

View File

@ -9,4 +9,6 @@ COPY requirements.txt .
RUN pip install -r requirements.txt RUN pip install -r requirements.txt
COPY . . COPY . .
RUN python manage.py collectstatic --noinput
CMD ["gunicorn", "-b", "0.0.0.0:8000", "guild_journal.wsgi"] CMD ["gunicorn", "-b", "0.0.0.0:8000", "guild_journal.wsgi"]

View File

@ -1,5 +1,4 @@
- Better character selection in session edit/create
- Bigger default summary input - Bigger default summary input
- Preview Markdown in summary input - Preview Markdown in summary input
- add player to charater in session list and edit/create - add player to charater in session list and edit/create

View File

@ -10,4 +10,5 @@ class PlaySessionForm(forms.ModelForm):
widgets = { widgets = {
"date": forms.DateInput(attrs={"type": "date"}), "date": forms.DateInput(attrs={"type": "date"}),
"characters": forms.CheckboxSelectMultiple(), "characters": forms.CheckboxSelectMultiple(),
"summary": forms.Textarea(attrs={"rows": 32}),
} }

View File

@ -44,6 +44,10 @@ class Adventure(models.Model):
blank=True, blank=True,
) )
@property
def last_session(self):
return self.playsession_set.order_by("-date").first()
class Meta: class Meta:
verbose_name = _("Adventure") verbose_name = _("Adventure")
verbose_name_plural = _("Adventures") verbose_name_plural = _("Adventures")
@ -92,7 +96,7 @@ class PlaySession(models.Model):
verbose_name_plural = _("playsessions") verbose_name_plural = _("playsessions")
def __str__(self): def __str__(self):
return self.name return str(self.date)
def get_absolute_url(self): def get_absolute_url(self):
return ( return (

View File

@ -16,7 +16,14 @@
<ul> <ul>
{% for adventure in adventures %} {% for adventure in adventures %}
<li> <li>
<a href="{% url 'guild:adventure_detail' adventure.id %}">{{ adventure.name }}</a> <a href="{% url 'guild:adventure_detail' adventure.id %}">
{{ adventure.name }}
</a>
{% if adventure.last_session %}
, last session {{ adventure.last_session }}
{% else %}
, no sessions yet
{% endif %}
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
@ -33,7 +40,10 @@
<ul> <ul>
{% for character in characters %} {% for character in characters %}
<li> <li>
<a href="{% url 'guild:character_detail' character.id %}">{{ character.name }}</a> <a href="{% url 'guild:character_detail' character.id %}">
{{ character.name }}
(played by {{ character.player.name }})
</a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -1,3 +1,4 @@
from datetime import date
from django.views.generic import TemplateView, ListView, DetailView from django.views.generic import TemplateView, ListView, DetailView
from django.views.generic.edit import CreateView from django.views.generic.edit import CreateView
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
@ -11,7 +12,13 @@ class HomeView(LoginRequiredMixin, TemplateView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context["adventures"] = Adventure.objects.all() advs = Adventure.objects.prefetch_related("playsession_set", "master").all()
advs = sorted(
advs,
key=lambda x: x.last_session.date if x.last_session else date.min,
reverse=True,
)
context["adventures"] = advs
context["players"] = Player.objects.all() context["players"] = Player.objects.all()
context["characters"] = Character.objects.all() context["characters"] = Character.objects.all()
return context return context

View File

@ -23,6 +23,13 @@ class CreateAdventureView(LoginRequiredMixin, CreateView):
class AdventureDetailView(LoginRequiredMixin, DetailView): class AdventureDetailView(LoginRequiredMixin, DetailView):
model = Adventure model = Adventure
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["sessions"] = PlaySession.objects.filter(
adventure=self.object
).order_by("date")
return context
class AdventureUpdateView(LoginRequiredMixin, UpdateView): class AdventureUpdateView(LoginRequiredMixin, UpdateView):
model = Adventure model = Adventure

View File

@ -103,9 +103,9 @@ STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
STATIC_URL = "static/" STATIC_URL = "static/"
STATIC_ROOT = BASE_DIR / "static" STATIC_ROOT = BASE_DIR / "staticfiles"
STATICFILES_DIRS = [] STATICFILES_DIRS = [BASE_DIR / "static"]
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

View File

@ -69,7 +69,8 @@ input[type='submit'] {
white-space: nowrap; white-space: nowrap;
} }
.button:focus, .button:hover, .button:focus,
.button:hover,
button:focus, button:focus,
button:hover, button:hover,
input[type='button']:focus, input[type='button']:focus,
@ -93,7 +94,8 @@ input[type='submit'][disabled] {
opacity: .5; opacity: .5;
} }
.button[disabled]:focus, .button[disabled]:hover, .button[disabled]:focus,
.button[disabled]:hover,
button[disabled]:focus, button[disabled]:focus,
button[disabled]:hover, button[disabled]:hover,
input[type='button'][disabled]:focus, input[type='button'][disabled]:focus,
@ -115,7 +117,8 @@ input[type='submit'].button-outline {
color: var(--color-primary); color: var(--color-primary);
} }
.button.button-outline:focus, .button.button-outline:hover, .button.button-outline:focus,
.button.button-outline:hover,
button.button-outline:focus, button.button-outline:focus,
button.button-outline:hover, button.button-outline:hover,
input[type='button'].button-outline:focus, input[type='button'].button-outline:focus,
@ -129,7 +132,8 @@ input[type='submit'].button-outline:hover {
color: var(--color-secondary); color: var(--color-secondary);
} }
.button.button-outline[disabled]:focus, .button.button-outline[disabled]:hover, .button.button-outline[disabled]:focus,
.button.button-outline[disabled]:hover,
button.button-outline[disabled]:focus, button.button-outline[disabled]:focus,
button.button-outline[disabled]:hover, button.button-outline[disabled]:hover,
input[type='button'].button-outline[disabled]:focus, input[type='button'].button-outline[disabled]:focus,
@ -152,7 +156,8 @@ input[type='submit'].button-clear {
color: var(--color-primary); color: var(--color-primary);
} }
.button.button-clear:focus, .button.button-clear:hover, .button.button-clear:focus,
.button.button-clear:hover,
button.button-clear:focus, button.button-clear:focus,
button.button-clear:hover, button.button-clear:hover,
input[type='button'].button-clear:focus, input[type='button'].button-clear:focus,
@ -166,7 +171,8 @@ input[type='submit'].button-clear:hover {
color: var(--color-secondary); color: var(--color-secondary);
} }
.button.button-clear[disabled]:focus, .button.button-clear[disabled]:hover, .button.button-clear[disabled]:focus,
.button.button-clear[disabled]:hover,
button.button-clear[disabled]:focus, button.button-clear[disabled]:focus,
button.button-clear[disabled]:hover, button.button-clear[disabled]:hover,
input[type='button'].button-clear[disabled]:focus, input[type='button'].button-clear[disabled]:focus,
@ -193,7 +199,7 @@ pre {
overflow-y: hidden; overflow-y: hidden;
} }
pre > code { pre>code {
border-radius: 0; border-radius: 0;
display: block; display: block;
padding: 1rem 1.5rem; padding: 1rem 1.5rem;
@ -220,7 +226,6 @@ input[type='text'],
input[type='url'], input[type='url'],
input[type='week'], input[type='week'],
input:not([type]), input:not([type]),
textarea,
select { select {
-webkit-appearance: none; -webkit-appearance: none;
background-color: transparent; background-color: transparent;
@ -233,6 +238,17 @@ select {
width: 100%; width: 100%;
} }
textarea {
-webkit-appearance: none;
background-color: transparent;
border: 0.1rem solid var(--color-quaternary);
border-radius: .4rem;
box-shadow: none;
box-sizing: inherit;
padding: .6rem 1.0rem .7rem;
width: 100%;
}
input[type='color']:focus, input[type='color']:focus,
input[type='date']:focus, input[type='date']:focus,
input[type='datetime']:focus, input[type='datetime']:focus,
@ -314,7 +330,7 @@ input[type='radio'] {
padding: 0; padding: 0;
} }
.row.row-no-padding > .column { .row.row-no-padding>.column {
padding: 0; padding: 0;
} }
@ -362,7 +378,8 @@ input[type='radio'] {
margin-left: 25%; margin-left: 25%;
} }
.row .column.column-offset-33, .row .column.column-offset-34 { .row .column.column-offset-33,
.row .column.column-offset-34 {
margin-left: 33.3333%; margin-left: 33.3333%;
} }
@ -378,7 +395,8 @@ input[type='radio'] {
margin-left: 60%; margin-left: 60%;
} }
.row .column.column-offset-66, .row .column.column-offset-67 { .row .column.column-offset-66,
.row .column.column-offset-67 {
margin-left: 66.6666%; margin-left: 66.6666%;
} }
@ -409,7 +427,8 @@ input[type='radio'] {
max-width: 25%; max-width: 25%;
} }
.row .column.column-33, .row .column.column-34 { .row .column.column-33,
.row .column.column-34 {
flex: 0 0 33.3333%; flex: 0 0 33.3333%;
max-width: 33.3333%; max-width: 33.3333%;
} }
@ -429,7 +448,8 @@ input[type='radio'] {
max-width: 60%; max-width: 60%;
} }
.row .column.column-66, .row .column.column-67 { .row .column.column-66,
.row .column.column-67 {
flex: 0 0 66.6666%; flex: 0 0 66.6666%;
max-width: 66.6666%; max-width: 66.6666%;
} }
@ -467,6 +487,7 @@ input[type='radio'] {
margin-left: -1.0rem; margin-left: -1.0rem;
width: calc(100% + 2.0rem); width: calc(100% + 2.0rem);
} }
.row .column { .row .column {
margin-bottom: inherit; margin-bottom: inherit;
padding: 0 1.0rem; padding: 0 1.0rem;
@ -478,7 +499,8 @@ a {
text-decoration: none; text-decoration: none;
} }
a:focus, a:hover { a:focus,
a:hover {
color: var(--color-secondary); color: var(--color-secondary);
} }

1
static/milligram.css.map Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

5
static/pico.min.css vendored

File diff suppressed because one or more lines are too long