<commit_before>module InfoRequestCustomStates

    def self.included(base)
        base.extend(ClassMethods)
    end

    # Mixin methods for InfoRequest
    def theme_display_status(status)
        if status == 'deadline_extended'
            _("Deadline extended.")
        elsif status == 'wrong_response'
            _("Wrong Response.")
        else
            raise _("unknown status ") + status        
        end
    end

    def theme_calculate_status
        return 'waiting_classification' if self.awaiting_description
        waiting_response = self.described_state == "waiting_response" || self.described_state == "deadline_extended"
        return self.described_state unless waiting_response
        if self.described_state == 'deadline_extended' 
            return 'deadline_extended' if
                Time.now.strftime("%Y-%m-%d") < self.date_deadline_extended.strftime("%Y-%m-%d")
            return 'waiting_response_very_overdue'  if 
                Time.now.strftime("%Y-%m-%d") > Holiday.due_date_from(self.date_deadline_extended, 15).strftime("%Y-%m-%d")
            return 'waiting_response_overdue'
        end
        return 'waiting_response_very_overdue' if
            Time.now.strftime("%Y-%m-%d") > self.date_very_overdue_after.strftime("%Y-%m-%d")
        return 'waiting_response_overdue' if
            Time.now.strftime("%Y-%m-%d") > self.date_response_required_by.strftime("%Y-%m-%d")
        return 'waiting_response'
    end        

    def date_deadline_extended
        # XXX shouldn't this be 15 days after the date the status was
        # changed to "deadline extended"? Or perhaps 15 days ater the
        # initial request due date?
        return Holiday.due_date_from(self.date_response_required_by, 15)
    end

    module ClassMethods 
        def theme_extra_states
            return ['deadline_extended',
                    'wrong_response']
        end
    end
end

module RequestControllerCustomStates
<commit_msg>Due to ca6fd3700c7c439d6ea969afcba2d2656d5b123f, theme_display_status for custom states needs to be a class method<commit_after>module InfoRequestCustomStates

    def self.included(base)
        base.extend(ClassMethods)
    end

    # Mixin methods for InfoRequest
    def theme_calculate_status
        return 'waiting_classification' if self.awaiting_description
        waiting_response = self.described_state == "waiting_response" || self.described_state == "deadline_extended"
        return self.described_state unless waiting_response
        if self.described_state == 'deadline_extended' 
            return 'deadline_extended' if
                Time.now.strftime("%Y-%m-%d") < self.date_deadline_extended.strftime("%Y-%m-%d")
            return 'waiting_response_very_overdue'  if 
                Time.now.strftime("%Y-%m-%d") > Holiday.due_date_from(self.date_deadline_extended, 15).strftime("%Y-%m-%d")
            return 'waiting_response_overdue'
        end
        return 'waiting_response_very_overdue' if
            Time.now.strftime("%Y-%m-%d") > self.date_very_overdue_after.strftime("%Y-%m-%d")
        return 'waiting_response_overdue' if
            Time.now.strftime("%Y-%m-%d") > self.date_response_required_by.strftime("%Y-%m-%d")
        return 'waiting_response'
    end        

    def date_deadline_extended
        # XXX shouldn't this be 15 days after the date the status was
        # changed to "deadline extended"? Or perhaps 15 days ater the
        # initial request due date?
        return Holiday.due_date_from(self.date_response_required_by, 15)
    end

    module ClassMethods 
        def theme_display_status(status)
            if status == 'deadline_extended'
                _("Deadline extended.")
            elsif status == 'wrong_response'
                _("Wrong Response.")
            else
                raise _("unknown status ") + status        
            end
        end

        def theme_extra_states
            return ['deadline_extended',
                    'wrong_response']
        end
    end
end

module RequestControllerCustomStates

{'fraction_non_alphanumeric': 0.09073123012961604, 'fraction_numerical': 0.009293225727561751, 'mean_word_length': 2.4927412467976087, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4794571', 'n_tokens_mistral': 1242, 'n_tokens_neox': 1139, 'n_words': 248}