# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

from auto_nag import utils
from auto_nag.bzcleaner import BzCleaner


class TrackedBadSeverity(BzCleaner):
    def __init__(self):
        super(TrackedBadSeverity, self).__init__()
        if not self.init_versions():
            return

        self.status_release = utils.get_flag(
            self.versions["release"], "status", "release"
        )

    def description(self):
        return "Bug tracked in a release but with a small severity"

    def ignore_date(self):
        return True

    def get_bz_params(self, date):
        # TODO add support for ESR here?
        value = ",".join(["affected", "fixed"])
        params = {
            "bug_severity": ["normal", "minor", "trivial", "enhancement"],
            "f1": "OP",
            "j1": "OR",
            "f2": "OP",
            "f3": utils.get_flag(self.versions["release"], "tracking", "release"),
            "o3": "equals",
            "v3": "blocking",
            "f4": self.status_release,
            "o4": "anyexact",
            "v4": value,
            "f5": "CP",
            "f6": "OP",
            "f7": utils.get_flag(self.versions["beta"], "tracking", "beta"),
            "o7": "equals",
            "v7": "blocking",
            "f8": utils.get_flag(self.versions["beta"], "status", "beta"),
            "o8": "anyexact",
            "v8": value,
            "f9": "CP",
            "f10": "OP",
            "f11": utils.get_flag(self.versions["central"], "tracking", "central"),
            "o11": "equals",
            "v11": "blocking",
            "f12": utils.get_flag(self.versions["central"], "status", "central"),
            "o12": "anyexact",
            "v12": value,
            "f13": "CP",
            "f14": "CP",
        }

        return params

    def get_autofix_change(self):
        return {"severity": "major"}


if __name__ == "__main__":
    TrackedBadSeverity().run()

@@ -197,35 +197,8 @@
 /.%0A%0A
-from auto_nag import utils%0A
 from
@@ -348,16 +348,67 @@
 nit__()%0A
+        # need to check that versions aren't messy%0A
         
@@ -460,123 +460,8 @@
 rn%0A%0A
-        self.status_release = utils.get_flag(%0A            self.versions%5B%22release%22%5D, %22status%22, %22release%22%0A        )%0A%0A
     
@@ -912,70 +912,37 @@
 3%22: 
-utils.get_flag(self.versions%5B%22release%22%5D, %22tracking%22, %22
+%22cf_tracking_firefox_
 release%22
 ),%0A 
@@ -937,17 +937,16 @@
 release%22
-)
 ,%0A      
@@ -1019,27 +1019,35 @@
 4%22: 
-self.
+%22cf_
 status_
+firefox_
 release
+%22
 ,%0A  
@@ -1169,65 +1169,34 @@
 7%22: 
-utils.get_flag(self.versions%5B%22beta%22%5D, %22tracking%22, %22
+%22cf_tracking_firefox_
 beta%22
-)
 ,%0A  
@@ -1273,63 +1273,32 @@
 8%22: 
-utils.get_flag(self.versions%5B%22beta%22%5D, %22status%22, %22
+%22cf_status_firefox_
 beta%22
-)
 ,%0A  
@@ -1422,71 +1422,37 @@
 1%22: 
-utils.get_flag(self.versions%5B%22central%22%5D, %22tracking%22, %22central%22)
+%22cf_tracking_firefox_nightly%22
 ,%0A  
@@ -1532,69 +1532,35 @@
 2%22: 
-utils.get_flag(self.versions%5B%22central%22%5D, %22status%22, %22central%22)
+%22cf_status_firefox_nightly%22
 ,%0A  
@@ -1748,16 +1748,214 @@
 return %7B
+%0A            %22comment%22: %7B%0A                %22body%22: f%22This bug is tracked by a release manager but with a small severity so change it to major.%5Cn%7Bself.get_documentation()%7D%22%0A            %7D,%0A            
 %22severit
@@ -1965,16 +1965,26 @@
  %22major%22
+,%0A        
 %7D%0A%0A%0Aif _

add a comment to explain (#756)