Introduce optional raids.
This commit is contained in:
parent
9e4cdd3ec1
commit
d4341e5d0b
|
@ -63,7 +63,7 @@ class RaidResponseForm(ModelForm):
|
||||||
class RaidForm(ModelForm):
|
class RaidForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Raid
|
model = Raid
|
||||||
fields = ["title", "description", "date", "response_deadline"]
|
fields = ["title", "description", "is_optional", "date", "response_deadline"]
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
@ -76,6 +76,7 @@ class RaidForm(ModelForm):
|
||||||
self.helper.layout = Layout(
|
self.helper.layout = Layout(
|
||||||
Field("title"),
|
Field("title"),
|
||||||
Field("description"),
|
Field("description"),
|
||||||
|
Field("is_optional"),
|
||||||
Row(
|
Row(
|
||||||
Column("date", css_class="form-group col-md-6"),
|
Column("date", css_class="form-group col-md-6"),
|
||||||
Column("response_deadline", css_class="form-group col-md-6"),
|
Column("response_deadline", css_class="form-group col-md-6"),
|
||||||
|
|
18
drakul/raids/migrations/0004_raid_is_optional.py
Normal file
18
drakul/raids/migrations/0004_raid_is_optional.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.2.6 on 2019-11-20 22:36
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('raids', '0003_auto_20191119_0412'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='raid',
|
||||||
|
name='is_optional',
|
||||||
|
field=models.BooleanField(default=False, help_text='Designates whether this raid is optional. Optional raids are not included in attendance calculations.'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -23,6 +23,13 @@ class Raid(models.Model):
|
||||||
help_text="Defaults to 24 hours before date and time of raid if not set."
|
help_text="Defaults to 24 hours before date and time of raid if not set."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
is_optional = models.BooleanField(
|
||||||
|
default=False,
|
||||||
|
help_text=(
|
||||||
|
"Designates whether this raid is optional. Optional raids are not included in attendance calculations."
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ["-date"]
|
ordering = ["-date"]
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
</h4>
|
</h4>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text">{{ raid.description | urlize | linebreaksbr | default:"<em>No description</em>" }}</p>
|
<p class="card-text">{{ raid.description | urlize | linebreaksbr | default:"<em>No description</em>" }}</p>
|
||||||
|
{% if raid.is_optional %}
|
||||||
|
<p class="card-text mb-0"><small class="text-muted">This raid is optional.</small></p>
|
||||||
|
{% endif %}
|
||||||
<p class="card-text"><small class="text-muted">Response deadline: {{ raid.response_deadline }}.</small></p>
|
<p class="card-text"><small class="text-muted">Response deadline: {{ raid.response_deadline }}.</small></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
24
migrate.py
Normal file
24
migrate.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import json
|
||||||
|
|
||||||
|
with open("data.json", "r") as file:
|
||||||
|
data = json.load(file)
|
||||||
|
for o in data:
|
||||||
|
print(o)
|
||||||
|
if o["model"] == "raids.raidresponse":
|
||||||
|
if o["fields"]["status"] >= 2: # SIGNED_UP
|
||||||
|
o["fields"]["attendance"] = 1.0
|
||||||
|
else:
|
||||||
|
o["fields"]["attendance"] = 0.0
|
||||||
|
if o["model"] == "users.user":
|
||||||
|
o["fields"]["rank"] = 3 # veteran
|
||||||
|
|
||||||
|
print("=============================================")
|
||||||
|
print("=============================================")
|
||||||
|
print("=============================================")
|
||||||
|
|
||||||
|
with open("new.json", "w") as file:
|
||||||
|
skip = ["contenttypes.contenttype", "auth.permission", "admin.logentry"]
|
||||||
|
thedump = [d for d in data if d["model"] not in skip]
|
||||||
|
for d in thedump:
|
||||||
|
print(d)
|
||||||
|
json.dump(thedump, file)
|
Loading…
Reference in a new issue