diff --git a/drakul/raids/forms.py b/drakul/raids/forms.py index 070e47c..bec8261 100644 --- a/drakul/raids/forms.py +++ b/drakul/raids/forms.py @@ -63,7 +63,7 @@ class RaidResponseForm(ModelForm): class RaidForm(ModelForm): class Meta: model = Raid - fields = ["title", "description", "date", "response_deadline"] + fields = ["title", "description", "is_optional", "date", "response_deadline"] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -76,6 +76,7 @@ class RaidForm(ModelForm): self.helper.layout = Layout( Field("title"), Field("description"), + Field("is_optional"), Row( Column("date", css_class="form-group col-md-6"), Column("response_deadline", css_class="form-group col-md-6"), diff --git a/drakul/raids/migrations/0004_raid_is_optional.py b/drakul/raids/migrations/0004_raid_is_optional.py new file mode 100644 index 0000000..b5d80d5 --- /dev/null +++ b/drakul/raids/migrations/0004_raid_is_optional.py @@ -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.'), + ), + ] diff --git a/drakul/raids/models.py b/drakul/raids/models.py index a363c18..bf45f78 100755 --- a/drakul/raids/models.py +++ b/drakul/raids/models.py @@ -23,6 +23,13 @@ class Raid(models.Model): 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: ordering = ["-date"] diff --git a/drakul/raids/templates/raids/raid_detail.html b/drakul/raids/templates/raids/raid_detail.html index 6d9802f..f4f3dc8 100644 --- a/drakul/raids/templates/raids/raid_detail.html +++ b/drakul/raids/templates/raids/raid_detail.html @@ -15,6 +15,9 @@

{{ raid.description | urlize | linebreaksbr | default:"No description" }}

+ {% if raid.is_optional %} +

This raid is optional.

+ {% endif %}

Response deadline: {{ raid.response_deadline }}.

diff --git a/migrate.py b/migrate.py new file mode 100644 index 0000000..b1936df --- /dev/null +++ b/migrate.py @@ -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)