def register(self): # Check if 'issues' is in the command arguments if self.args.main == 'issues': # Check if there is a number of issues to pull number_issues = self.args.id or 20 # Print a list with all the issues for issue in Issue().all(number_issues): print issue # Check if there id argument is set if self.args.id != 0 and self.args.main != 'issues': try: # Set the current issue self.current_issue = Issue().get(self.args.id) except IssueDoesNotExist: print CoreErrors.does_not_exist('issue') sys.exit() if self.args.main == 'show': # Display the current issue IssueMessages.display_issue(self.current_issue) elif self.args.main == 'init': # Initialzie a new project Project.create() elif self.args.main == 'workon': # Work on the current issue WorkOn.issue(self.current_issue) elif self.args.main == 'workoff': # Workoff the current issue WorkOff.issue(self.current_issue) elif self.args.main == 'time': # Check if the secondary argument is 'toggle' or blank if self.args.secondary == 'toggle' or self.args.secondary == '': # Run the timelog toggle for the specific issue command TimeLog.toggle(self.current_issue) # Check if the secondary argument is 'pause' elif self.args.secondary == 'pause': # Run the timelog pause for the specific issue command TimeLog.pause(self.current_issue) # Check if the secondary argument is 'resume' elif self.args.secondary == 'resume': # Run the resume toggle for the specific issue command TimeLog.resume(self.current_issue) elif self.args.main == 'hours': if self.args.secondary == 'all' or self.args.secondary == '': TimeEntry.all() elif self.args.secondary == 'new': TimeEntry.new()
def filter(self, limit=20, **kwargs): # Check if there is a description flag on the keyword arguments description = 'description' in kwargs and kwargs.pop('description') # Check if there is an option checked if len(kwargs) == 0: # As default set the options to by assigned to the current user kwargs['assigned_to_id'] = self.redmine.user.get('current').id # Get all the issues with for that options issues = self.redmine.issue.filter(sort='status:asc', **kwargs)[:limit] # Return all the issues with the issues list format return (IssueMessages.issue_format(i, description) for i in issues)