Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2194] Add field "Autoassign when award is created" to Community Role Config #2218

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions amy/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ class Meta:
"display_name",
"link_to_award",
"award_badge_limit",
"autoassign_when_award_created",
"link_to_membership",
"additional_url",
"generic_relation_content_type",
Expand Down
1 change: 1 addition & 0 deletions amy/communityroles/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class CommunityRoleConfigAdmin(DynamicArrayMixin, admin.ModelAdmin):
"name",
"link_to_award",
"award_badge_limit",
"autoassign_when_award_created",
"link_to_membership",
"additional_url",
"generic_relation_content_type",
Expand Down
36 changes: 27 additions & 9 deletions amy/communityroles/fixtures/configs.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
"display_name": "Maintainer",
"link_to_award": true,
"award_badge_limit": 3,
"autoassign_when_award_created": false,
"link_to_membership": false,
"additional_url": false,
"generic_relation_content_type": 9
"generic_relation_content_type": 9,
"custom_key_labels": "[]"
}
},
{
Expand All @@ -24,9 +26,11 @@
"display_name": "Trainer",
"link_to_award": true,
"award_badge_limit": 4,
"autoassign_when_award_created": false,
"link_to_membership": false,
"additional_url": false,
"generic_relation_content_type": null
"generic_relation_content_type": null,
"custom_key_labels": "[]"
}
},
{
Expand All @@ -39,9 +43,11 @@
"display_name": "Instructor",
"link_to_award": false,
"award_badge_limit": null,
"autoassign_when_award_created": false,
"link_to_membership": false,
"additional_url": false,
"generic_relation_content_type": null
"generic_relation_content_type": null,
"custom_key_labels": "[]"
}
},
{
Expand All @@ -54,9 +60,11 @@
"display_name": "Curriculum Advisor",
"link_to_award": false,
"award_badge_limit": null,
"autoassign_when_award_created": false,
"link_to_membership": false,
"additional_url": false,
"generic_relation_content_type": 36
"generic_relation_content_type": 36,
"custom_key_labels": "[]"
}
},
{
Expand All @@ -69,9 +77,11 @@
"display_name": "Committee Member",
"link_to_award": false,
"award_badge_limit": 9,
"autoassign_when_award_created": false,
"link_to_membership": false,
"additional_url": false,
"generic_relation_content_type": null
"generic_relation_content_type": null,
"custom_key_labels": "[]"
}
},
{
Expand All @@ -84,9 +94,11 @@
"display_name": "Task Force Member",
"link_to_award": false,
"award_badge_limit": null,
"autoassign_when_award_created": false,
"link_to_membership": false,
"additional_url": false,
"generic_relation_content_type": null
"generic_relation_content_type": null,
"custom_key_labels": "[]"
}
},
{
Expand All @@ -99,9 +111,11 @@
"display_name": "Regional Coordinator",
"link_to_award": false,
"award_badge_limit": null,
"autoassign_when_award_created": false,
"link_to_membership": false,
"additional_url": false,
"generic_relation_content_type": null
"generic_relation_content_type": null,
"custom_key_labels": "[]"
}
},
{
Expand All @@ -114,9 +128,11 @@
"display_name": "The Carpentries Lab Editor",
"link_to_award": false,
"award_badge_limit": null,
"autoassign_when_award_created": false,
"link_to_membership": false,
"additional_url": true,
"generic_relation_content_type": null
"generic_relation_content_type": null,
"custom_key_labels": "[]"
}
},
{
Expand All @@ -129,9 +145,11 @@
"display_name": "The Carpentries Lab Reviewer",
"link_to_award": false,
"award_badge_limit": null,
"autoassign_when_award_created": false,
"link_to_membership": false,
"additional_url": true,
"generic_relation_content_type": null
"generic_relation_content_type": null,
"custom_key_labels": "[]"
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.14 on 2022-09-04 17:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('communityroles', '0002_custom_keys'),
]

operations = [
migrations.AddField(
model_name='communityroleconfig',
name='autoassign_when_award_created',
field=models.BooleanField(default=False, help_text='Should automatically assign a Community Role to a user, when a selected badge is awarded to them.', verbose_name='Auto-assign when award is created'),
),
]
6 changes: 6 additions & 0 deletions amy/communityroles/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class CommunityRoleConfig(CreatedUpdatedMixin, models.Model):
null=True,
blank=True,
)
autoassign_when_award_created = models.BooleanField(
"Auto-assign when award is created",
default=False,
help_text="Should automatically assign a Community Role to a user, when "
"a selected badge is awarded to them.",
)
link_to_membership = models.BooleanField("Should link to a Membership?")
additional_url = models.BooleanField("Should allow for additional URL?")
generic_relation_content_type = models.ForeignKey(
Expand Down