~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/admin/user.py

  • Committer: Matt Giuca
  • Date: 2010-02-11 05:21:17 UTC
  • Revision ID: matt.giuca@gmail.com-20100211052117-rb4q9rnrp2km3571
User administration page: Do not let an admin user change their own admin checkbox (disable and don't let it change). This would be bad.

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
                validator = UserAdminSchema()
139
139
                data = validator.to_python(data, state=req)
140
140
 
141
 
                self.context.admin = data['admin']
 
141
                if self.context is req.user:
 
142
                    # Admin checkbox is disabled -- assume unchanged
 
143
                    data['admin'] = self.context.admin
 
144
                else:
 
145
                    self.context.admin = data['admin']
142
146
                self.context.fullname = data['fullname'] \
143
147
                                        if data['fullname'] else None
144
148
                self.context.studentid = data['studentid'] \
156
160
 
157
161
        ctx['req'] = req
158
162
        ctx['user'] = self.context
 
163
        # Disable the Admin checkbox if editing oneself
 
164
        ctx['disable_admin'] = self.context is req.user
159
165
        ctx['data'] = data
160
166
        ctx['errors'] = errors
161
167