示例#1
0
 def changeDeposit(self, changer_admin_name, admin_name, deposit_change,
                   comment, remote_addr):
     """
         change deposit of admin "admin_name"
         
         changer_admin_name(str): name of admin, changing the deposit
         admin_name(str): name of admin that deposit changes
         deposit_change(float): amount of change
         comment(str):
         remote_addr(str): remote ip address of deposit changer
     """
     self.__changeDepositCheckInput(changer_admin_name, admin_name,
                                    deposit_change, comment, remote_addr)
     changer_admin_obj = self.__getAdminLoader().getAdminByName(
         changer_admin_name)
     admin_obj = self.__getAdminLoader().getAdminByName(admin_name)
     query = ""
     query += admin_main.getDepositChangeLogActions().logDepositChangeQuery(
         changer_admin_obj.getAdminID(), admin_obj.getAdminID(),
         deposit_change, comment, remote_addr)
     query += self.__changeDepositQuery(admin_obj.getAdminID(),
                                        deposit_change)
     query += ias_main.getActionsManager().logEvent("CHANGE_DEPOSIT",
                                                    changer_admin_name,
                                                    deposit_change,
                                                    admin_name)
     db_main.getHandle().transactionQuery(query)
     admin_obj.changeDeposit(deposit_change)
示例#2
0
    def delUser(self, user_ids, comment, del_connections, del_audit_logs,
                admin_name, remote_address):
        """
            delete users with ids in user_ids
            comment: comment when deleting users
            del_connection tells if we should delete user(s) connection logs too
        """
        self.__delUserCheckInput(user_ids, comment, del_connections,
                                 del_audit_logs, admin_name, remote_address)
        admin_obj = admin_main.getLoader().getAdminByName(admin_name)
        map(lambda user_id: user_main.getUserPool().addToBlackList, user_ids)
        try:
            loaded_users = self.getLoadedUsersByUserID(user_ids)
            total_credit = self.__delUserCheckUsers(loaded_users)
            admin_deposit = total_credit * -1
            ibs_query = IBSQuery()
            ibs_query += user_main.getCreditChangeLogActions(
            ).logCreditChangeQuery("DEL_USER", admin_obj.getAdminID(),
                                   user_ids, 0, admin_deposit, remote_address,
                                   comment)
            ibs_query += admin_main.getActionManager().consumeDepositQuery(
                admin_obj.getAdminID(), admin_deposit)
            ibs_query += ias_main.getActionsManager().logEvent(
                "DELETE_USER", admin_name, 0, ",".join(user_ids))

            self.__delUserQuery(ibs_query, user_ids, del_connections,
                                del_audit_logs)
            ibs_query.runQuery()
            admin_obj.consumeDeposit(admin_deposit)
            map(user_main.getUserPool().userChanged, user_ids)
        finally:
            map(lambda user_id: user_main.getUserPool().removeFromBlackList,
                user_ids)

        self.__postDelUser(loaded_users)
示例#3
0
    def deleteEvents(self, request):
        request.needAuthType(request.ADMIN)
        creator_obj = request.getAuthNameObj()
        creator_obj.canDo("HANDLE IAS EVENTS")
        request.checkArgs("event_ids")

        event_ids = map(lambda event_id: to_int(event_id, "event_id"),
                        request.fixList("event_ids"))
        return ias_main.getActionsManager().deleteEvents(event_ids)
示例#4
0
    def getEvents(self, request):
        request.needAuthType(request.ADMIN)
        creator_obj = request.getAuthNameObj()
        creator_obj.canDo("HANDLE IAS EVENTS")

        request.checkArgs("from_event_id", "from", "to")
        return ias_main.getActionsManager().getEvents(
            to_int(request["from_event_id"], "from_event_id"),
            to_int(request["from"], "from"), to_int(request["to"], "to"))
示例#5
0
    def changeCredit(self, user_ids, credit, changer_admin_name,
                     remote_address, credit_change_comment, loaded_users):
        """
            change credit of user(s) with user_id in "user_ids"
            user_ids(iterable object, list or multi_str): user_ids that credit will be changed
            credit(float): amount of credit change, can be negative
            changer_admin_name(string): username of admin that initiate the change. He should have enough deposit
            remote_address(string): changer client ip address 
            credit_change_comment(string): comment that will be stored in credit change log
            loaded_users(LoadedUser instance): list of loaded users of "user_ids"
        """
        self.__changeCreditCheckInput(user_ids, credit, changer_admin_name,
                                      remote_address, credit_change_comment,
                                      loaded_users)
        admin_consumed_credit = credit * len(user_ids)
        ibs_query = IBSQuery()
        ibs_query += admin_main.getActionManager().consumeDeposit(
            changer_admin_name, admin_consumed_credit)
        try:
            changer_admin_obj = admin_main.getLoader().getAdminByName(
                changer_admin_name)
            ibs_query += self.__changeCreditQuery(user_ids, credit)
            ibs_query+=user_main.getCreditChangeLogActions().logCreditChangeQuery("CHANGE_CREDIT",changer_admin_obj.getAdminID(),user_ids,credit,\
                                        admin_consumed_credit,remote_address,credit_change_comment)

            ibs_query += ias_main.getActionsManager().logEvent(
                "CHANGE_CREDIT", changer_admin_name, credit,
                ",".join(user_ids))

            ibs_query.runQuery()
        except:
            admin_main.getActionManager().consumeDeposit(
                changer_admin_name, -1 * admin_consumed_credit,
                False)  #re-add deposit to admin
            raise
        self.broadcastChange(user_ids)
示例#6
0
 def __addNewAdminIASQuery(self, username, creator_id):
     creator_username = admin_main.getLoader().getAdminByID(
         creator_id).getUsername()
     return ias_main.getActionsManager().logEvent("ADD_ADMIN",
                                                  creator_username, 0,
                                                  username)
示例#7
0
 def __deleteAdminIASQuery(self, deleter_admin, admin_obj):
     return ias_main.getActionsManager().logEvent("DELETE_ADMIN",
                                                  deleter_admin,
                                                  admin_obj.deposit,
                                                  admin_obj.getUsername())
示例#8
0
 def __addNewUserIASQuery(self, ibs_query, creator_name, credit, user_ids):
     destination = ",".join(map(str, user_ids))
     ibs_query += ias_main.getActionsManager().logEvent(
         "ADD_USER", creator_name, 0, destination)
     ibs_query += ias_main.getActionsManager().logEvent(
         "CHANGE_CREDIT", creator_name, credit, destination)