def __init__(self, redmine, *args, **kw_args): # Override init to also set up sub-queries # Call the base-class init super(Project, self).__init__(redmine, *args, **kw_args) # Manage issues for this project, # using __dict__ to bypass the changes__dict__ # Bake this project ID into queries and new issue commands self.__dict__['issues'] = Redmine_Items_Manager( redmine, Issue, query_path='/projects/%s/issues.json' % self.id, item_new_path='/projects/%s/issues.json' % self.id) # Manage time entries for this project self.__dict__['time_entries'] = Redmine_Items_Manager( redmine, Time_Entry, query_path='/projects/%s/time_entries.json' % self.id, item_new_path='/projects/%s/time_entries.json' % self.id) # Manage wiki pages if they're available if redmine._wiki_pages: self.__dict__['wiki_pages'] = Redmine_Wiki_Pages_Manager( redmine, self)
def __init__(self, redmine, project): # Call the base class constructor path = '/projects/%s/wiki/%%s.json' % project.id Redmine_Items_Manager.__init__(self, redmine, Wiki_Page, item_path=path, item_new_path=path) self._project = project
def __init__(self, redmine, project): # Call the base class constructor Redmine_Items_Manager.__init__( self, redmine, Wiki_Page, item_path='/projects/%s/wiki/%%s.json' % project.id, item_new_path='/projects/%s/wiki/%%s.json' % project.id) self._project = project
def __init__(self, redmine, *args, **kw_args): # Override init to also set up sub-queries # Call the base-class init super(Issue, self).__init__(redmine, *args, **kw_args) # to manage time_entries for this issue self.__dict__['time_entries'] = Redmine_Items_Manager( redmine, Time_Entry) self.time_entries._query_path = '/issues/%s/time_entries.json' % self.id self.time_entries._item_new_path = self.time_entries._query_path
def _set_version(self, version): '''Set up this object based on the capabilities of the known versions of Redmine''' # Store the version we are evaluating self.version = version or None # To evaluate the version capabilities, assume the best-case if no version is provided version_check = version or 9999.0 if version_check < 1.0: raise RedmineError( 'This library will only work with Redmine version 1.0 and higher.' ) ## SECURITY AUGMENTATION # All versions support the key in the request (http://server/stuff.json?key=blah) # But versions 1.1 and higher can put the key in a header field for better security. # If no version was provided (0.0) then assume we should set the key with the request. if version >= 1.1: self.key_in_header = True # it puts the key in the header or it gets the hose, but not for 1.0 self.impersonation_supported = version_check >= 2.2 ## ITEM MANAGERS self.issues = Redmine_Items_Manager(self, Issue) self.projects = Redmine_Items_Manager(self, Project) self.trackers = Redmine_Items_Manager(self, Tracker) if version_check >= 1.1: self.users = Redmine_Items_Manager(self, User) self.news = Redmine_Items_Manager(self, News) self.time_entries = Redmine_Items_Manager(self, Time_Entry) if version_check >= 1.3: #issue relations #versions #queries #attachments #issue statuses #trackers #issue categories pass self._project_memberships = False if version_check >= 1.4: self._project_memberships = True #roles pass if version_check >= 2.1: #groups pass self._wiki_pages = False if version_check >= 2.2: self.time_entry_activities = Redmine_Items_Manager( self, Time_Entry_Activity) self._wiki_pages = True
def _set_version(self, version): ''' Set up this object based on the capabilities of the known versions of Redmine ''' # Store the version we are evaluating self.version = version or None # To evaluate the version capabilities, # assume the best-case if no version is provided. version_check = version or 9999.0 if version_check < 1.0: raise RedmineError('This library will only work with ' 'Redmine version 1.0 and higher.') ## SECURITY AUGMENTATION # All versions support the key in the request # (http://server/stuff.json?key=blah) # But versions 1.1 and higher can put the key in a header field # for better security. # If no version was provided (0.0) then assume we should # set the key with the request. self.key_in_header = version >= 1.1 # it puts the key in the header or # it gets the hose, but not for 1.0. self.impersonation_supported = version_check >= 2.2 self.has_project_memberships = version_check >= 1.4 self.has_project_versions = version_check >= 1.3 self.has_wiki_pages = version_check >= 2.2 ## ITEM MANAGERS # Step through all the item managers by version # and instatiate and item manager for that item. for manager_version in self._item_managers_by_version: if version_check >= manager_version: managers = self._item_managers_by_version[manager_version] for attribute_name, item in managers.iteritems(): setattr(self, attribute_name, Redmine_Items_Manager(self, item))