Sorin Sbarnea avatar Sorin Sbarnea committed cbdb613

Added rank() method for GreenHopper class, which now allows you to rank one issue before another.

Comments (0)

Files changed (1)

         'id':'',
         'Preview':'Preview',
         }
-        r = self._session.post(url, headers={'X-Atlassian-Token': 'nocheck', 'Cache-Control': 'no-cache'}, data=payload)
+        r = self._session.post(url, headers={'X-Atlassian-Token': 'nocheck', 'Cache-Control': 'no-cache, no-store, no-transform'}, data=payload)
         open("/tmp/jira_email_user_%s.html" % user,"w").write(r.content)
         #return False
 
     '''
 
     def __init__(self, options=None, basic_auth=None, oauth=None):
+        self._rank = None
         JIRA.__init__(self, options, basic_auth, oauth)
 
     def _gh_get_url(self, path):
         r = self._session.put(url, data=json.dumps(data), headers={'Content-Type': 'application/json'})
         raise_on_error(r)
 
+    def rank(self, issue, next_issue):
+        '''
+        Rank an issue before another using the default Ranking field, the one named 'Rank'.
+
+        :param issue: issue key of the issue to be ranked before the second one.
+        :param next_issue: issue key of the second issue.
+
+        '''
+        # {"issueKeys":["ANERDS-102"],"rankBeforeKey":"ANERDS-94","rankAfterKey":"ANERDS-7","customFieldId":11431}
+        if not self._rank:
+            for field in self.fields():
+                 if field['name'] == 'Rank' and field['schema']['custom']=="com.pyxis.greenhopper.jira:gh-global-rank":
+                     self._rank = field['schema']['customId']
+        data = {"issueKeys":[issue],"rankBeforeKey":next_issue,"customFieldId":self._rank}
+        url = self._gh_get_url('rank')
+        r = self._session.put(url, data=json.dumps(data), headers={'Content-Type': 'application/json'})
+        raise_on_error(r)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.