code: def email_action_view(self, id, action):
          
  
          # Retrieve UserEmail by id
          user_email = self.db_manager.get_user_email_by_id(id=id)
  
          # Users may only change their own UserEmails
          if not user_email or user_email.user_id != current_user.id:
              return self.unauthorized_view()
  
          # Delete UserEmail
          if action == 'delete':
              # Primary UserEmail can not be deleted
              if user_email.is_primary:
                  return self.unauthorized_view()
              # Delete UserEmail
              self.db_manager.delete_object(user_email)
              self.db_manager.commit()
  
          # Set UserEmail.is_primary
          elif action == 'make-primary':
              # Disable previously primary emails
              user_emails = self.db_manager.find_user_emails(current_user)
              for other_user_email in user_emails:
                  if other_user_email.is_primary:
                      other_user_email.is_primary=False
                      self.db_manager.save_object(other_user_email)
              # Enable current primary email
              user_email.is_primary=True
              self.db_manager.save_object(user_email)
              self.db_manager.commit()
  
          # Send confirm email
          elif action == 'confirm':
              self._send_confirm_email_email(user_email.user, user_email)
          else:
              return self.unauthorized_view()
  
          return redirect(url_for('user.manage_emails'))
docs: Perform action 'action' on UserEmail object 'id'