fedora-accounts receive-cla.py,1.22,1.23 website.py,1.7,1.8
Toshio Ernie Kuratomi (toshio)
fedora-extras-commits at redhat.com
Thu Apr 5 01:18:45 UTC 2007
Author: toshio
Update of /cvs/fedora/fedora-accounts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1858
Modified Files:
receive-cla.py website.py
Log Message:
Move the auto-add group functionality into its own function in website.py.
There are three places that use it (approving an account and sponsoring an
account in website.py and approving cla_fedora in receive-cla.py.) and all
are now using the function to do the work.
Also make sponsoring an account into cvsextras autoadd fedorabugs.
Index: receive-cla.py
===================================================================
RCS file: /cvs/fedora/fedora-accounts/receive-cla.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- receive-cla.py 4 Apr 2007 23:14:52 -0000 1.22
+++ receive-cla.py 5 Apr 2007 01:18:43 -0000 1.23
@@ -104,43 +104,10 @@
qry = "UPDATE role SET role_status = 'approved' WHERE person_id = %s AND project_group_id = %s"
qargs = (role_row['person_id'], role_row['project_group_id'])
dbc.execute(qry, qargs)
+ # Auto approve any dependent groups (cla_done)
+ website._process_auto_approvals(dbc, 'cla_fedora', role_row['person_id'],
+ role_row['role_domain'])
dbh.commit()
- ### HACK: This is done in website.py:handle_group_mods() but that piece of
- # code also has UI bits so we can't use it here. Cut and paste. Bleargh.
- for group in website.auto_approve_groups['cla_fedora']:
- # Check whether the user is already a member of the
- # auto-approved group.
- qry = "select role_status from role as r," \
- " project_group as pg where" \
- " person_id = %s and" \
- " role_domain = %s and" \
- " pg.name = %s and" \
- " pg.id = project_group_id"
- dbc.execute(qry, (role_row['person_id'], role_row['role_domain'], group))
- checkrole = dbc.fetchone()
- if checkrole and checkrole[0] != 'approved':
- # User is a member but needs to be approved
- qry = "update role set role_status = 'approved'" \
- " where person_id = %s and" \
- " role_domain = %s and" \
- " project_group_id in (select pg.id from" \
- " project_group as pg where pg.name = %s)"
- dbc.execute(qry, (role_row['person_id'], role_row['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, id, %s," \
- " 'user', 'approved'" \
- " from project_group where name = %s"
- dbc.execute(qry, (role_row['person_id'], role_row['role_domain'], group))
- dbh.commit()
- else:
- # User was already approved for this group.
- # Nothing to be done.
- pass
return msg, person_row, interesting_part
Index: website.py
===================================================================
RCS file: /cvs/fedora/fedora-accounts/website.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- website.py 4 Apr 2007 23:14:52 -0000 1.7
+++ website.py 5 Apr 2007 01:18:43 -0000 1.8
@@ -46,6 +46,47 @@
role_type_names = ['user', 'sponsor', 'administrator']
+def _process_auto_approvals(dbc, newGroup, userid, domain):
+ '''Approval to be in certain groups automatically grants other groups.
+
+ This function adds the user to other groups if the one they were just
+ approved for is set up this way.
+ '''
+ if newGroup not in auto_approve_groups:
+ return
+ for group in auto_approve_groups[newGroup]:
+ # Check whether the user is already a member of the
+ # auto-approved group.
+ qry = "select role_status from role as r," \
+ " project_group as pg where" \
+ " person_id = %s and" \
+ " role_domain = %s and" \
+ " pg.name = %s and" \
+ " pg.id = project_group_id"
+ dbc.execute(qry, (userid, domain, group))
+ checkrole = dbc.fetchone()
+ if checkrole and checkrole[0] != 'approved':
+ # User is a member but needs to be approved
+ qry = "update role set role_status = 'approved'" \
+ " where person_id = %s and" \
+ " role_domain = %s and" \
+ " project_group_id in (select pg.id from" \
+ " project_group as pg where pg.name = %s)"
+ dbc.execute(qry, (userid, domain, group))
+ 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, id, %s," \
+ " 'user', 'approved'" \
+ " from project_group where name = %s"
+ dbc.execute(qry, (userid, domain, group))
+ else:
+ # User was already approved for this group.
+ # Nothing to be done.
+ pass
+
def print_header(title, auth_username=None, cache=0):
print "Content-type: text/html"
if not cache and 0:
@@ -582,40 +623,8 @@
# 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 as r," \
- " project_group as pg where" \
- " person_id = %s and" \
- " role_domain = %s and" \
- " pg.name = %s and" \
- " pg.id = project_group_id"
- 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 set role_status = 'approved'" \
- " where person_id = %s and" \
- " role_domain = %s and" \
- " project_group_id in (select pg.id from" \
- " project_group as pg where pg.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, 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
+ _process_auto_approvals(dbc, role_group, role_user_id,
+ role_domain)
if action_name != 'approve':
joinmsg = ''
send_email(accounts_email, uinfo['email'], "Your Fedora %s membership has been %s" % (role_group, new_status),
@@ -719,6 +728,8 @@
if arow[2]:
qstat = "role_status = %s, "
qsa = ('approved',)
+ _process_auto_approvals(dbc, role_group, role_user_id,
+ role_domain)
else:
qstat = ""
qsa = ()
More information about the fedora-extras-commits
mailing list