Example #1
0
 def post(self):
     reason = self.get_argument("reason").strip()
     user_id = int(self.get_argument("user_id"))
     if not reason:
         raise tornado.web.HTTPError(422, reason="No explanation provided for this action".format(
             offset=offset,
         ))
         
     context = self._build_common_context()
     restrict_moderator(context)
     DATABASE.users_accept_recovery_password(user_id)
     DATABASE.interactions_record(user_id, context['identity']['user_id'], 'recovered', reason)
     self.redirect('/users/{user_id}'.format(
         user_id=user_id,
     ))
Example #2
0
 def post(self):
     reason = self.get_argument("reason").strip()
     user_id = int(self.get_argument("user_id"))
     if not reason:
         raise tornado.web.HTTPError(422, reason="No explanation provided for this action".format(
             offset=offset,
         ))
         
     context = self._build_common_context()
     restrict_moderator(context)
     DATABASE.users_accept_recovery_password(user_id)
     DATABASE.interactions_record(user_id, context['identity']['user_id'], 'recovered', reason)
     self.redirect('/users/{user_id}'.format(
         user_id=user_id,
     ))
Example #3
0
 def post(self):
     action = self.get_argument("action")
     reason = self.get_argument("reason").strip()
     user_id = int(self.get_argument("user_id"))
     if not reason:
         raise tornado.web.HTTPError(422, reason="No explanation provided for this action".format(
             offset=offset,
         ))
         
     context = self._build_common_context()
     
     subject_identity = DATABASE.users_get_identity(user_id)
     if subject_identity is None:
         raise tornado.web.HTTPError(404, reason="No user exists with id {id}".format(
             id=user_id,
         ))
         
     if action =='activated' and _can_set_active(user_id, subject_identity[1], context['identity']['user_id'], context['role']):
         status = USER_STATUS_ACTIVE
         CLEAR_BAN(user_id)
     elif action == 'promoted' and _can_set_moderator(user_id, subject_identity[1], context['identity']['user_id'], context['role']):
         status = USER_STATUS_MODERATOR
         CLEAR_BAN(user_id)
     elif action == 'banned' and _can_set_banned(user_id, subject_identity[1], context['identity']['user_id'], context['role']):
         status = USER_STATUS_BANNED
         ADD_BAN(user_id)
     else:
         raise tornado.web.HTTPError(422, reason="Unsupported action: {action}".format(
             action=action,
         ))
         
     DATABASE.users_set_status(user_id, status)
     DATABASE.interactions_record(user_id, context['identity']['user_id'], action, reason)
     self.redirect('/users/{user_id}'.format(
         user_id=user_id,
     ))
Example #4
0
 def post(self):
     action = self.get_argument("action")
     reason = self.get_argument("reason").strip()
     user_id = int(self.get_argument("user_id"))
     if not reason:
         raise tornado.web.HTTPError(422, reason="No explanation provided for this action".format(
             offset=offset,
         ))
         
     context = self._build_common_context()
     
     subject_identity = DATABASE.users_get_identity(user_id)
     if subject_identity is None:
         raise tornado.web.HTTPError(404, reason="No user exists with id {id}".format(
             id=user_id,
         ))
         
     if action =='activated' and _can_set_active(user_id, subject_identity[1], context['identity']['user_id'], context['role']):
         status = USER_STATUS_ACTIVE
         CLEAR_BAN(user_id)
     elif action == 'promoted' and _can_set_moderator(user_id, subject_identity[1], context['identity']['user_id'], context['role']):
         status = USER_STATUS_MODERATOR
         CLEAR_BAN(user_id)
     elif action == 'banned' and _can_set_banned(user_id, subject_identity[1], context['identity']['user_id'], context['role']):
         status = USER_STATUS_BANNED
         ADD_BAN(user_id)
     else:
         raise tornado.web.HTTPError(422, reason="Unsupported action: {action}".format(
             action=action,
         ))
         
     DATABASE.users_set_status(user_id, status)
     DATABASE.interactions_record(user_id, context['identity']['user_id'], action, reason)
     self.redirect('/users/{user_id}'.format(
         user_id=user_id,
     ))