コード例 #1
0
ファイル: user_actions.py プロジェクト: moxwose/freeIBS
    def delUser(self,user_ids,comment,del_connections,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,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)
	    self.__delUserQuery(ibs_query,user_ids,del_connections)
	    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)
コード例 #2
0
ファイル: credit.py プロジェクト: zeroleo12345/freeIBS
    def applyConditions(self):
        """
	    Apply conditions on tables, should check conditions here
	"""
        credit_table = self.search_helper.getTable("credit_change")
        userid_table = self.search_helper.getTable("credit_change_userid")

        self.__addUserIDAndAdminCondition()

        credit_table.exactSearch(
            self.search_helper,
            "action",
            "action",
            lambda action: user_main.getCreditChangeLogActions().getActionID(action),
        )

        credit_table.ltgtSearch(self.search_helper, "per_user_credit", "per_user_credit_op", "per_user_credit")

        credit_table.ltgtSearch(self.search_helper, "admin_credit", "admin_credit_op", "admin_credit")

        self.search_helper.setCondValue("change_time_from_op", ">=")
        credit_table.dateSearch(
            self.search_helper, "change_time_from", "change_time_from_unit", "change_time_from_op", "change_time"
        )

        self.search_helper.setCondValue("change_time_to_op", "<")
        credit_table.dateSearch(
            self.search_helper, "change_time_to", "change_time_to_unit", "change_time_to_op", "change_time"
        )

        credit_table.exactSearch(self.search_helper, "remote_addr", "remote_addr", MultiStr)
コード例 #3
0
ファイル: user_actions.py プロジェクト: sankopay/IBSng
    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)
コード例 #4
0
ファイル: credit.py プロジェクト: zeroleo12345/freeIBS
    def __repairCreditChangeDic(self, credit_changes, user_ids, date_type):
        for change in credit_changes:
            change["change_time_formatted"] = AbsDate(change["change_time"], "gregorian").getDate(date_type)
            change["admin_name"] = admin_main.getLoader().getAdminByID(change["admin_id"]).getUsername()
            change["action_text"] = user_main.getCreditChangeLogActions().getIDActionText(change["action"])
            try:
                change["user_ids"] = user_ids[change["credit_change_id"]]
            except KeyError:
                change["user_ids"] = []

        return credit_changes
コード例 #5
0
ファイル: credit.py プロジェクト: sankopay/IBSng
    def __repairCreditChangeDic(self, credit_changes, user_ids, date_type):
        for change in credit_changes:
            change["change_time_formatted"] = AbsDate(
                change["change_time"], "gregorian").getDate(date_type)
            change["admin_name"] = admin_main.getLoader().getAdminByID(
                change["admin_id"]).getUsername()
            change["action_text"] = user_main.getCreditChangeLogActions(
            ).getIDActionText(change["action"])
            try:
                change["user_ids"] = user_ids[change["credit_change_id"]]
            except KeyError:
                change["user_ids"] = []

        return credit_changes
コード例 #6
0
ファイル: user_actions.py プロジェクト: moxwose/freeIBS
    def addNewUsers(self,_count,credit,owner_name,creator_name,group_name,remote_address,credit_change_comment):
	self.__addNewUsersCheckInput(_count,credit,owner_name,creator_name,group_name,remote_address,credit_change_comment)
	admin_consumed_credit=credit*_count
	ibs_query=IBSQuery()
	ibs_query+=admin_main.getActionManager().consumeDeposit(creator_name,admin_consumed_credit)
	try:
	    user_ids=self.addNewUsersQuery(_count,credit,owner_name,group_name,ibs_query)
	    creator_admin_obj=admin_main.getLoader().getAdminByName(creator_name)
    	    ibs_query+=user_main.getCreditChangeLogActions().logCreditChangeQuery("ADD_USER",creator_admin_obj.getAdminID(),user_ids,credit,\
					admin_consumed_credit,remote_address,credit_change_comment)
	    ibs_query.runQuery()
	    return user_ids
	except:
	    admin_main.getActionManager().consumeDeposit(creator_name,-1*admin_consumed_credit,False) #re-add deposit to admin
	    raise
コード例 #7
0
ファイル: user_actions.py プロジェクト: sankopay/IBSng
    def addNewUsers(self,
                    _count,
                    credit,
                    owner_name,
                    creator_name,
                    group_name,
                    remote_address,
                    credit_change_comment,
                    user_ids=None):
        """
            add _count of users to system
            _count(int): postive integer
            credit(float): initial credit of users
            owner_name(str): valid admin name, that is owner of created users
            creator_name(str): valid admin name, that created users
            group_name(str): valid group name these users belongs to
            remote_address(str): ip address that admin used to create these users
            credit_change_comment(str): 
            user_ids(None or list of int): list of user_ids to use. if set to None
                                           generate new ids
                    
        """
        self.__addNewUsersCheckInput(_count, credit, owner_name, creator_name,
                                     group_name, remote_address,
                                     credit_change_comment, user_ids)
        admin_consumed_credit = credit * _count
        ibs_query = IBSQuery()
        ibs_query += admin_main.getActionManager().consumeDeposit(
            creator_name, admin_consumed_credit)
        try:
            user_ids = self.addNewUsersQuery(_count, credit, owner_name,
                                             group_name, ibs_query, user_ids)
            creator_admin_obj = admin_main.getLoader().getAdminByName(
                creator_name)
            ibs_query+=user_main.getCreditChangeLogActions().logCreditChangeQuery("ADD_USER",creator_admin_obj.getAdminID(),user_ids,credit,\
                                        admin_consumed_credit,remote_address,credit_change_comment)
            self.__addNewUserIASQuery(ibs_query, creator_name, credit,
                                      user_ids)

            ibs_query.runQuery()
            return user_ids
        except:
            admin_main.getActionManager().consumeDeposit(
                creator_name, -1 * admin_consumed_credit,
                False)  #re-add deposit to admin
            raise
コード例 #8
0
ファイル: user_actions.py プロジェクト: moxwose/freeIBS
    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.runQuery()
	except:
	    admin_main.getActionManager().consumeDeposit(changer_admin_name,-1*admin_consumed_credit,False) #re-add deposit to admin
	    raise
	self.__broadcastChange(user_ids)
コード例 #9
0
ファイル: user_actions.py プロジェクト: sankopay/IBSng
    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)