Browse Source

Add a data migration to populate Member.role

pull/545/head
Pēteris Caune 3 years ago
parent
commit
d19cb8c681
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
2 changed files with 21 additions and 3 deletions
  1. +20
    -0
      hc/accounts/migrations/0041_fill_role.py
  2. +1
    -3
      hc/accounts/models.py

+ 20
- 0
hc/accounts/migrations/0041_fill_role.py View File

@ -0,0 +1,20 @@
# Generated by Django 3.2.4 on 2021-07-22 13:25
from django.db import migrations
def fill_member_role(apps, schema_editor):
Member = apps.get_model("accounts", "Member")
Member.objects.filter(rw=False).update(role="r")
Member.objects.filter(rw=True).update(role="w")
class Migration(migrations.Migration):
dependencies = [
("accounts", "0040_auto_20210722_1244"),
]
operations = [
migrations.RunPython(fill_member_role, migrations.RunPython.noop),
]

+ 1
- 3
hc/accounts/models.py View File

@ -428,9 +428,7 @@ class Member(models.Model):
project = models.ForeignKey(Project, models.CASCADE)
transfer_request_date = models.DateTimeField(null=True, blank=True)
rw = models.BooleanField(default=True, null=True)
role = models.CharField(
max_length=1, default=Role.REGULAR, choices=Role.choices, blank=True, null=True
)
role = models.CharField(max_length=1, default=Role.REGULAR, choices=Role.choices)
class Meta:
constraints = [


Loading…
Cancel
Save