Changeset - aafd9a98ea58
[Not reviewed]
default
0 2 0
Marcin Kuzminski - 15 years ago 2010-07-01 18:17:52
marcin@python-works.com
added admin flag to users editing
2 files changed with 6 insertions and 0 deletions:
0 comments (0 inline, 0 general)
pylons_app/model/forms.py
Show inline comments
 
@@ -209,48 +209,49 @@ class LoginForm(formencode.Schema):
 
                                       'empty':_('Please enter a login'),
 
                                       'tooShort':_('Enter a value %(min)i characters long or more')}
 
                            )
 

	
 
    password = UnicodeString(
 
                            strip=True,
 
                            min=3,
 
                            not_empty=True,
 
                            messages={
 
                                      'empty':_('Please enter a password'),
 
                                      'tooShort':_('Enter a value %(min)i characters long or more')}
 
                                )
 

	
 

	
 
    #chained validators have access to all data
 
    chained_validators = [ValidAuth]
 
    
 
def UserForm(edit=False):
 
    class _UserForm(formencode.Schema):
 
        allow_extra_fields = True
 
        filter_extra_fields = True
 
        username = All(UnicodeString(strip=True, min=3, not_empty=True), ValidUsername)
 
        if edit:
 
            new_password = All(UnicodeString(strip=True, min=3, not_empty=False), ValidPassword)
 
            admin = StringBoolean(if_missing=False)
 
        else:
 
            password = All(UnicodeString(strip=True, min=3, not_empty=False), ValidPassword)
 
        active = StringBoolean(if_missing=False)
 
        name = UnicodeString(strip=True, min=3, not_empty=True)
 
        lastname = UnicodeString(strip=True, min=3, not_empty=True)
 
        email = Email(not_empty=True)
 
        
 
    return _UserForm
 

	
 
def RepoForm(edit=False):
 
    class _RepoForm(formencode.Schema):
 
        allow_extra_fields = True
 
        filter_extra_fields = False
 
        repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), ValidRepoName(edit))
 
        description = UnicodeString(strip=True, min=3, not_empty=True)
 
        private = StringBoolean(if_missing=False)
 
        
 
        if edit:
 
            user = All(Int(not_empty=True), ValidRepoUser)
 
        
 
        chained_validators = [ValidPerms]
 
    return _RepoForm
 

	
 
def RepoSettingsForm(edit=False):
pylons_app/templates/admin/users/user_edit.html
Show inline comments
 
@@ -28,32 +28,37 @@
 
        		<td>${h.text('new_password')}</td>
 
        		<td>${self.get_form_error('new_password')}</td>
 
        	</tr>
 
        	<tr>
 
        		<td>${_('Name')}</td>
 
        		<td>${h.text('name')}</td>
 
        		<td>${self.get_form_error('name')}</td>
 
        	</tr>
 
        	<tr>
 
        		<td>${_('Lastname')}</td>
 
        		<td>${h.text('lastname')}</td>
 
        		<td>${self.get_form_error('lastname')}</td>
 
        	</tr>
 
        	<tr>
 
        		<td>${_('Email')}</td>
 
        		<td>${h.text('email')}</td>
 
        		<td>${self.get_form_error('email')}</td>
 
        	</tr>        	        	
 
        	<tr>
 
        		<td>${_('Active')}</td>
 
        		<td>${h.checkbox('active',value=True)}</td>
 
        		<td>${self.get_form_error('active')}</td>
 
        	</tr>
 
        	<tr>
 
        		<td>${_('Admin')}</td>
 
        		<td>${h.checkbox('admin',value=True)}</td>
 
        		<td>${self.get_form_error('admin')}</td>
 
        	</tr>        	
 
        	<tr>
 
        		<td></td>
 
        		<td>${h.submit('save','save')}</td>
 
        	</tr>
 
        	        	        	
 
        </table>
 
        ${h.end_form()}
 
    </div>
 
</%def>  
 
\ No newline at end of file
0 comments (0 inline, 0 general)