Compare commits

..

No commits in common. "a9d9854844e64af481ef2ab4fd679e8ec1ba01c8" and "502698a501fafb98fc6042a7d0c948f072a68a1a" have entirely different histories.

6 changed files with 51 additions and 97 deletions

View file

@ -162,7 +162,6 @@ CRISPY_TEMPLATE_PACK = "bootstrap4"
DEFAULT_ATTENDANCE = { DEFAULT_ATTENDANCE = {
"NO_RESPONSE": 0.0, "NO_RESPONSE": 0.0,
"SIGNED_OFF": 0.0, "SIGNED_OFF": 0.0,
"BACKUP": 0.0,
"SIGNED_UP": 1.0, "SIGNED_UP": 1.0,
"STANDBY": 1.0, "STANDBY": 1.0,
"CONFIRMED": 1.0, "CONFIRMED": 1.0,

View file

@ -142,42 +142,32 @@ a.response-status-signed-off-bg:hover, a.response-status-1-bg:hover {
background-color: #bd2130; background-color: #bd2130;
} }
.response-status-backup-bg, .response-status-2-bg { /* warning */ .response-status-signed-up-bg, .response-status-2-bg { /* info */
color: #212529;
background-color: #ffc107;
}
a.response-status-backup-bg:focus, a.response-status-2-bg:focus,
a.response-status-backup-bg:hover, a.response-status-2-bg:hover {
color: #212529;
background-color: #d39e00;
}
.response-status-signed-up-bg, .response-status-3-bg { /* info */
color: #fff; color: #fff;
background-color: #17a2b8; background-color: #17a2b8;
} }
a.response-status-signed-up-bg:focus, a.response-status-3-bg:focus, a.response-status-signed-up-bg:focus, a.response-status-2-bg:focus,
a.response-status-signed-up-bg:hover, a.response-status-3-bg:hover { a.response-status-signed-up-bg:hover, a.response-status-2-bg:hover {
color: #fff; color: #fff;
background-color: #117a8b; background-color: #117a8b;
} }
.response-status-standby-bg, .response-status-4-bg { /* warning */ .response-status-standby-bg, .response-status-3-bg { /* warning */
color: #212529; color: #212529;
background-color: #ffc107; background-color: #ffc107;
} }
a.response-status-standby-bg:focus, a.response-status-4-bg:focus, a.response-status-standby-bg:focus, a.response-status-3-bg:focus,
a.response-status-standby-bg:hover, a.response-status-4-bg:hover { a.response-status-standby-bg:hover, a.response-status-3-bg:hover {
color: #212529; color: #212529;
background-color: #d39e00; background-color: #d39e00;
} }
.response-status-confirmed-bg, .response-status-5-bg { /* success */ .response-status-confirmed-bg, .response-status-4-bg { /* success */
color: #fff; color: #fff;
background-color: #28a745; background-color: #28a745;
} }
a.response-status-confirmed-bg:focus, a.response-status-5-bg:focus, a.response-status-confirmed-bg:focus, a.response-status-4-bg:focus,
a.response-status-confirmed-bg:hover, a.response-status-5-bg:hover { a.response-status-confirmed-bg:hover, a.response-status-4-bg:hover {
color: #fff; color: #fff;
background-color: #1e7e34; background-color: #1e7e34;
} }

View file

@ -18,34 +18,29 @@ class RaidResponseForm(ModelForm):
self.fields["role"].initial = user.main.role self.fields["role"].initial = user.main.role
self.fields["status"].choices = RaidResponse.UserStatus.choices self.fields["status"].choices = RaidResponse.UserStatus.choices
is_signed_up = self.instance.status == RaidResponse.Status.SIGNED_UP
self.helper = FormHelper() self.helper = FormHelper()
if self.instance.status <= RaidResponse.Status.SIGNED_OFF:
signup_button = StrictButton(
"Sign Up",
type="submit",
name="status",
value=RaidResponse.Status.SIGNED_UP,
css_class="btn-success btn-block"
)
else:
signup_button = StrictButton(
"Change",
type="submit",
name="status",
value=RaidResponse.Status.SIGNED_UP,
css_class="btn-primary btn-block"
)
self.helper.layout = Layout( self.helper.layout = Layout(
Row( Row(
Column("character", css_class="col-md-3"), Column("character", css_class="col-md-3"),
Column("role", css_class="col-md-2"), Column("role", css_class="col-md-3"),
Column( Column(signup_button, css_class="col-md-3"),
StrictButton(
"Sign Up" if not is_signed_up else "Change",
type="submit",
name="status",
value=RaidResponse.Status.SIGNED_UP,
css_class=f"btn-block {'btn-success' if not is_signed_up else 'btn-primary'}"
),
css_class="col-md-3"
),
Column(
StrictButton(
"Backup",
type="submit",
name="status",
value=RaidResponse.Status.BACKUP,
css_class="btn-warning btn-block",
disabled=self.instance.pk and self.instance.status == RaidResponse.Status.BACKUP
),
css_class="col-md-2"
),
Column( Column(
StrictButton( StrictButton(
"Sign Off", "Sign Off",
@ -55,7 +50,7 @@ class RaidResponseForm(ModelForm):
css_class="btn-danger btn-block", css_class="btn-danger btn-block",
disabled=self.instance.pk and self.instance.status == RaidResponse.Status.SIGNED_OFF disabled=self.instance.pk and self.instance.status == RaidResponse.Status.SIGNED_OFF
), ),
css_class="col-md-2" css_class="col-md-3"
), ),
css_class="form-row" css_class="form-row"
) )

View file

@ -1,20 +0,0 @@
# Generated by Django 3.0.2 on 2020-05-28 04:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('raids', '0008_auto_20200421_1753'),
]
# This migration is not complete, as we're introducing a new status 'backup' with the old value of 'signed up'.
# We should probably do a proper migration, but no one else is using this system, so we'll just do it manually.
operations = [
migrations.AlterField(
model_name='raidresponse',
name='status',
field=models.PositiveSmallIntegerField(choices=[(0, 'No Response'), (1, 'Signed Off'), (2, 'Backup'), (3, 'Signed Up'), (4, 'Standby'), (5, 'Confirmed')]),
),
]

View file

@ -65,10 +65,9 @@ class RaidResponse(models.Model):
class Status(models.IntegerChoices): class Status(models.IntegerChoices):
NO_RESPONSE = 0 NO_RESPONSE = 0
SIGNED_OFF = 1 SIGNED_OFF = 1
BACKUP = 2 SIGNED_UP = 2
SIGNED_UP = 3 STANDBY = 3
STANDBY = 4 CONFIRMED = 4
CONFIRMED = 5
@property @property
def default_attendance(self): def default_attendance(self):
@ -76,8 +75,7 @@ class RaidResponse(models.Model):
class UserStatus(models.IntegerChoices): class UserStatus(models.IntegerChoices):
SIGNED_OFF = 1 SIGNED_OFF = 1
BACKUP = 2 SIGNED_UP = 2
SIGNED_UP = 3
status = models.PositiveSmallIntegerField( status = models.PositiveSmallIntegerField(
choices=Status.choices choices=Status.choices
@ -116,9 +114,8 @@ class RaidResponse(models.Model):
self._original_status = self.status self._original_status = self.status
def clean(self): def clean(self):
# Make sure no-responses and sign-offs are character- and role-agnostic, but all other responses are not # Make sure no-responses and sign-offs are role-agnostic, but all other responses are not
if self.status <= RaidResponse.Status.SIGNED_OFF: if self.status <= RaidResponse.Status.SIGNED_OFF:
self.character = self.character.user.main
self.role = None self.role = None
elif self.role is None: elif self.role is None:
raise ValidationError({"role": "This field is required."}) raise ValidationError({"role": "This field is required."})

View file

@ -28,20 +28,18 @@
</div> </div>
<select class="custom-select" id="change-status-from-status-select"> <select class="custom-select" id="change-status-from-status-select">
<option value="1">Signed Off</option> <option value="1">Signed Off</option>
<option value="2">Backup</option> <option selected value="2">Signed Up</option>
<option selected value="3">Signed Up</option> <option value="3">Standby</option>
<option value="4">Standby</option> <option value="4">Confirmed</option>
<option value="5">Confirmed</option>
</select> </select>
<div class="input-group-append input-group-prepend"> <div class="input-group-append input-group-prepend">
<label class="input-group-text" for="change-status-to-status-select">to</label> <label class="input-group-text" for="change-status-to-status-select">to</label>
</div> </div>
<select class="custom-select" id="change-status-to-status-select"> <select class="custom-select" id="change-status-to-status-select">
<option value="1">Signed Off</option> <option value="1">Signed Off</option>
<option value="2">Backup</option> <option value="2">Signed Up</option>
<option value="3">Signed Up</option> <option value="3">Standby</option>
<option value="4">Standby</option> <option selected value="4">Confirmed</option>
<option selected value="5">Confirmed</option>
</select> </select>
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" <button class="btn btn-outline-secondary" type="button"
@ -61,10 +59,9 @@
</div> </div>
<select class="custom-select" id="set-attendance-status-select"> <select class="custom-select" id="set-attendance-status-select">
<option value="1">Signed Off</option> <option value="1">Signed Off</option>
<option value="2">Backup</option> <option value="2">Signed Up</option>
<option value="3">Signed Up</option> <option value="3">Standby</option>
<option value="4">Standby</option> <option selected value="4">Confirmed</option>
<option selected value="5">Confirmed</option>
</select> </select>
<input type="number" class="form-control" id="set-attendance-value-input" aria-label="Attendance Input" value="1.0"> <input type="number" class="form-control" id="set-attendance-value-input" aria-label="Attendance Input" value="1.0">
<div class="input-group-append"> <div class="input-group-append">
@ -80,16 +77,15 @@
</div> </div>
<hr> <hr>
<div class="row"> <div class="row">
<div class="col-md-7"> <div class="col-md-6">
<div class="alert alert-primary d-flex justify-content-around" role="alert"> <div class="alert alert-primary d-flex justify-content-around" role="alert">
<div><span id="total-signed-off" class="font-weight-bold">?</span> Signed Off</div>
<div><span id="total-backup" class="font-weight-bold">?</span> Backup</div>
<div><span id="total-signed-up" class="font-weight-bold">?</span> Signed Up</div>
<div><span id="total-standby" class="font-weight-bold">?</span> Standby</div>
<div><span id="total-confirmed" class="font-weight-bold">?</span> Confirmed</div> <div><span id="total-confirmed" class="font-weight-bold">?</span> Confirmed</div>
<div><span id="total-standby" class="font-weight-bold">?</span> Standby</div>
<div><span id="total-signed-up" class="font-weight-bold">?</span> Signed Up</div>
<div><span id="total-signed-off" class="font-weight-bold">?</span> Signed Off</div>
</div> </div>
</div> </div>
<div class="col-md-5"> <div class="col-md-6">
<div class="alert alert-success d-flex justify-content-around" role="alert"> <div class="alert alert-success d-flex justify-content-around" role="alert">
<div class="font-weight-bolder">Confirmed</div> <div class="font-weight-bolder">Confirmed</div>
<div><span id="total-confirmed-tank" class="font-weight-bold">?</span> Tanks</div> <div><span id="total-confirmed-tank" class="font-weight-bold">?</span> Tanks</div>
@ -108,10 +104,9 @@
{% block scripts %} {% block scripts %}
<script> <script>
const SIGNED_OFF = 1; const SIGNED_OFF = 1;
const BACKUP = 2; const SIGNED_UP = 2;
const SIGNED_UP = 3; const STAND_BY = 3;
const STAND_BY = 4; const CONFIRMED = 4;
const CONFIRMED = 5;
const TANK = 1; const TANK = 1;
const HEALER = 2; const HEALER = 2;
@ -127,7 +122,6 @@
function updateSelectTotals() { function updateSelectTotals() {
let statusTotals = { let statusTotals = {
[SIGNED_OFF]: 0, [SIGNED_OFF]: 0,
[BACKUP]: 0,
[SIGNED_UP]: 0, [SIGNED_UP]: 0,
[STAND_BY]: 0, [STAND_BY]: 0,
[CONFIRMED]: 0 [CONFIRMED]: 0
@ -153,7 +147,6 @@
document.querySelector("#total-confirmed-damage").innerHTML = confirmedTotals[DAMAGE].toString(); document.querySelector("#total-confirmed-damage").innerHTML = confirmedTotals[DAMAGE].toString();
document.querySelector("#total-signed-off").innerHTML = statusTotals[SIGNED_OFF].toString(); document.querySelector("#total-signed-off").innerHTML = statusTotals[SIGNED_OFF].toString();
document.querySelector("#total-backup").innerHTML = statusTotals[BACKUP].toString();
document.querySelector("#total-signed-up").innerHTML = statusTotals[SIGNED_UP].toString(); document.querySelector("#total-signed-up").innerHTML = statusTotals[SIGNED_UP].toString();
document.querySelector("#total-standby").innerHTML = statusTotals[STAND_BY].toString(); document.querySelector("#total-standby").innerHTML = statusTotals[STAND_BY].toString();
document.querySelector("#total-confirmed").innerHTML = statusTotals[CONFIRMED].toString(); document.querySelector("#total-confirmed").innerHTML = statusTotals[CONFIRMED].toString();