On Thu, 2007-03-29 at 15:55 -0400, Warren Togami wrote: > One Time Changes > ================ [...] > 4) Modify existing Fedora CLA signing process to join fedora_cla instead > of cla_done. > > Automatic Changes Thereafter > ============================ > fedora_cla auto adds to cla_done > redhat_cla autoadds to cla_done > dell_cla autoadds to cla_done > Toshio's cvsextras -> fedorabugs code should work in these cases too? Patch attached to handle these two things. Notes: 1) This is untested code and could contain bugs. Please test that it does what it's supposed to when applying for a new Fedora Individual CLA and being approved for cvsextras. 2) This obsoletes my previous patch to auto-add fedorabugs when a person is approved for cvsextras. -Toshio
? fas1-auto-cla-fedorabugs.diff ? fas1-fedorabugs.patch Index: send-cla.cgi =================================================================== RCS file: /cvs/fedora/fedora-accounts/send-cla.cgi,v retrieving revision 1.15 diff -u -r1.15 send-cla.cgi --- send-cla.cgi 15 Jun 2006 20:57:55 -0000 1.15 +++ send-cla.cgi 2 Apr 2007 19:15:23 -0000 @@ -28,14 +28,14 @@ dbc.execute("SELECT * FROM person WHERE username = %s", (auth_username, )) arow = dbc.fetchhash() -dbc.execute("SELECT id FROM project_group WHERE name = 'cla_done'") +dbc.execute("SELECT id FROM project_group WHERE name = 'fedora_cla'") if not dbc.rowcount: print "The accounts system is awaiting setup." sys.exit(1) -cla_done_id = dbc.fetchone()[0] +fedora_cla_id = dbc.fetchone()[0] dbc.execute("SELECT * FROM role WHERE person_id = %s AND project_group_id = %s", - (arow['id'], cla_done_id)) + (arow['id'], fedora_cla_id)) role_row = dbc.fetchhash() if role_row and role_row['role_status'] == 'approved': print "Your Contributor License Agreement for the %s account has already been approved." % auth_username @@ -96,10 +96,10 @@ if role_row: dbc.execute("UPDATE role SET role_status = %s WHERE person_id = %s AND project_group_id = %s AND role_status <> 'approved'", - (arow['signingcode'], arow['id'], cla_done_id)) + (arow['signingcode'], arow['id'], fedora_cla_id)) else: dbc.execute("INSERT INTO role (person_id, project_group_id, role_type, role_domain, role_status) VALUES (%s, %s, %s, %s, %s)", - (arow['id'], cla_done_id, 'user', None, arow['signingcode'])) + (arow['id'], fedora_cla_id, 'user', None, arow['signingcode'])) dbh.commit() print """An e-mail has been sent to you with the Fedora Individual Contributor License Agreement. Please follow the Index: website.py =================================================================== RCS file: /cvs/fedora/fedora-accounts/website.py,v retrieving revision 1.3 diff -u -r1.3 website.py --- website.py 30 Mar 2007 20:10:09 -0000 1.3 +++ website.py 2 Apr 2007 19:15:23 -0000 @@ -20,6 +20,13 @@ dbname_map = {'auth':'fedorausers'} dbctx_map = {'auth':'live', 'metrics':'metrics-source'} dbcnx_map = {} +# Mapping of group to groups that are automatically added to a user when the +# original group is approved. +auto_approve_groups = {'cvsextras' : ('fedorabugs',), + 'dell_cla' : ('cla_done',), + 'fedora_cla' : ('cla_done',), + 'redhat_cla' : ('cla_done',) + } fh = aline = pieces = None if os.environ.has_key('HOME') and os.path.isfile(os.environ.get('HOME') + '/.fedora-db-access'): @@ -540,6 +547,7 @@ allowed_actions = get_allowed_group_actions(dbh, auth_username, role_group, for_username=role_user) dbc.execute("SELECT sponsor_id, role_status FROM role WHERE " + rolespec, roleargs) arow = dbc.fetchone() + if action_name == 'decline' and arow and arow[1] != 'unapproved': print "You cannot decline memberships that are already approved." continue @@ -554,6 +562,8 @@ and have_prereq) or action_name != 'approve') \ and action_name in allowed_actions: + + # Change the approval status of the person in this group if action_name == 'approve': qry ="UPDATE role SET role_status = %s, approval = NOW() WHERE " + rolespec else: @@ -567,6 +577,45 @@ authi = get_user_info(dbh, auth_username) ginfo = get_group_info(dbh, role_group_id) joinmsg = ginfo.get('joinmsg', '') + + # If the user is approved for certain groups it autoapproves + # them for certain others. + if new_status == 'approved' and role_group in \ + auto_approve_groups: + for group in auto_approve_groups[role_group]: + # Check whether the user is already a member of the + # auto-approved group. + qry = "select role_status from role natural join" \ + " project_group where person_id = %s and" \ + " role_domain = %s and" \ + " name = %s" + dbc.execute(qry, (role_user_id, role_domain, group)) + checkrole = dbc.fetchone() + + if checkrole and checkrole[0] != 'approved': + # User is a member but needs to be approved + qry = "update role natural join project_group" \ + " set role_status = 'approved'" \ + " where person_id = %s and" \ + " role_domain = %s and" \ + " name = %s" + dbc.execute(qry, (role_user_id, role_domain, group)) + dbh.commit() + elif not checkrole: + # Add the user to the group + qry = "insert into role (person_id," \ + " project_group_id, role_domain," \ + " role_type, role_status)" \ + " select %s, project_group_id, %s," \ + " 'user', 'approved')" \ + " from project_group where name = %s" + dbc.execute(qry, (role_user_id, role_domain, group)) + dbh.commit() + else: + # User was already approved for this group. + # Nothing to be done. + pass + if action_name != 'approve': joinmsg = '' send_email(accounts_email, uinfo['email'], "Your Fedora %s membership has been %s" % (role_group, new_status),
Attachment:
signature.asc
Description: This is a digitally signed message part