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

feat: add open_managed team type #33672

Merged
merged 5 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion cms/djangoapps/models/settings/course_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def validate_single_topic(cls, topic_settings):
"""
error_list = []
valid_teamset_types = [TeamsetType.open.value, TeamsetType.public_managed.value,
TeamsetType.private_managed.value]
TeamsetType.private_managed.value, TeamsetType.open_managed.value]
valid_keys = {'id', 'name', 'description', 'max_team_size', 'type'}
teamset_type = topic_settings.get('type', {})
if teamset_type:
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/teams/static/teams/js/views/team_profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
discussionTopicID = this.model.get('discussion_topic_id'),
isMember = TeamUtils.isUserMemberOfTeam(memberships, this.context.userInfo.username),
isAdminOrStaff = this.context.userInfo.privileged || this.context.userInfo.staff,
isInstructorManagedTopic = TeamUtils.isInstructorManagedTopic(this.topic.attributes.type),
canJoinTeam = TeamUtils.canJoinTeam(this.context.userInfo, this.topic.attributes.type),
Ian2012 marked this conversation as resolved.
Show resolved Hide resolved
maxTeamSize = this.topic.getMaxTeamSize(this.context.courseMaxTeamSize);

// Assignments URL isn't provided if team assignments shouldn't be shown
// so we can treat it like a toggle
var showAssignments = !!this.context.teamsAssignmentsUrl;

var showLeaveLink = isMember && (isAdminOrStaff || !isInstructorManagedTopic);
var showLeaveLink = isMember && (isAdminOrStaff || canJoinTeam);

HtmlUtils.setHtml(
this.$el,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
} else if (!teamHasSpace) {
showJoinButton = false;
message = view.teamFullMessage;
} else if (info.canJoinTeam) {
showJoinButton = true;
} else if (!info.isAdminOrStaff && info.isInstructorManagedTopic) {
showJoinButton = false;
message = view.notJoinInstructorManagedTeam;
Expand Down Expand Up @@ -100,12 +102,14 @@
// this.topic.getMaxTeamSize() will return null for a managed team,
// but the size is considered to be arbitarily large.
var isInstructorManagedTopic = TeamUtils.isInstructorManagedTopic(this.topic.attributes.type);
var canJoinTeam = TeamUtils.canJoinTeam(this.context.userInfo, this.topic.attributes.type)
var teamHasSpace = isInstructorManagedTopic
|| (this.model.get('membership').length < this.topic.getMaxTeamSize(courseMaxTeamSize));

info.memberOfCurrentTeam = TeamUtils.isUserMemberOfTeam(this.model.get('membership'), username);
info.isAdminOrStaff = this.context.userInfo.privileged || this.context.userInfo.staff;
info.isInstructorManagedTopic = isInstructorManagedTopic;
info.canJoinTeam = canJoinTeam;

if (info.memberOfCurrentTeam) {
info.alreadyInTeamset = true;
Expand Down
7 changes: 7 additions & 0 deletions lms/djangoapps/teams/static/teams/js/views/team_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@
return topicType.toLowerCase() !== 'open';
},

canJoinTeam: function(userInfo, topicType) {
Ian2012 marked this conversation as resolved.
Show resolved Hide resolved
if (topicType === undefined) {
return false;
}
return userInfo.privileged || userInfo.staff || topicType.includes("open");
},

/** Shows info/error banner for team membership CSV upload
* @param: content - string or array for display
* @param: isError - true sets error styling, false/none uses info styling
Expand Down
5 changes: 4 additions & 1 deletion lms/djangoapps/teams/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ def get(self, request, course_id):
"teams": user_teams_data
},
"has_open_teamset": bool(teamset_counts_by_type[TeamsetType.open.value]),
"has_public_managed_teamset": bool(teamset_counts_by_type[TeamsetType.public_managed.value]),
"has_public_managed_teamset": bool(
teamset_counts_by_type[TeamsetType.public_managed.value] +
teamset_counts_by_type[TeamsetType.open_managed.value]
),
"has_managed_teamset": bool(
teamset_counts_by_type[TeamsetType.public_managed.value] +
teamset_counts_by_type[TeamsetType.private_managed.value]
Expand Down
1 change: 1 addition & 0 deletions openedx/core/lib/teams_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ class TeamsetType(Enum):
open = "open"
public_managed = "public_managed"
private_managed = "private_managed"
open_managed = "open_managed"

@classmethod
def get_default(cls):
Expand Down
Loading