Umuzi-org / Tilde

Open source agile, collaborative learning platform.
52 stars 34 forks source link

Give new staff write access on all learner repos #667

Closed kingraphaii closed 9 months ago

kingraphaii commented 10 months ago

Related issues: [please specify]

Description:

Functionality should be in the Admin panel

We need to give a user access to all repos they have view access of the projects.

Second potential functionality give a staff member access to all repos that belong to:

What are you up to? Fill us in :)

Screenshots/videos

image

image

This makes use of the already existing invite_github_collaborators_to_repo method inside the RecruitProject model. Here is a snippet of it:

def invite_github_collaborators_to_repo(self):
  from social_auth.github_api import Api
  from social_auth.models import SocialProfile
  from git_real.helpers import add_collaborator, list_collaborators

  api = Api(GIT_REAL_BOT_USERNAME)
  repo = self.repository
  existing_collaborators = list_collaborators(api, repo.full_name)

  collaborator_users = {
      "reviewer users": list(self.reviewer_users.filter(active=True)),
      "assigned users": list(self.recruit_users.filter(active=True)),
      "users with explicit permission": self.get_users_with_permission(
          Team.PERMISSION_REPO_COLLABORATER_AUTO_ADD
      ),
  }

specifically, the users with explicit permission part. Team.PERMISSION_REPO_COLLABORATER_AUTO_ADD is a group of permissions as defined here:

class Team(AuthGroup, Mixins):
  ... 
  PERMISSION_REPO_COLLABORATER_AUTO_ADD = [
      # when a repo is created then folks with these permissions get added to the repo as collaborators
      PERMISSION_MANAGE_CARDS,
      PERMISSION_VIEW_ALL,
      PERMISSION_ASSIGN_REVIEWERS,
      PERMISSION_REVIEW_CARDS,
  ]
  ...

This new action basically "refreshes" github collaborators based on these permissions. So if new staff "john" and "sarah" have the same perms to a certain team, doing it for "john" would be enough to give both staff members access to their repos.

I solemnly swear that: