Ejemplo n.º 1
0
 def canDeclineInvite(self, profile, inviteID):
     invite = profile.getInvite(inviteID)
     if not invite:
         return error(_CCR.INVITE_DOES_NOT_EXIST)
     if not invite.isActive():
         return error(_CCR.INVITE_IS_NOT_ACTIVE)
     return self._isAccountRequestValid(_CRT.DECLINE_INVITE)
Ejemplo n.º 2
0
 def canCreateClub(self, profile):
     stateID = profile.getState().getStateID()
     if stateID == _CCB.HAS_CLUB:
         return error(_CCR.ACCOUNT_ALREADY_IN_TEAM)
     if stateID == _CCB.SENT_APP:
         return error(_CCR.APPLICATION_FOR_USER_EXCEEDED)
     return self._isAccountRequestValid(_CRT.CREATE_CLUB)
Ejemplo n.º 3
0
 def canCreateUnit(self, profile, club=None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     if not club.canParticipateBattles():
         return error(_CCR.NOT_ENOUGH_MEMBERS)
     return self._isClubRequestValid(_CRT.JOIN_UNIT, club, 'canCreateUnit')
Ejemplo n.º 4
0
 def canDeclineInvite(self, profile, inviteID):
     invite = profile.getInvite(inviteID)
     if not invite:
         return error(_CCR.INVITE_DOES_NOT_EXIST)
     if not invite.isActive():
         return error(_CCR.INVITE_IS_NOT_ACTIVE)
     return self._isAccountRequestValid(_CRT.DECLINE_INVITE)
Ejemplo n.º 5
0
 def canCreateUnit(self, profile, club = None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     if not club.canParticipateBattles():
         return error(_CCR.NOT_ENOUGH_MEMBERS)
     return self._isClubRequestValid(_CRT.JOIN_UNIT, club, 'canCreateUnit')
Ejemplo n.º 6
0
 def canCreateClub(self, profile):
     stateID = profile.getState().getStateID()
     if stateID == _CCB.HAS_CLUB:
         return error(_CCR.ACCOUNT_ALREADY_IN_TEAM)
     if stateID == _CCB.SENT_APP:
         return error(_CCR.APPLICATION_FOR_USER_EXCEEDED)
     return self._isAccountRequestValid(_CRT.CREATE_CLUB)
Ejemplo n.º 7
0
 def canLeaveClub(self, profile, club=None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     if club is not None:
         if not club.hasMember(getAccountDatabaseID()):
             return error(_CCR.NOT_A_CLUB_MEMBER)
     return self._isClubRequestValid(_CRT.LEAVE_CLUB, club, 'canLeaveClub')
Ejemplo n.º 8
0
 def canLeaveClub(self, profile, club = None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     if club is not None:
         if not club.hasMember(getAccountDatabaseID()):
             return error(_CCR.NOT_A_CLUB_MEMBER)
     return self._isClubRequestValid(_CRT.LEAVE_CLUB, club, 'canLeaveClub')
Ejemplo n.º 9
0
 def canAcceptInvite(self, profile, inviteID):
     if profile.getState().getStateID() == _CCB.HAS_CLUB:
         return error(_CCR.ACCOUNT_ALREADY_IN_TEAM)
     invite = profile.getInvite(inviteID)
     if not invite:
         return error(_CCR.INVITE_DOES_NOT_EXIST)
     if not invite.isActive():
         return error(_CCR.INVITE_IS_NOT_ACTIVE)
     return self._isAccountRequestValid(_CRT.ACCEPT_INVITE)
Ejemplo n.º 10
0
 def canAcceptInvite(self, profile, inviteID):
     if profile.getState().getStateID() == _CCB.HAS_CLUB:
         return error(_CCR.ACCOUNT_ALREADY_IN_TEAM)
     invite = profile.getInvite(inviteID)
     if not invite:
         return error(_CCR.INVITE_DOES_NOT_EXIST)
     if not invite.isActive():
         return error(_CCR.INVITE_IS_NOT_ACTIVE)
     return self._isAccountRequestValid(_CRT.ACCEPT_INVITE)
Ejemplo n.º 11
0
 def _isClubRequestValid(self, requestTypeID, club, permName):
     if club is not None:
         perms = club.getPermissions()
         if not getattr(perms, permName)():
             return error(_CCR.DEFAULT)
         isValid, reason = club.getRestrictions().isRequestValid(requestTypeID)
         if not isValid:
             return error(reason)
     else:
         LOG_WARNING('There is no club to check restrictions, skip', requestTypeID, club, permName)
     return self._isAccountRequestValid(requestTypeID)
Ejemplo n.º 12
0
 def canSendInvite(self, profile, club = None, accountsToInvite = None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     if accountsToInvite is not None:
         if len(accountsToInvite) > CLUB_LIMITS.MAX_INVITES_PER_CALL:
             return error(_CCR.TOO_MANY_INVITES_PER_CALL)
         if club is not None:
             available = MAX_CLUB_ACTIVE_INVITES - len(club.getInvites(onlyActive=True))
             if available < len(accountsToInvite):
                 return error(_CCR.TOO_MANY_ACTIVE_INVITES)
     return self._isClubRequestValid(_CRT.SEND_INVITE, club, 'canSendInvite')
Ejemplo n.º 13
0
    def canChangeWebSettings(self, profile, club = None):
        url = GUI_SETTINGS.lookup('clubSettings')
        if not url:
            return error(_CCR.DEFAULT)
        if club is not None:
            for rID in {_CRT.CHANGE_CLUB_NAME, _CRT.CHANGE_CLUB_EMBLEM}:
                result = self._isClubRequestValid(rID, club, 'canChangeWebSettings')
                if result.success:
                    return result

            return error(_CCR.NOT_ENOUGH_RATED_BATTLES)
        return success()
Ejemplo n.º 14
0
 def canChangeWebSettings(self, profile, club = None):
     url = GUI_SETTINGS.lookup('clubSettings')
     if not url:
         return error(_CCR.DEFAULT)
     else:
         if club is not None:
             permissions = club.getPermissions()
             if not permissions.canChangeWebSettings():
                 return error(_CCR.DEFAULT)
             if club.getTotalDossier().getTotalStats().getBattlesCount() < CLUB_LIMITS.MIN_BATTLES_COUNT_TO_CHANGE_NAME:
                 return error(_CCR.NOT_ENOUGH_RATED_BATTLES)
         return success()
Ejemplo n.º 15
0
    def canChangeWebSettings(self, profile, club=None):
        url = GUI_SETTINGS.lookup('clubSettings')
        if not url:
            return error(_CCR.DEFAULT)
        if club is not None:
            for rID in {_CRT.CHANGE_CLUB_NAME, _CRT.CHANGE_CLUB_EMBLEM}:
                result = self._isClubRequestValid(rID, club,
                                                  'canChangeWebSettings')
                if result.success:
                    return result

            return error(_CCR.NOT_ENOUGH_RATED_BATTLES)
        return success()
Ejemplo n.º 16
0
 def _isClubRequestValid(self, requestTypeID, club, permName):
     if club is not None:
         perms = club.getPermissions()
         if not getattr(perms, permName)():
             return error(_CCR.DEFAULT)
         isValid, reason = club.getRestrictions().isRequestValid(
             requestTypeID)
         if not isValid:
             return error(reason)
     else:
         LOG_WARNING('There is no club to check restrictions, skip',
                     requestTypeID, club, permName)
     return self._isAccountRequestValid(requestTypeID)
Ejemplo n.º 17
0
    def canSendApplication(self, profile, club = None):
        stateID = profile.getState().getStateID()
        if stateID == _CCB.HAS_CLUB:
            return error(_CCR.ACCOUNT_ALREADY_IN_TEAM)
        if stateID == _CCB.SENT_APP:
            return error(_CCR.APPLICATION_FOR_USER_EXCEEDED)
        if club:
            if club.getState().isClosed():
                return error(_CCR.CLUB_IS_CLOSED)
            for app in profile.getApplications().itervalues():
                if app.getClubDbID() == club.getClubDbID() and app.isDeclined() and app.getTimestamp() + THE_SAME_CLUB_SEND_APP_COOLDOWN > getCurrentTimestamp():
                    return error(_CCR.TEMPORARILY_RESTRICTED)

        return self._isClubRequestValid(_CRT.SEND_APPLICATION, club, 'canSendApplication')
Ejemplo n.º 18
0
 def canSendInvite(self, profile, club=None, accountsToInvite=None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     if accountsToInvite is not None:
         if len(accountsToInvite) > CLUB_LIMITS.MAX_INVITES_PER_CALL:
             return error(_CCR.TOO_MANY_INVITES_PER_CALL)
         if club is not None:
             available = MAX_CLUB_ACTIVE_INVITES - len(
                 club.getInvites(onlyActive=True))
             if available < len(accountsToInvite):
                 return error(_CCR.TOO_MANY_ACTIVE_INVITES)
     return self._isClubRequestValid(_CRT.SEND_INVITE, club,
                                     'canSendInvite')
Ejemplo n.º 19
0
    def isRequestValid(self, requestTypeID):
        if requestTypeID in self.__restrictions:
            for restriction in self.__restrictions[requestTypeID]:
                if not restriction.isExpired():
                    return error(restriction.getReasonString())

        return success()
Ejemplo n.º 20
0
    def isRequestValid(self, requestTypeID):
        if requestTypeID in self.__restrictions:
            for restriction in self.__restrictions[requestTypeID]:
                if not restriction.isExpired():
                    return error(restriction.getReasonString())

        return success()
Ejemplo n.º 21
0
 def canRevokeApplication(self, profile, club=None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.SENT_APP or club is not None and profile.getState(
     ).getClubDbID() != club.getClubDbID():
         return error(_CCR.NOT_IN_APPLICANTS)
     return self._isClubRequestValid(_CRT.REVOKE_APPLICATION, club,
                                     'canRevokeApplication')
Ejemplo n.º 22
0
 def canKickMember(self, profile, club=None, memberDbID=None):
     if club is not None:
         if memberDbID is not None:
             if not club.hasMember(memberDbID):
                 return error(_CCR.NOT_A_CLUB_MEMBER)
     return self._isClubRequestValid(_CRT.KICK_MEMBER, club,
                                     'canKickMember')
Ejemplo n.º 23
0
    def canSendApplication(self, profile, club=None):
        stateID = profile.getState().getStateID()
        if stateID == _CCB.HAS_CLUB:
            return error(_CCR.ACCOUNT_ALREADY_IN_TEAM)
        if stateID == _CCB.SENT_APP:
            return error(_CCR.APPLICATION_FOR_USER_EXCEEDED)
        if club:
            if club.getState().isClosed():
                return error(_CCR.CLUB_IS_CLOSED)
            for app in profile.getApplications().itervalues():
                if app.getClubDbID() == club.getClubDbID() and app.isDeclined(
                ) and app.getTimestamp(
                ) + THE_SAME_CLUB_SEND_APP_COOLDOWN > getCurrentTimestamp():
                    return error(_CCR.TEMPORARILY_RESTRICTED)

        return self._isClubRequestValid(_CRT.SEND_APPLICATION, club,
                                        'canSendApplication')
Ejemplo n.º 24
0
 def canSeeContenders(self, profile, club = None):
     if club and not club.getLadderInfo().isInLadder():
         return error(_CCR.CLUB_IS_NOT_IN_LADDER)
     return self._isClubRequestValid(_CRT.GET_CLUBS_CONTENDERS, club, 'canSeeContenders')
Ejemplo n.º 25
0
 def canRevokeInvite(self, profile, club = None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     return self._isClubRequestValid(_CRT.REVOKE_INVITE, club, 'canRevokeInvite')
Ejemplo n.º 26
0
 def canSeeOtherPlayerInfo(self, profile, club=None, userDbID=None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 27
0
 def canKickMember(self, profile, club=None, memberDbID=None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 28
0
 def canDeclineInvite(self, profile, inviteID):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 29
0
 def isRequestValid(self, requestTypeID):
     if requestTypeID in self.__restrictions:
         return error(first(self.__restrictions[requestTypeID]).getReasonString())
     return success()
Ejemplo n.º 30
0
 def canKickMember(self, profile, club = None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 31
0
 def canChangeWebSettings(self, profile, club = None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 32
0
 def canSeeApplicants(self, profile, club=None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 33
0
 def canJoinUnit(self, profile, club = None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     return self._isClubRequestValid(_CRT.JOIN_UNIT, club, 'canJoinUnit')
Ejemplo n.º 34
0
 def canJoinUnit(self, profile, club=None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     return self._isClubRequestValid(_CRT.JOIN_UNIT, club, 'canJoinUnit')
Ejemplo n.º 35
0
 def canDeclineApplication(self, profile, club=None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     return self._isClubRequestValid(_CRT.DECLINE_APPLICATION, club,
                                     'canDeclineApplication')
Ejemplo n.º 36
0
 def canRevokeInvite(self, profile, club=None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     return self._isClubRequestValid(_CRT.REVOKE_INVITE, club,
                                     'canRevokeInvite')
Ejemplo n.º 37
0
 def canCloseClub(self, profile, club=None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     return self._isClubRequestValid(_CRT.CLOSE_CLUB, club, 'canCloseClub')
Ejemplo n.º 38
0
 def canSeeContenders(self, profile, club=None):
     if club and not club.getLadderInfo().isInLadder():
         return error(_CCR.CLUB_IS_NOT_IN_LADDER)
     return self._isClubRequestValid(_CRT.GET_CLUBS_CONTENDERS, club,
                                     'canSeeContenders')
Ejemplo n.º 39
0
 def canCreateUnit(self, profile, club=None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 40
0
 def canDeclineApplication(self, profile, club=None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 41
0
 def canChangeClubRequirements(self, profile, club = None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 42
0
 def canRevokeInvite(self, profile, club=None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 43
0
 def canCreateClub(self, profile):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 44
0
 def canCloseClub(self, profile, club=None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 45
0
 def canSendApplication(self, profile, club = None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 46
0
 def canSeeContenders(self, profile, club = None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 47
0
 def canGetClubSeasons(self, profile, club=None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 48
0
 def canCloseClub(self, profile, club = None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 49
0
 def canSeeContenders(self, profile, club=None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 50
0
 def canRevokeInvite(self, profile, club = None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 51
0
 def canRevokeApplication(self, profile, club = None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.SENT_APP or profile.getState().getClubDbID() != club.getClubDbID():
         return error(_CCR.NOT_IN_APPLICANTS)
     return self._isClubRequestValid(_CRT.REVOKE_APPLICATION, club, 'canRevokeApplication')
Ejemplo n.º 52
0
 def canAssignPrivate(self, profile, club=None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 53
0
 def canCloseClub(self, profile, club = None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     return self._isClubRequestValid(_CRT.CLOSE_CLUB, club, 'canCloseClub')
Ejemplo n.º 54
0
 def canChangeWebSettings(self, profile, club=None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 55
0
 def canDeclineApplication(self, profile, club = None):
     stateID = profile.getState().getStateID()
     if stateID != _CCB.HAS_CLUB:
         return error(_CCR.HAS_NO_CLUB)
     return self._isClubRequestValid(_CRT.DECLINE_APPLICATION, club, 'canDeclineApplication')
Ejemplo n.º 56
0
 def canAssignPrivate(self, profile, club = None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 57
0
 def canCreateUnit(self, profile, club = None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 58
0
 def canTransferOwnership(self, profile, club=None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 59
0
 def canTransferOwnership(self, profile, club = None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)
Ejemplo n.º 60
0
 def canChangeClubRequirements(self, profile, club=None):
     return error(CLIENT_CLUB_RESTRICTIONS.DEFAULT)