Exemple #1
0
    def report_event(self, reason=None, details_text=None,
            subreddit=None, target=None, request=None, context=None):
        """Create a 'report' event for event-collector.

        process_notes: Type of rule (pre-defined report reasons or custom)
        details_text: The report reason
        subreddit: The Subreddit the action is being performed in
        target: The Thing the action was applied to
        request, context: Should be pylons.request & pylons.c respectively

        """
        from r2.models.rules import OLD_SITEWIDE_RULES, SITEWIDE_RULES, SubredditRules

        event = Event(
            topic="report_events",
            event_type="ss.report",
            request=request,
            context=context,
        )
        if reason in OLD_SITEWIDE_RULES or reason in SITEWIDE_RULES:
            process_notes = "SITE_RULES"
        else:
            if subreddit and SubredditRules.get_rule(subreddit, reason):
                process_notes = "SUBREDDIT_RULES"
            else:
                process_notes = "CUSTOM"

        event.add("process_notes", process_notes)
        event.add("details_text", details_text)

        event.add_subreddit_fields(subreddit)
        event.add_target_fields(target)

        self.save_event(event)
Exemple #2
0
    def report_event(self, reason=None, details_text=None,
            subreddit=None, target=None, request=None, context=None):
        """Create a 'report' event for event-collector.

        process_notes: Type of rule (pre-defined report reasons or custom)
        details_text: The report reason
        subreddit: The Subreddit the action is being performed in
        target: The Thing the action was applied to
        request, context: Should be pylons.request & pylons.c respectively

        """
        from r2.models.rules import OLD_SITEWIDE_RULES, SITEWIDE_RULES, SubredditRules

        event = Event(
            topic="report_events",
            event_type="ss.report",
            request=request,
            context=context,
        )
        if reason in OLD_SITEWIDE_RULES or reason in SITEWIDE_RULES:
            process_notes = "SITE_RULES"
        else:
            if subreddit and SubredditRules.get_rule(subreddit, reason):
                process_notes = "SUBREDDIT_RULES"
            else:
                process_notes = "CUSTOM"

        event.add("process_notes", process_notes)
        event.add("details_text", details_text)

        event.add_subreddit_fields(subreddit)
        event.add_target_fields(target)

        self.save_event(event)