accounts2/fas/fas controllers.py,1.10,1.11 fasLDAP.py,1.9,1.10

Michael Patrick McGrath (mmcgrath) fedora-extras-commits at redhat.com
Mon Apr 30 13:37:46 UTC 2007


Author: mmcgrath

Update of /cvs/fedora/accounts2/fas/fas
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv7136/fas/fas

Modified Files:
	controllers.py fasLDAP.py 
Log Message:
Major UI changes.  Added help system.  Added group prereq to ldap schema


Index: controllers.py
===================================================================
RCS file: /cvs/fedora/accounts2/fas/fas/controllers.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- controllers.py	27 Apr 2007 21:08:49 -0000	1.10
+++ controllers.py	30 Apr 2007 13:37:44 -0000	1.11
@@ -22,6 +22,7 @@
         if p.cn:
             raise validators.Invalid("'%s' already axists" % value, value, state)
 
+
 class newPerson(widgets.WidgetsList):
 #    cn = widgets.TextField(label='Username', validator=validators.PlainText(not_empty=True, max=10))
     cn = widgets.TextField(label='Username', validator=validators.All(knownUser(not_empty=True, max=10), validators.String(max=32, min=3)))
@@ -33,13 +34,12 @@
 newPersonForm = widgets.TableForm(fields=newPerson(), submit_text='Sign Up')
 
 class findUser(widgets.WidgetsList):
-    userName = widgets.AutoCompleteField(search_controller='search', search_param='userName', result_name='people')
-
-    action = widgets.HiddenField(default='apply', validator=validators.String(not_empty=True))
+    userName = widgets.AutoCompleteField(label='Username', search_controller='search', search_param='userName', result_name='people')
+    action = widgets.HiddenField(label='action', default='apply', validator=validators.String(not_empty=True))
+    groupName = widgets.HiddenField(label='groupName', validator=validators.String(not_empty=True))
 
-    groupName = widgets.HiddenField(validator=validators.String(not_empty=True))
+searchUserForm = widgets.TableForm(fields=findUser(), submit_text='Invite')
 
-searchUserForm = widgets.TableForm(fields=findUser())
 
 class Root(controllers.RootController):
     @expose(template="fas.templates.error")
@@ -90,8 +90,16 @@
     @expose(template="fas.templates.editAccount")
     @identity.require(identity.not_anonymous())
     def editAccount(self,userName=None, action=None):
-        if not userName:
-            userName = turbogears.identity.current.user_name
+        if userName:
+            try:
+                Groups.byUserName(turbogears.identity.current.user_name)['accounts'].cn
+                if not userName:
+                    userName = turbogears.identity.current.user_name
+            except KeyError:
+                turbogears.flash('You cannot view %s' % userName )
+                userName = turbogears.identity.current.user_name
+        else:
+                userName = turbogears.identity.current.user_name
         user = Person.byUserName(userName)
         groups = Groups.byUserName(userName)
         groupsPending = Groups.byUserName(userName, unapprovedOnly=True)
@@ -106,7 +114,6 @@
     @exception_handler(errorMessage,rules="isinstance(tg_exceptions,ValueError)")
     @identity.require(identity.not_anonymous())
     def editGroup(self, groupName):
-
         try:
             groups = Groups.byGroupName(groupName, includeUnapproved=True)
         except KeyError, e:
@@ -153,7 +160,7 @@
 
         # Not logged in
         if not (userName and mail) and not turbogears.identity.current.user_name:
-            turbogears.flash('Please provide your username and password')
+#            turbogears.flash('Please provide your username and password')
             return dict()
 
         if turbogears.identity.current.user_name:
@@ -207,14 +214,24 @@
     @exception_handler(errorMessage,rules="isinstance(tg_exceptions,ValueError)")
     @identity.require(identity.not_anonymous())
     def editUserAttribute(self, attribute, value, userName=None):
-        userName = turbogears.identity.current.user_name
+        try:
+            Groups.byUserName(turbogears.identity.current.user_name)['accounts'].cn
+            if not userName:
+                userName = turbogears.identity.current.user_name
+        except KeyError:
+            turbogears.flash('You cannot view %s' % userName )
+            userName = turbogears.identity.current.user_name
+
         attribute = attribute.encode('utf8')
         value = value.encode('utf8')
         if attribute and value:
             p = Person.byUserName(userName)
-            p.__setattr__('%s' % attribute, '%s' % value)
+            p.__setattr__(attribute, value)
             turbogears.flash("'%s' Updated to %s" % (attribute, value))
-            turbogears.redirect('editAccount')
+            if userName == turbogears.identity.current.user_name:
+                turbogears.redirect('editAccount')
+            else:
+                turbogears.redirect('editAccount?userName=%s' % userName)
         return dict(userName=userName, attribute=attribute, value=value)
 
     @expose(template='fas.templates.apply')
@@ -225,13 +242,18 @@
         turbogears.identity.current.user_name=userName
         turbogears.flash('Sudoed to %s' % userName)
         turbogears.recirect('editAccount')
-    
-    @error_handler(editGroup)
-    @validate(form=newPersonForm)
+
+#    @error_handler(editGroup)
+#    @validate(form=newPersonForm)
     @expose(template='fas.templates.apply')
     @identity.require(identity.not_anonymous())
-    def modifyGroup(self, groupName, action, userName):
+    def modifyGroup(self, groupName, action, userName, **kw):
         ''' Modifies group based on action, groupName and userName '''
+        try:
+            userName = userName['text']
+        except TypeError:
+            pass
+
         sponsor = turbogears.identity.current.user_name
         try:
             group = Groups.groups(groupName)[groupName]
@@ -245,7 +267,7 @@
         except KeyError, e:
             turbogears.flash('User Error: %s does not exist - %s' % (userName, e))
             turbogears.redirect('editGroup?groupName=%s' % group.cn)
-        
+
         g = Groups.byGroupName(groupName, includeUnapproved=True)
 
         # Apply user to a group (as in application)
@@ -378,18 +400,45 @@
             turbomail.enqueue(message)
             p.__setattr__('userPassword', newpass['hash'])
             turbogears.flash('Your password has been emailed to you.  Please log in with it and change your password')
+            turbogears.redirect('/')
 
         except ldap.ALREADY_EXISTS:
             turbogears.flash('%s Already Exists, Please pick a different name' % cn)
             turbogears.redirect('signUp')
         return dict()
-        
+
     @expose(format="json")
     def search(self, userName=None, groupName=None):
         people = Person.users('%s*' % userName)
         return dict(people=
                 filter(lambda item: userName in item.lower(), people))
 
+    @expose(format="json")
+    def help(self, helpID='Unknown'):
+        messages = { 
+            'Unknown' : ''' Unknown:  If you know what help should be here, please email accounts at fedoraproject.org and tell them.''',
+            'postalAddress' : ''' Postal Address: Your local mailing address.  It could be a work address or a home address.''',
+            'cn' : ''' Account Name: A unique identifier for each user.  This is your 'username' for many parts of fedora.  This will also be your @fedoraproject.org email alias.''',
+            'givenName' : ''' Real Name: This is your full name, often Firstname Lastname.''',
+            'mail' : ''' Email Address: This is your primary email address.  Notifications, aliases, password resets all get sent to this address.  Other email addresses can be added (like bugzilla address)''',
+            'fedoraPersonBugzillaMail' : ''' Bugzilla Email:  For most this is the same address as as their primary email address.''',
+            'fedoraPersonIrcNick' : ''' IRC Nick: Many fedora developers can be found on freenode.net.  Make sure your nick is registered so no one else takes it.  After you have registered, let the rest of fedora know what your nick is.''',
+            'fedoraPersonKeyId' : ''' PGP Key: PGP key's are required to verify your identity to others and to encrypt messages.  It is required in order to sign the CLA and, as such, is required to be a contributor.  In order to create and upload your key please see our howto at: <a href='http://fedoraproject.org/wiki/DocsProject/UsingGpg/CreatingKeys'>http://fedoraproject.org/wiki/DocsProject/UsingGpg/CreatingKeys</a> ''',
+            'telephoneNumber' : ''' Telephone Number: Please include a country code if outside of the united states. ''',
+            'description' : ''' Description: Just a brief comment on yourself.  Could include your website or blog. ''',
+            'password' : ''' Password: Used to access fedora resources.  Resources that don't require your password may require ssh keys ''',
+            'accountStatus' : ''' Account Status: Some accounts may be disabled because of misconduct or password expiration.  If your account is not active and you are not sure why, please contact <a href='mailto:accounts at fedoraproject.org>accounts at fedoraproject.org</a> or join #fedora-admin on <a href='http://irc.freenode.net/'>irc.freenode.net</a> ''',
+            'cla' : ''' Contributor License Agreement: This agreement is required in order to be a Fedora contributor.  The CLA can be found at: <a href='http://fedoraproject.org/wiki/Legal/Licenses/CLA'>http://fedoraproject.org/wiki/Legal/Licenses/CLA</a> ''',
+            'inviteToGroup' : ''' This will add a user to the following group.  They will initially be unapproved, just as if they had applied themselves.  An email notification will be sent. '''
+            }
+        try:
+            messages[helpID]
+        except KeyError:
+            helpID='Unknown'
+        return dict(help=messages[helpID])
+                #filter(lambda item: userName in item.lower(), people))
+
+
 
     @expose(template='fas.templates.invite')
     @exception_handler(errorMessage,rules="isinstance(tg_exceptions,ValueError)")


Index: fasLDAP.py
===================================================================
RCS file: /cvs/fedora/accounts2/fas/fas/fasLDAP.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- fasLDAP.py	26 Apr 2007 21:20:53 -0000	1.9
+++ fasLDAP.py	30 Apr 2007 13:37:44 -0000	1.10
@@ -218,7 +218,7 @@
 
     def __getattr__(self, attr):
         if attr.startswith('_'):
-#            print 'GET %s=%s' % (attr, self.__getattr__(attr))
+            print 'GET %s=%s' % (attr, self.__getattr__(attr))
             if attr == '__filter':
                 return self.__filter
         if attr == 'userName':
@@ -236,10 +236,15 @@
             #return setattr(self.__class__, attr, value)
             self.__dict__[attr] = value
             return
-
         base = 'cn=%s,ou=People,dc=fedoraproject,dc=org' % self.__getattr__('cn')
-        modify(base, attr, value, self.__getattr__(attr))
-        return setattr(self.__class__, attr, value)
+
+        if self.__getattr__(attr):
+            modify(base, attr, value, self.__getattr__(attr))
+        else:
+            try:
+                modify(base, attr, value)
+            except:
+                modify(base, attr, value, self.__getattr__(attr))
 
     @classmethod
     def users(self, searchExpression='*', findAttr='cn'):




More information about the scm-commits mailing list