fedora-accounts website.py,1.2,1.3
Toshio Ernie Kuratomi (toshio)
fedora-extras-commits at redhat.com
Fri Mar 30 20:10:11 UTC 2007
Author: toshio
Update of /cvs/fedora/fedora-accounts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv12247
Modified Files:
website.py
Log Message:
* Convert tabs into four spaces.
Index: website.py
===================================================================
RCS file: /cvs/fedora/fedora-accounts/website.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- website.py 11 Jul 2006 09:13:08 -0000 1.2
+++ website.py 30 Mar 2007 20:10:09 -0000 1.3
@@ -168,11 +168,11 @@
def get_dbh(dbtype='auth', dbctx=None):
dbname = dbname_map.get(dbtype, dbtype)
if dbctx is None:
- hn = socket.gethostname()
- if hn.find('devel.redhat.com') >= 0:
- dbctx = 'devel'
- else:
- dbctx = dbctx_map.get(dbname, 'live')
+ hn = socket.gethostname()
+ if hn.find('devel.redhat.com') >= 0:
+ dbctx = 'devel'
+ else:
+ dbctx = dbctx_map.get(dbname, 'live')
dbcnx = dbcnx_map[dbctx]
dbhost = dbcnx['host']
dbuser = dbcnx['user']
@@ -229,7 +229,7 @@
if not x:
auth_username = auth_password = None
else:
- auth_username = x
+ auth_username = x
if not (auth_username or not auth_password):
if c.has_key('auth_username'):
del c['auth_username']
@@ -324,10 +324,11 @@
if form.has_key('auth_password'):
print 'Username or password not valid. <a href="%s/reset-password.cgi?username=%s">Reset password</a><br>' % (accounts_url, auth_username)
print """<form method=post action="%s">Username: <input type=text name=auth_username value="%s"><br>Password: <input type=password name=auth_password><br><input type=submit value=Login>""" % (url, auth_username)
- for I in form.keys():
- if I in ('auth_username', 'auth_password'): continue
- print '<input type=hidden name="%s" value="%s">' % (I, form[I].value)
- print "</form>"
+ for I in form.keys():
+ if I in ('auth_username', 'auth_password'):
+ continue
+ print '<input type=hidden name="%s" value="%s">' % (I, form[I].value)
+ print "</form>"
do_error(title)
return auth_username, auth_password
@@ -358,11 +359,11 @@
if arow: # Group owner
default_retval = 'administrator'
if require_role_type:
- if isinstance(require_role_type, tuple) or isinstance(require_role_type, list):
- qry += ' AND role.role_type IN %s'
- else:
+ if isinstance(require_role_type, tuple) or isinstance(require_role_type, list):
+ qry += ' AND role.role_type IN %s'
+ else:
require_role_type = role_type_names[role_type_names.index(require_role_type):]
- qry += ' AND role.role_type IN %s'
+ qry += ' AND role.role_type IN %s'
qargs.append(require_role_type)
if require_role_domain:
qry += " AND (role.role_domain + '%%') LIKE %s"
@@ -384,18 +385,18 @@
ginfo = get_group_info(dbh, groupname)
my_group_info.update(ginfo)
if my_group_info['name'] == 'cla_done':
- return []
+ return []
x = have_group(dbh, auth_username, groupname, group_info=my_group_info)
if x:
- allowed_actions.append(x)
- allowed_actions.append('member')
+ allowed_actions.append(x)
+ allowed_actions.append('member')
if my_group_info.get('user_can_remove', 1):
allowed_actions.extend(['remove_self'])
if x in ('sponsor', 'administrator') and my_group_info.get('needs_sponsor'):
allowed_actions.extend(['sponsor'])
if x in ('administrator', 'sponsor'):
allowed_actions.extend(['decline', 'remove'])
- if not my_group_info.get('needs_sponsor'):
+ if not my_group_info.get('needs_sponsor'):
allowed_actions.extend(['approve'])
if x == 'administrator':
allowed_actions.extend(['upgrade', 'downgrade'])
@@ -466,8 +467,8 @@
cc=group_info['email'])
else:
print "'Add' action denied."
- if not group_info:
- print " The %s group doesn't seem to exist." % (role_group,)
+ if not group_info:
+ print " The %s group doesn't seem to exist." % (role_group,)
elif group_info['prerequisite_id']:
print " You may need to become a member of the %s group first." % (get_group_info(dbh, group_info['prerequisite_id'])['name'])
@@ -485,7 +486,8 @@
role_user_id = get_user_id(dbh, role_user)
assert role_user_id, role_user
- if role_domain == 'None': role_domain = None
+ if role_domain == 'None':
+ role_domain = None
allowed_actions = get_allowed_group_actions(dbh, auth_username, role_group, for_username=role_user)
if role_user_id == auth_user_id:
@@ -494,12 +496,12 @@
permitted = 'remove' in allowed_actions
if permitted:
- if role_domain is None:
- rdc = "IS NULL"
- qargs = (role_user_id, role_group_id)
- else:
- rdc = " = %s"
- qargs = (role_user_id, role_group_id, role_domain)
+ if role_domain is None:
+ rdc = "IS NULL"
+ qargs = (role_user_id, role_group_id)
+ else:
+ rdc = " = %s"
+ qargs = (role_user_id, role_group_id, role_domain)
dbc.execute("DELETE FROM role WHERE person_id = %s AND project_group_id = %s AND role_domain " + rdc,
qargs)
else:
@@ -625,8 +627,8 @@
continue
new_type = role_type_names[new_type_num]
if arow and the_action in allowed_actions:
- qry = "UPDATE role SET role_type = %s WHERE person_id = %s AND project_group_id = %s AND role_domain = %s"
- qargs = (new_type, role_user_id, role_group_id, role_domain)
+ qry = "UPDATE role SET role_type = %s WHERE person_id = %s AND project_group_id = %s AND role_domain = %s"
+ qargs = (new_type, role_user_id, role_group_id, role_domain)
dbc.execute(qry, qargs)
uinfo = get_user_info(dbh, role_user_id)
authi = get_user_info(dbh, auth_user_id)
@@ -665,15 +667,15 @@
(role_user_id, role_group_id, role_domain))
arow = dbc.fetchone()
if arow and not arow[0] and 'sponsor' in allowed_actions:
- if arow[2]:
- qstat = "role_status = %s, "
- qsa = ('approved',)
- else:
- qstat = ""
- qsa = ()
- assert 0
- qry = "UPDATE role SET " + qstat + "sponsor_id = %s, approval = NOW() WHERE person_id = %s AND project_group_id = %s AND role_domain = %s AND sponsor_id IS NULL"
- qargs = qsa + (auth_user_id, role_user_id, role_group_id, role_domain)
+ if arow[2]:
+ qstat = "role_status = %s, "
+ qsa = ('approved',)
+ else:
+ qstat = ""
+ qsa = ()
+ assert 0
+ qry = "UPDATE role SET " + qstat + "sponsor_id = %s, approval = NOW() WHERE person_id = %s AND project_group_id = %s AND role_domain = %s AND sponsor_id IS NULL"
+ qargs = qsa + (auth_user_id, role_user_id, role_group_id, role_domain)
dbc.execute(qry, qargs)
uinfo = get_user_info(dbh, role_user_id)
authi = get_user_info(dbh, auth_user_id)
@@ -742,17 +744,17 @@
rsa_value = None
rsu_value = None
if form.has_key('_role_show_all'):
- rsa_value = form['_role_show_all'].value
+ rsa_value = form['_role_show_all'].value
if form.has_key('_role_show_unapproved'):
- rsu_value = form['_role_show_unapproved'].value
+ rsu_value = form['_role_show_unapproved'].value
if rsa_value and rsa_value[:4].lower() == 'show':
role_show = 'all'
elif rsu_value and rsu_value[:4].lower() == 'show':
role_show = 'unapproved'
elif rsa_value:
- role_show = 'all'
+ role_show = 'all'
elif rsu_value:
- role_show = 'unapproved'
+ role_show = 'unapproved'
if role_show == 'unapproved':
qspecs.append("role_status = 'unapproved'")
assert qtables
@@ -806,10 +808,10 @@
print ' <input type=submit name=_role_show_%s value="Show %s">' % (I, I)
print "</td></tr><tr><th></th><th>Group Name</th><th>Username</th><th>Role Domain</th><th>Role Type</th><th>Role Status</th><th>Sponsor</th></tr>"
- if groupname:
- allowed_actions = get_allowed_group_actions(dbh, auth_username, groupname)
- else:
- allowed_actions = get_allowed_group_actions(dbh, auth_username, 'accounts') # XXX fixme badhack yuk
+ if groupname:
+ allowed_actions = get_allowed_group_actions(dbh, auth_username, groupname)
+ else:
+ allowed_actions = get_allowed_group_actions(dbh, auth_username, 'accounts') # XXX fixme badhack yuk
got_needs_sponsor = 0
got_needs_review = 0
while 1:
@@ -818,9 +820,9 @@
print '<tr><td><input type=checkbox name=existing_roles value="%s!%s!%s"></td>' % (arow['name'],
arow['username'],
arow['role_domain'])
- arow['print_role_status'] = arow['role_status']
- if arow['print_role_status'] not in ('unapproved', 'approved', 'declined'):
- arow['print_role_status'] = 'In progress'
+ arow['print_role_status'] = arow['role_status']
+ if arow['print_role_status'] not in ('unapproved', 'approved', 'declined'):
+ arow['print_role_status'] = 'In progress'
for I in ('name', 'username', 'role_domain', 'role_type', 'print_role_status'):
if I == 'username':
print """<td><a href="userbox.cgi?_editme=Edit&username=%s">%s</a></td>""" % (arow[I], arow[I])
@@ -847,8 +849,8 @@
if 'sponsor' in allowed_actions and got_needs_sponsor:
print '<input type=submit name=_role_sponsor value="Sponsor Selected">'
-# else:
-# print " got_needs_sponsor %s, actions %s " % (got_needs_sponsor, allowed_actions)
+# else:
+# print " got_needs_sponsor %s, actions %s " % (got_needs_sponsor, allowed_actions)
if 'approve' in allowed_actions and got_needs_review:
print '<input type=submit name=_role_approve value="Approve Selected">'
if 'decline' in allowed_actions and got_needs_review:
More information about the fedora-extras-commits
mailing list