Skip to content

Commit

Permalink
Update membership types: merge Managing into Contributing
Browse files Browse the repository at this point in the history
Update `membership_type` on `Membership` model to reflect 2024 Bylaws Change 1 (psf/bylaws#4)

- Create data migration to merge `MANAGING` (3) into `CONTRIBUTING` (4).
- Update `Membership` model, remove `MANAGING`.
- Update all references: `MANAGING` to `CONTRIBUTING`.

Left gap in `membership_type` choice values to ease data migration process.

Closes python#2566
  • Loading branch information
dorian-adams committed Jan 22, 2025
1 parent 4e2bd04 commit f65ca85
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
2 changes: 1 addition & 1 deletion users/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def export_csv(modeladmin, request, queryset):
membership_name = {
0: 'Basic', 1: 'Supporting', 2: 'Sponsor', 3: 'Managing',
0: 'Basic', 1: 'Supporting', 2: 'Sponsor',
4: 'Contributing', 5: 'Fellow'
}
response = HttpResponse(content_type='text/csv')
Expand Down
24 changes: 24 additions & 0 deletions users/migrations/0016_auto_20250121_2256.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.17 on 2025-01-21 22:56

# Data migration: Merge MANAGING (3) membership_type into CONTRIBUTING (4)

from django.db import migrations


def update_membership_level(apps, schema_editor):
Membership = apps.get_model('users', 'Membership')
Membership.objects.filter(membership_type=3).update(membership_type=4)


class Migration(migrations.Migration):

dependencies = [
('users', '0015_alter_user_first_name'),
]

operations = [
migrations.RunPython(
update_membership_level,
migrations.RunPython.noop
)
]
18 changes: 18 additions & 0 deletions users/migrations/0017_alter_membership_membership_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.17 on 2025-01-22 03:20

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('users', '0016_auto_20250121_2256'),
]

operations = [
migrations.AlterField(
model_name='membership',
name='membership_type',
field=models.IntegerField(choices=[(0, 'Basic Member'), (1, 'Supporting Member'), (2, 'Sponsor Member'), (4, 'Contributing Member'), (5, 'Fellow')], default=0),
),
]
2 changes: 0 additions & 2 deletions users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,13 @@ class Membership(models.Model):
BASIC = 0
SUPPORTING = 1
SPONSOR = 2
MANAGING = 3
CONTRIBUTING = 4
FELLOW = 5

MEMBERSHIP_CHOICES = (
(BASIC, 'Basic Member'),
(SUPPORTING, 'Supporting Member'),
(SPONSOR, 'Sponsor Member'),
(MANAGING, 'Managing Member'),
(CONTRIBUTING, 'Contributing Member'),
(FELLOW, 'Fellow'),
)
Expand Down
2 changes: 1 addition & 1 deletion users/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_membership(self):

def test_higher_level_member(self):
member1 = MembershipFactory()
member2 = MembershipFactory(membership_type=Membership.SPONSOR)
member2 = MembershipFactory(membership_type=Membership.CONTRIBUTING)

self.assertFalse(member1.higher_level_member)
self.assertTrue(member2.higher_level_member)
Expand Down

0 comments on commit f65ca85

Please sign in to comment.