Exemple #1
0
    def get_cases(self, case_filter=''):
        """
        Get all cases that match the supplied filter. If no filter is supplied, all cases will be fetched.

        :param case_filter: Either Customer ID, Company ID, or Filter ID
        :type case_filter: str
        :return: All Cases that match the filter, If the request was completed successfully.
        :rtype: str, bool
        """
        results, ok = self.get(self.url, 'cases' + case_filter)

        all_cases = results['_embedded']['entries']
        Logging.get_logger(__name__).debug('Get Cases returned %s' %
                                           str(results))

        while results['_links']['next'] is not None:
            results, ok = self.get(
                self.url, results['_links']['next']['href'].split('/')[-1])
            Logging.get_logger(__name__).debug('Get Cases returned %s' %
                                               str(results))

            all_cases.append(results['_embedded']['entries'])

        Logging.get_logger(__name__).info('Fetched a total of %d cases.' %
                                          len(all_cases))

        marshaled_results = Marshal.desk_case(all_cases)

        for case in marshaled_results:
            case.customer = self.get_customer(case.customer_id)[0]
    def get_cases(self, case_filter=''):
        """
        Get all cases that match the supplied filter. If no filter is supplied, all cases will be fetched.

        :param case_filter: Either Customer ID, Company ID, or Filter ID
        :type case_filter: str
        :return: All Cases that match the filter, If the request was completed successfully.
        :rtype: str, bool
        """
        results, ok = self.get(self.url, 'cases' + case_filter)

        all_cases = results['_embedded']['entries']
        Logging.get_logger(__name__).debug('Get Cases returned %s' % str(results))

        while results['_links']['next'] is not None:
            results, ok = self.get(self.url, results['_links']['next']['href'].split('/')[-1])
            Logging.get_logger(__name__).debug('Get Cases returned %s' % str(results))

            all_cases.append(results['_embedded']['entries'])

        Logging.get_logger(__name__).info('Fetched a total of %d cases.' % len(all_cases))

        marshaled_results = Marshal.desk_case(all_cases)

        for case in marshaled_results:
            case.customer = self.get_customer(case.customer_id)[0]

        return marshaled_results, ok
Exemple #3
0
    def get_customer(self, customer_id):
        """
        Get the Customer Information for a specified id

        :param customer_id:
         :type customer_id: int
        :return: Customer Information, If the request was completed successfully.
        :rtype: str, bool
        """
        results, ok = self.get(self.url, 'customers/' + str(customer_id))

        return Marshal.desk_customer(results), ok
    def get_customer(self, customer_id):
        """
        Get the Customer Information for a specified id

        :param customer_id:
         :type customer_id: int
        :return: Customer Information, If the request was completed successfully.
        :rtype: str, bool
        """
        results, ok = self.get(self.url, 'customers/' + str(customer_id))

        return Marshal.desk_customer(results), ok
def get_grey_leader():
    try:
        marshal = random.choice(marshals)
        if marshal.is_greyleader():
            if marshal not in usedMarshals:
                return marshal
            elif marshal in usedMarshals:
                if usedMarshals.count(marshal) < 2:
                    return marshal
                elif usedMarshals.count(marshal) >= 2:
                    return get_grey_leader()
        elif not marshal.is_greyleader():
            return get_grey_leader()
    except RecursionError:
        return Marshal("", False, False, False)
    name = marshalRow[3]

    HeadMarshal = False
    RegularMarshal = False
    GreyLeader = False

    if marshalRow[0] != "":
        RegularMarshal = (False, True)[bool(len(marshalRow[0]) > 0)]

    if marshalRow[1] != "":
        HeadMarshal = (False, True)[bool(len(marshalRow[1]) > 0)]

    if marshalRow[2] != "":
        GreyLeader = (False, True)[bool(len(marshalRow[2]) > 0)]

    marshals.append(Marshal(name, HeadMarshal, RegularMarshal, GreyLeader))

roster = []

# Logic = 2 months (8 weeks), require GL, HM and 2 M's
#         no one person should have more than two rostered
#         positions in two months
#

todaysDate = next_weekday(dt.datetime.now(), 3)
for idx in range(8):
    weekDate = todaysDate + dt.timedelta(weeks=idx)
    weekDate = weekDate.strftime("%Y-%m-%d")

    week = idx + 1