diff --git a/drakul/raids/admin.py b/drakul/raids/admin.py index 76944fb..3275a5a 100755 --- a/drakul/raids/admin.py +++ b/drakul/raids/admin.py @@ -5,7 +5,7 @@ from .models import Raid, RaidResponse, RaidComment, InstanceReset class RaidResponseInline(admin.TabularInline): model = RaidResponse - fields = ["character", "role", "status", "attendance", "note"] + fields = ["character", "role", "status", "group", "attendance", "note"] extra = 0 diff --git a/drakul/raids/forms.py b/drakul/raids/forms.py index eaa46d4..eb13f2a 100644 --- a/drakul/raids/forms.py +++ b/drakul/raids/forms.py @@ -109,7 +109,7 @@ class RaidCommentForm(ModelForm): RaidResponseFormSet = inlineformset_factory( Raid, # parent model RaidResponse, - fields=["character", "role", "status", "note", "attendance"], + fields=["character", "role", "status", "group", "note", "attendance"], can_delete=False, extra=1 ) @@ -124,6 +124,7 @@ class RaidResponseFormSetHelper(FormHelper): Field("character", css_class="character-select"), Field("role", css_class="role-select"), Field("status", css_class="status-select"), + Field("group", css_class="group-select"), Field("note"), Field("attendance", css_class="attendance-input"), ) diff --git a/drakul/raids/migrations/0008_auto_20200421_1753.py b/drakul/raids/migrations/0008_auto_20200421_1753.py new file mode 100644 index 0000000..faa0135 --- /dev/null +++ b/drakul/raids/migrations/0008_auto_20200421_1753.py @@ -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), + ), + ] diff --git a/drakul/raids/models.py b/drakul/raids/models.py index 3c3a624..a9265d7 100755 --- a/drakul/raids/models.py +++ b/drakul/raids/models.py @@ -81,6 +81,17 @@ class RaidResponse(models.Model): 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( max_digits=3, decimal_places=2, @@ -93,7 +104,7 @@ class RaidResponse(models.Model): ) class Meta: - ordering = ["-status", "role", "character__klass", "character__user__rank", "character__name"] + ordering = ["-status", "group", "role", "character__klass", "character__user__rank", "character__name"] constraints = [ models.UniqueConstraint(fields=["raid", "character"], name="unique_character_raid_signup") ] diff --git a/drakul/raids/templates/raids/raid_detail.html b/drakul/raids/templates/raids/raid_detail.html index 245b3ce..b90eb58 100644 --- a/drakul/raids/templates/raids/raid_detail.html +++ b/drakul/raids/templates/raids/raid_detail.html @@ -54,44 +54,49 @@ {% regroup raid.responses.all by get_status_display as status_responses_list %} {% for status, status_responses in status_responses_list %} -
-
- {{ status }} ({{ status_responses | length }}) - Export -
-
- {% regroup status_responses by get_role_display as role_responses_list %} - {% for role, role_responses in role_responses_list %} - {% if role is not None %} -
{{ role }} ({{ role_responses | length }})
- {% endif %} -
- {% regroup role_responses by character.klass as class_responses_list %} - {% for class, class_responses in class_responses_list %} -
- {% regroup class_responses by character.user.rank as rank_responses_list %} - {% for rank, rank_responses in rank_responses_list %} -
-
-
{{ rank }}
-
-
- {% for response in rank_responses %} - - {% if response.character != response.character.user.main %} - {{ response.character.name }} - {% else %} - {{ response.character.name }} - {% endif %} - + {% regroup status_responses by get_group_display as group_responses_list %} + {% for group, group_responses in group_responses_list %} +
+
+ + {{ status }}{% if group_responses_list|length > 1 %}: {{ group }}{% endif %} ({{ status_responses | length }}) + + Export +
+
+ {% regroup group_responses by get_role_display as role_responses_list %} + {% for role, role_responses in role_responses_list %} + {% if role is not None %} +
{{ role }} ({{ role_responses | length }})
+ {% endif %} +
+ {% regroup role_responses by character.klass as class_responses_list %} + {% for class, class_responses in class_responses_list %} +
+ {% regroup class_responses by character.user.rank as rank_responses_list %} + {% for rank, rank_responses in rank_responses_list %} +
+
+
{{ rank }}
+
+
+ {% for response in rank_responses %} + + {% if response.character != response.character.user.main %} + {{ response.character.name }} + {% else %} + {{ response.character.name }} + {% endif %} + + {% endfor %} {% endfor %} +
{% endfor %}
{% endfor %}
- {% endfor %}
-
+ {% endfor %} {% endfor %}
diff --git a/drakul/raids/templates/raids/raid_response_table_inline_formset.html b/drakul/raids/templates/raids/raid_response_table_inline_formset.html index 9cd90bd..2d6448a 100644 --- a/drakul/raids/templates/raids/raid_response_table_inline_formset.html +++ b/drakul/raids/templates/raids/raid_response_table_inline_formset.html @@ -44,17 +44,23 @@ {% regroup formset by status.value as status_forms_list %} {% for status, status_forms in status_forms_list %} - {% regroup status_forms by role.value as role_forms_list %} - {% for role, role_forms in role_forms_list %} - {% for form in role_forms %} - {% if form_show_errors and not form.is_extra %} - {% include "bootstrap4/errors.html" %} + {% 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 form in role_forms %} + {% if form_show_errors and not form.is_extra %} + {% include "bootstrap4/errors.html" %} + {% endif %} + + {% for field in form %} + {% include 'bootstrap4/field.html' with tag="td" form_show_labels=False %} + {% endfor %} + + {% endfor %} + {% if not forloop.last %} + {% endif %} - - {% for field in form %} - {% include 'bootstrap4/field.html' with tag="td" form_show_labels=False %} - {% endfor %} - {% endfor %} {% if not forloop.last %}