Skip to content
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
4 changes: 4 additions & 0 deletions api/dashboard/campus/dash_campus_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,17 @@ def assign_ig_campus_lead(chapter, new_lead, acting_user_id):
{
"title": ig_name,
"description": f"{ig_name} Interest Group Member",
"is_execom_role": False,
},
{
"title": RoleType.IG_CAMPUS_LEAD_ROLE(ig_code),
"description": f"{ig_name} Interest Group Campus Lead",
"is_execom_role": True,
},
{
"title": RoleType.IG_LEAD_ROLE(ig_code),
"description": f"{ig_name} Interest Group Lead",
"is_execom_role": False,
},
]

Expand All @@ -149,6 +152,7 @@ def assign_ig_campus_lead(chapter, new_lead, acting_user_id):
"description": role_data["description"],
"created_by_id": acting_user_id,
"updated_by_id": acting_user_id,
"is_execom_role": role_data["is_execom_role"],
}
)

Expand Down
31 changes: 14 additions & 17 deletions api/dashboard/campus/events_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,9 @@ def get(self, request):
is_alumni=False,
).values_list("user_id", flat=True)

# Extracted all non-execom system roles to properly support listing dynamic custom/IG roles
BLACKLIST_ROLES = [
RoleType.ADMIN.value, RoleType.FELLOW.value, RoleType.APPRAISER.value,
RoleType.ZONAL_CAMPUS_LEAD.value, RoleType.DISTRICT_CAMPUS_LEAD.value,
RoleType.MENTOR.value, RoleType.COMPANY.value, RoleType.BOT_DEV.value,
RoleType.TECH_TEAM.value, RoleType.CAMPUS_ACTIVATION_TEAM.value,
RoleType.DISCORD_MANAGER.value, RoleType.EX_OFFICIAL.value,
RoleType.INTERN.value, RoleType.PRE_MEMBER.value, RoleType.SUSPEND.value,
RoleType.MULEARNER.value, RoleType.STUDENT.value, RoleType.ASSOCIATE.value,
RoleType.IG_LEAD.value
]

execom_links = UserRoleLink.objects.filter(
user_id__in=campus_user_ids
).exclude(
role__title__in=BLACKLIST_ROLES
user_id__in=campus_user_ids,
role__is_execom_role=True,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Legacy Execom Roles Stay Unclassified

The new column defaults to false, and this PR does not backfill existing custom execom or IG campus-lead roles. Once the column exists, members holding those roles disappear from the roster even though the old blacklist included them; the assignment path also rejects their existing role titles as non-execom.

).select_related("user", "role")

serializer = campus_serializers.ExecomMemberSerializer(
Expand Down Expand Up @@ -300,12 +287,17 @@ def post(self, request):

# Fetch role by title
role = Role.objects.filter(title=role_title).first()
if role is not None and not role.is_execom_role:
return CustomResponse(
general_message=f"'{role_title}' is already in use by another feature and cannot be assigned as an execom role"
).get_failure_response()
if role is None:
role = Role.objects.create(
id=str(uuid.uuid4()),
title=role_title,
created_by_id=user_id,
updated_by_id=user_id
updated_by_id=user_id,
is_execom_role=True,
)

# Remove existing holder of this role in the campus
Expand Down Expand Up @@ -490,13 +482,18 @@ def post(self, request):

role = Role.objects.filter(title=role_title).first()
if role:
if not role.is_execom_role:
return CustomResponse(
general_message=f"'{role_title}' is already in use by another feature and cannot be created as an execom role"
).get_failure_response()
return CustomResponse(general_message="Role already exists").get_success_response()

Role.objects.create(
id=str(uuid.uuid4()),
title=role_title,
created_by_id=user_id,
updated_by_id=user_id
updated_by_id=user_id,
is_execom_role=True,
)

return CustomResponse(general_message="Role created successfully").get_success_response()
Expand Down
4 changes: 4 additions & 0 deletions api/dashboard/ig/dash_ig_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,17 @@ def post(self, request):
{
"title": ig_name,
"description": f"{ig_name} Interest Group Member",
"is_execom_role": False,
},
{
"title": RoleType.IG_CAMPUS_LEAD_ROLE(ig_code),
"description": f"{ig_name} Interest Group Campus Lead",
"is_execom_role": True,
},
{
"title": RoleType.IG_LEAD_ROLE(ig_code),
"description": f"{ig_name} Interest Group Lead",
"is_execom_role": False,
},
]

Expand All @@ -210,6 +213,7 @@ def post(self, request):
"description": role_data["description"],
"created_by_id": request_data.get("created_by"),
"updated_by_id": request_data.get("updated_by"),
"is_execom_role": role_data["is_execom_role"],
}
)

Expand Down
7 changes: 7 additions & 0 deletions api/dashboard/user/dash_user_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,13 @@ class Meta:
"district",
]

def validate_interest_groups(self, interest_group_ids):
if len(interest_group_ids) > 3:
raise serializers.ValidationError(
"Cannot select more than 3 interest groups"
)
return interest_group_ids

def to_representation(self, instance):
data = super().to_representation(instance)

Expand Down
1 change: 1 addition & 0 deletions db/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ class Role(models.Model):
created_by = models.ForeignKey(User, on_delete=models.SET(settings.SYSTEM_ADMIN_ID), db_column='created_by',
related_name='role_created_by')
created_at = models.DateTimeField(auto_now_add=True)
is_execom_role = models.BooleanField(default=False)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Role Column Missing From Schema

Role is unmanaged, but no matching schema.sql or alter-scripts/ change adds this column. Deployments using the repository schema will make ORM reads and the new execom filter reference a missing column, causing role-backed API requests to fail with a database error.


class Meta:
managed = False
Expand Down
Loading