class LogicGetMatchCondition(object):
    def __init__(self):
        self.relation = UserAndMatchCondition()
        self.condition = MatchCondition()

    # @staticmethod
    # def get_query(user_id, name):
    #     query = DBOHHOMatchCondition.get_by_user(user_id)
    #     query = DBOHHOMatchCondition.get_by_name(query, name)
    #     query = DBOHHOMatchCondition.order_by_id_asc(query)
    #     query = DBOHHOMatchCondition.first(query)
    #     return query

    def get(self, user_id, name=None):
        relation = self.relation.get(user_id, name)
        if relation:
            result = Result.result_success()
        else:
            user_id = 1
            name = "test"
            relation = self.relation.get(user_id, name)
            if relation:
                result = Result.result_not_exist(DEFAULT)
            else:
                result = Result.result_failed()
        if relation:
            condition = self.condition.get_by_id(relation.match_condition_id)
            if condition:
                result["data"] = self.condition.get_information(condition)
        else:
            condition = None

        return result, condition
    def get(self):
        the_get = Get()
        instance = MatchCondition()
        match_condition_id = the_get.get_id(self)
        match_condition = instance.get_by_id(match_condition_id)
        match_condition_dict = instance.get_information(match_condition)

        return self.render(BASE_MATCH_CONDITION_DETAIL_HTML,
                           condition=match_condition_dict,
                           match_condition_id=match_condition_id,
                           detail_url=BASE_MATCH_CONDITION_DETAIL_URL,
                           list_url=BASE_MATCH_CONDITION_LIST_URL
                           )