Add support for raid groups.
This commit is contained in:
parent
be63e62637
commit
1df3b67fa1
6 changed files with 90 additions and 45 deletions
|
@ -5,7 +5,7 @@ from .models import Raid, RaidResponse, RaidComment, InstanceReset
|
||||||
|
|
||||||
class RaidResponseInline(admin.TabularInline):
|
class RaidResponseInline(admin.TabularInline):
|
||||||
model = RaidResponse
|
model = RaidResponse
|
||||||
fields = ["character", "role", "status", "attendance", "note"]
|
fields = ["character", "role", "status", "group", "attendance", "note"]
|
||||||
extra = 0
|
extra = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ class RaidCommentForm(ModelForm):
|
||||||
RaidResponseFormSet = inlineformset_factory(
|
RaidResponseFormSet = inlineformset_factory(
|
||||||
Raid, # parent model
|
Raid, # parent model
|
||||||
RaidResponse,
|
RaidResponse,
|
||||||
fields=["character", "role", "status", "note", "attendance"],
|
fields=["character", "role", "status", "group", "note", "attendance"],
|
||||||
can_delete=False,
|
can_delete=False,
|
||||||
extra=1
|
extra=1
|
||||||
)
|
)
|
||||||
|
@ -124,6 +124,7 @@ class RaidResponseFormSetHelper(FormHelper):
|
||||||
Field("character", css_class="character-select"),
|
Field("character", css_class="character-select"),
|
||||||
Field("role", css_class="role-select"),
|
Field("role", css_class="role-select"),
|
||||||
Field("status", css_class="status-select"),
|
Field("status", css_class="status-select"),
|
||||||
|
Field("group", css_class="group-select"),
|
||||||
Field("note"),
|
Field("note"),
|
||||||
Field("attendance", css_class="attendance-input"),
|
Field("attendance", css_class="attendance-input"),
|
||||||
)
|
)
|
||||||
|
|
22
drakul/raids/migrations/0008_auto_20200421_1753.py
Normal file
22
drakul/raids/migrations/0008_auto_20200421_1753.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# Generated by Django 3.0.2 on 2020-04-21 17:53
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('raids', '0007_auto_20200421_0256'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='raidresponse',
|
||||||
|
options={'ordering': ['-status', 'group', 'role', 'character__klass', 'character__user__rank', 'character__name']},
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='raidresponse',
|
||||||
|
name='group',
|
||||||
|
field=models.PositiveSmallIntegerField(choices=[(1, 'Group 1'), (2, 'Group 2'), (3, 'Group 3'), (4, 'Group 4')], default=1),
|
||||||
|
),
|
||||||
|
]
|
|
@ -81,6 +81,17 @@ class RaidResponse(models.Model):
|
||||||
choices=Status.choices
|
choices=Status.choices
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class Groups(models.IntegerChoices):
|
||||||
|
GROUP_1 = 1
|
||||||
|
GROUP_2 = 2
|
||||||
|
GROUP_3 = 3
|
||||||
|
GROUP_4 = 4
|
||||||
|
|
||||||
|
group = models.PositiveSmallIntegerField(
|
||||||
|
choices=Groups.choices,
|
||||||
|
default=Groups.GROUP_1
|
||||||
|
)
|
||||||
|
|
||||||
attendance = models.DecimalField(
|
attendance = models.DecimalField(
|
||||||
max_digits=3,
|
max_digits=3,
|
||||||
decimal_places=2,
|
decimal_places=2,
|
||||||
|
@ -93,7 +104,7 @@ class RaidResponse(models.Model):
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ["-status", "role", "character__klass", "character__user__rank", "character__name"]
|
ordering = ["-status", "group", "role", "character__klass", "character__user__rank", "character__name"]
|
||||||
constraints = [
|
constraints = [
|
||||||
models.UniqueConstraint(fields=["raid", "character"], name="unique_character_raid_signup")
|
models.UniqueConstraint(fields=["raid", "character"], name="unique_character_raid_signup")
|
||||||
]
|
]
|
||||||
|
|
|
@ -54,13 +54,17 @@
|
||||||
|
|
||||||
{% regroup raid.responses.all by get_status_display as status_responses_list %}
|
{% regroup raid.responses.all by get_status_display as status_responses_list %}
|
||||||
{% for status, status_responses in status_responses_list %}
|
{% for status, status_responses in status_responses_list %}
|
||||||
|
{% regroup status_responses by get_group_display as group_responses_list %}
|
||||||
|
{% for group, group_responses in group_responses_list %}
|
||||||
<div class="card mb-2">
|
<div class="card mb-2">
|
||||||
<h6 class="card-header d-flex response-status-{{ status | slugify }}-bg">
|
<h6 class="card-header d-flex response-status-{{ status | slugify }}-bg">
|
||||||
<span class="mr-auto">{{ status }} ({{ status_responses | length }})</span>
|
<span class="mr-auto">
|
||||||
|
{{ status }}{% if group_responses_list|length > 1 %}: {{ group }}{% endif %} ({{ status_responses | length }})
|
||||||
|
</span>
|
||||||
<span type="button" class="badge badge-dark" data-toggle="modal" data-target="#exportModal">Export</span>
|
<span type="button" class="badge badge-dark" data-toggle="modal" data-target="#exportModal">Export</span>
|
||||||
</h6>
|
</h6>
|
||||||
<div class="card-body mb-n4">
|
<div class="card-body mb-n4">
|
||||||
{% regroup status_responses by get_role_display as role_responses_list %}
|
{% regroup group_responses by get_role_display as role_responses_list %}
|
||||||
{% for role, role_responses in role_responses_list %}
|
{% for role, role_responses in role_responses_list %}
|
||||||
{% if role is not None %}
|
{% if role is not None %}
|
||||||
<h6 class="card-title border-bottom pb-2">{{ role }} ({{ role_responses | length }})</h6>
|
<h6 class="card-title border-bottom pb-2">{{ role }} ({{ role_responses | length }})</h6>
|
||||||
|
@ -93,6 +97,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
<div id="comments" class="card mt-4 mb-4">
|
<div id="comments" class="card mt-4 mb-4">
|
||||||
<h6 class="card-header">Comments</h6>
|
<h6 class="card-header">Comments</h6>
|
||||||
|
|
|
@ -44,7 +44,9 @@
|
||||||
|
|
||||||
{% regroup formset by status.value as status_forms_list %}
|
{% regroup formset by status.value as status_forms_list %}
|
||||||
{% for status, status_forms in status_forms_list %}
|
{% for status, status_forms in status_forms_list %}
|
||||||
{% regroup status_forms by role.value as role_forms_list %}
|
{% regroup status_forms by group.value as group_forms_list %}
|
||||||
|
{% for group, group_forms in group_forms_list %}
|
||||||
|
{% regroup group_forms by role.value as role_forms_list %}
|
||||||
{% for role, role_forms in role_forms_list %}
|
{% for role, role_forms in role_forms_list %}
|
||||||
{% for form in role_forms %}
|
{% for form in role_forms %}
|
||||||
{% if form_show_errors and not form.is_extra %}
|
{% if form_show_errors and not form.is_extra %}
|
||||||
|
@ -56,6 +58,10 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% if not forloop.last %}
|
||||||
|
<tr><td class="p-1"></td></tr>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
{% if not forloop.last %}
|
{% if not forloop.last %}
|
||||||
<tr><td class="p-2"></td></tr>
|
<tr><td class="p-2"></td></tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in a new issue