fedora-accounts send-cla.cgi,1.15,1.16 website.py,1.3,1.4
Toshio Ernie Kuratomi (toshio)
fedora-extras-commits at redhat.com
Wed Apr 4 20:12:03 UTC 2007
Author: toshio
Update of /cvs/fedora/fedora-accounts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv2726
Modified Files:
send-cla.cgi website.py
Log Message:
Changes to enable auto add of groups. This revision autoadds fedorabugs when
cvsextras is approved and cla_done when any of fedora_cla, redhat_cla, or
dell_cla is approved.
Index: send-cla.cgi
===================================================================
RCS file: /cvs/fedora/fedora-accounts/send-cla.cgi,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- send-cla.cgi 15 Jun 2006 20:57:55 -0000 1.15
+++ send-cla.cgi 4 Apr 2007 20:12:00 -0000 1.16
@@ -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
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- website.py 30 Mar 2007 20:10:09 -0000 1.3
+++ website.py 4 Apr 2007 20:12:00 -0000 1.4
@@ -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),
More information about the fedora-extras-commits
mailing list