#156 pagure_owner_alias: Output two jsons, one just with admin ACL
Opened 2 years ago by frantisekz. Modified 9 months ago
frantisekz/pagure-dist-git owner_admin_only  into  master

file modified
+28 -2
@@ -72,8 +72,34 @@ 

          namespace, package, admin = entry

          output[namespace][package] = [admin]

  

-     # Add the users with commit and admin ACLs

+     # Add the users with admin ACLs first

+     query = (

+         session.query(

+             model.Project.namespace,

+             model.Project.name,

+             model.User.user,

+         )

+         .filter(model.Project.id == model.ProjectUser.project_id)

+         .filter(model.ProjectUser.user_id == model.User.id)

+         .filter(model.ProjectUser.access == "admin")

+         .filter(model.Project.parent_id == None)

+         .filter(model.Project.is_fork == False)

+     )

+ 

+     for entry in query.all():

+         namespace, package, user = entry

+         output[namespace][package].add(user)

+ 

+     # Convert the sets into lists

+     final = collections.defaultdict(dict)

+     for ns in output:

+         for pkg in output[ns]:

+             final[ns][pkg] = list(output[ns][pkg])

+ 

+     with open(os.path.join(args[0], "pagure_owner_alias_admins.json"), "w") as stream:

+         json.dump(final, stream, indent=4, sort_keys=True)

  

+     # Add the users with commit ACLs

      query = (

          session.query(

              model.Project.namespace,
@@ -82,7 +108,7 @@ 

          )

          .filter(model.Project.id == model.ProjectUser.project_id)

          .filter(model.ProjectUser.user_id == model.User.id)

-         .filter(model.ProjectUser.access.in_(["commit", "admin"]))

+         .filter(model.ProjectUser.access == "commit")

          .filter(model.Project.parent_id == None)

          .filter(model.Project.is_fork == False)

      )

Supports: https://pagure.io/fedora-qa/packager_dashboard/issue/153

(I did not actually test this, it should work though (tm))

pagure_owner_alias_admins wouldn't that confuse people about the *-admin@fp.o email alias?

pagure_owner_alias_admins wouldn't that confuse people about the *-admin@fp.o email alias?

Yeah, fair point, it could. What about pagure_owner_alias_admin_acl_only ?

Couldn't you use something like proposed in https://pagure.io/pagure-dist-git/issue/155 ?

That seems like the better solution... one file with all the info people need in one place?

rebased onto 9a2fd08

9 months ago
Metadata