Exemplo n.º 1
0
 def update_(self):
     'Update account'
     # Initialize
     personID = h.getPersonID()
     # If the user is trying to update SMS information,
     if 'smsAddressID' in request.POST:
         # Load
         action = request.POST.get('action')
         smsAddressID = request.POST['smsAddressID']
         smsAddress = Session.query(model.SMSAddress).filter((model.SMSAddress.id==smsAddressID) & (model.SMSAddress.owner_id==personID)).first()
         if not smsAddress:
             return dict(isOk=0, message='Could not find smsAddressID=%s corresponding to personID=%s' % (smsAddressID, personID))
         # If the user is trying to activate an SMS address,
         elif action == 'activate':
             smsAddress.is_active = True
         # If the user is trying to deactivate an SMS address,
         elif action == 'deactivate':
             smsAddress.is_active = False
         # If the user is trying to remove an SMS address,
         elif action == 'remove':
             Session.delete(smsAddress)
         # Otherwise,
         else:
             return dict(isOk=0, message='Command not recognized')
         # Commit and return
         Session.commit()
         return dict(isOk=1)
     # If the user is trying to update account information,
     else:
         # Send update confirmation email
         return changePerson(dict(request.POST), 'update', Session.query(model.Person).get(personID))
Exemplo n.º 2
0
 def update_(self):
     'Update account'
     # Initialize
     personID = h.getPersonID()
     # If the user is trying to update SMS information,
     if 'smsAddressID' in request.POST:
         # Load
         action = request.POST.get('action')
         smsAddressID = request.POST['smsAddressID']
         smsAddress = Session.query(model.SMSAddress).filter(
             (model.SMSAddress.id == smsAddressID)
             & (model.SMSAddress.owner_id == personID)).first()
         if not smsAddress:
             return dict(
                 isOk=0,
                 message=
                 'Could not find smsAddressID=%s corresponding to personID=%s'
                 % (smsAddressID, personID))
         # If the user is trying to activate an SMS address,
         elif action == 'activate':
             smsAddress.is_active = True
         # If the user is trying to deactivate an SMS address,
         elif action == 'deactivate':
             smsAddress.is_active = False
         # If the user is trying to remove an SMS address,
         elif action == 'remove':
             Session.delete(smsAddress)
         # Otherwise,
         else:
             return dict(isOk=0, message='Command not recognized')
         # Commit and return
         Session.commit()
         return dict(isOk=1)
     # If the user is trying to update account information,
     else:
         # Send update confirmation email
         return changePerson(dict(request.POST), 'update',
                             Session.query(model.Person).get(personID))