示例#1
0
  def POST( self, get_string='' ):
    log.loggit( 'update.POST()' )

    # Must be a matching user or administrator to update
    wputil.must_match_username_or_admin( web.input()['username'] )

    # Catch the cancel button
    if  web.input().has_key('cancel'):
      if wputil.is_admin():
        raise web.seeother('../')
      else:
        raise web.seeother('../../')

    # Validate the form
    if wputil.is_admin():
      f = admin_account_form()
    else:
      f = account_form()
    if not f.validates():
      return { 'status' : 'error',
               'message' : 'Verify all information has been provided correctly.',
               'form' : f }

    # update the account in the database
    adb = accountdb.AccountDB()
    try:
      account = adb.update_account( f.d )
    except:
      return { 'status' : 'error',
               'message' : 'An error occurred updating the account.',
               'form' : f }

    raise web.seeother( '../review/%s' % (account['username']) )
示例#2
0
  def GET( self, get_string='' ):
    log.loggit( 'update.GET()' )

    # Grab the account id from the get string
    username = get_string.lstrip('/')
    if not username:
      raise web.seeother('../')

    # Must be a matching user or administrator to review accounts
    wputil.must_match_username_or_admin( username )

    # Verify account exists
    adb = accountdb.AccountDB()
    account = adb.review_account( username )
    if not account:
      return { 'status' : 'error',
               'message' : 'No such account exists: %s' % ( username ) }

    # Instantiate a form and populate it with the data
    if wputil.is_admin():
      f = admin_account_form()
    else:
      f = account_form()
    f.fill( wputil.clean_account( account ) )
    return { 'status' : 'success',
             'message' : 'Required fields include: id, username, password, password2 - Note that password and password2 must match.',
             'form' : f }
示例#3
0
    def GET(self, get_string=''):
        log.loggit('update.GET()')

        # Grab the account id from the get string
        username = get_string.lstrip('/')
        if not username:
            raise web.seeother('../')

        # Must be a matching user or administrator to review accounts
        wputil.must_match_username_or_admin(username)

        # Verify account exists
        adb = accountdb.AccountDB()
        account = adb.review_account(username)
        if not account:
            return {
                'status': 'error',
                'message': 'No such account exists: %s' % (username)
            }

        # Instantiate a form and populate it with the data
        if wputil.is_admin():
            f = admin_account_form()
        else:
            f = account_form()
        f.fill(wputil.clean_account(account))
        return {
            'status': 'success',
            'message':
            'Required fields include: id, username, password, password2 - Note that password and password2 must match.',
            'form': f
        }
示例#4
0
    def POST(self, get_string=''):
        log.loggit('update.POST()')

        # Must be a matching user or administrator to update
        wputil.must_match_username_or_admin(web.input()['username'])

        # Catch the cancel button
        if web.input().has_key('cancel'):
            if wputil.is_admin():
                raise web.seeother('../')
            else:
                raise web.seeother('../../')

        # Validate the form
        if wputil.is_admin():
            f = admin_account_form()
        else:
            f = account_form()
        if not f.validates():
            return {
                'status': 'error',
                'message':
                'Verify all information has been provided correctly.',
                'form': f
            }

        # update the account in the database
        adb = accountdb.AccountDB()
        try:
            account = adb.update_account(f.d)
        except:
            return {
                'status': 'error',
                'message': 'An error occurred updating the account.',
                'form': f
            }

        raise web.seeother('../review/%s' % (account['username']))