def get_stories(projectIds): stories = {} start = 1 pagesize = 200 for projId in projectIds: print 'project' lastPage = False page = start while not (lastPage): storyurl = agileurl + apiurl + 'projects/' + projId + '/stories?' + get_page_query_params( page, pagesize) logger.debug('Retrieving Stories from URL: ' + storyurl) print storyurl response = requests.get(storyurl, headers=rest_header) processed_response = response.json() story_list = processed_response[u'items'] count = len(story_list) #processed_response[u'totalItems'] print 'count %d' % count for result in story_list: #print result phase = result[u'phase'] ignorestates = [u'Backlog'] if not phase[u'name'] in ignorestates: story = Story() story.rally_id = result[u'id'] story.name = result[u'text'][0:100] story.sprint = result[u'text'][0:3] story.url = agileurl + 'project/' + projId + '/story/%d' % result[ u'id'] project = result[u'project'] project_name = project[u'name'] projshort_name = '' try: projshort_name = (re.search(r'\(.*?\)', project_name)).group() except: #expected the project name to have a short name in () #this will cut the name down to 10 characters and append ERRNOPAREN projshort_name = '%s-%s' % (project_name[0:10], '(ERRNOPAREN)') story.sprint = '%s - %s' % (projId, projshort_name) storykey = '%s-%s' % (story.rally_id, story.sprint) #print 'generated key for stories list - %s' % storykey stories[storykey] = story if count == 0: lastPage = True page += 1 return stories
def get_stories(projectIds): stories = {} start = 1 pagesize = 200 for projId in projectIds: print 'project' lastPage = False page = start while not (lastPage): storyurl = agileurl + apiurl + 'projects/' + projId + '/stories?' + get_page_query_params( page, pagesize) logger.debug('Retrieving Stories from URL: ' + storyurl) print storyurl response = requests.get(storyurl, headers=rest_header) processed_response = response.json() story_list = processed_response[u'items'] count = len(story_list) #processed_response[u'totalItems'] print 'count %d' % count for result in story_list: #print result phase = result[u'phase'] ignorestates = [ u'Backlog', u'Ready', u'Archive', u'Release Candidate / Production' ] if not phase[u'name'] in ignorestates: story = Story() story.rally_id = result[u'id'] story.name = result[u'text'][0:100] story.sprint = result[u'text'][0:3] story.url = agileurl + 'project/' + projId + '/story/%d' % result[ u'id'] try: story.sprint = '%s - %s' % (projId, result[u'deadline']) #story.release_date = result[u'deadline'] except: story.sprint = '%s' % projId logger.debug('no deadline for story %d' % story.rally_id) stories[story.rally_id] = story if count == 0: lastPage = True page += 1 return stories
def get_stories(projectIds): stories = {} start = 1 pagesize = 200 for projId in projectIds: print 'project' lastPage = False page = start while not(lastPage): storyurl = agileurl+apiurl+'projects/'+ projId +'/stories?'+ get_page_query_params(page, pagesize) logger.debug('Retrieving Stories from URL: '+storyurl) print storyurl response = requests.get(storyurl, headers=rest_header) processed_response = response.json() story_list = processed_response[u'items'] count = len(story_list) #processed_response[u'totalItems'] print 'count %d'%count for result in story_list: #print result phase = result[u'phase'] ignorestates = [u'Backlog'] if not phase[u'name'] in ignorestates: story = Story() story.rally_id = result[u'id'] story.name = result[u'text'][0:100] story.sprint = result[u'text'][0:3] story.url = agileurl+'project/'+ projId +'/story/%d'%result[u'id'] project = result[u'project'] project_name = project[u'name'] projshort_name = '' try: projshort_name = (re.search( r'\(.*?\)', project_name)).group() except: #expected the project name to have a short name in () #this will cut the name down to 10 characters and append ERRNOPAREN projshort_name = '%s-%s' % (project_name[0:10],'(ERRNOPAREN)') story.sprint = '%s - %s' % (projId, projshort_name) storykey = '%s-%s' % (story.rally_id, story.sprint) #print 'generated key for stories list - %s' % storykey stories[storykey] = story if count == 0: lastPage = True page += 1 return stories
def get_stories(projectIds): stories = {} start = 1 pagesize = 200 for projId in projectIds: print 'project' lastPage = False page = start while not(lastPage): storyurl = agileurl+apiurl+'projects/'+ projId +'/stories?'+ get_page_query_params(page, pagesize) logger.debug('Retrieving Stories from URL: '+storyurl) print storyurl response = requests.get(storyurl, headers=rest_header) processed_response = response.json() story_list = processed_response[u'items'] count = len(story_list) #processed_response[u'totalItems'] print 'count %d'%count for result in story_list: #print result phase = result[u'phase'] ignorestates = [u'Backlog', u'Ready', u'Archive', u'Release Candidate / Production'] if not phase[u'name'] in ignorestates: story = Story() story.rally_id = result[u'id'] story.name = result[u'text'][0:100] story.sprint = result[u'text'][0:3] story.url = agileurl+'project/'+ projId +'/story/%d'%result[u'id'] try: story.sprint = '%s - %s' % (projId, result[u'deadline']) #story.release_date = result[u'deadline'] except: story.sprint = '%s'%projId logger.debug('no deadline for story %d'%story.rally_id) stories[story.rally_id] = story if count == 0: lastPage = True page += 1 return stories
def addtostory(request): log = logging.getLogger("user") results = {"success": False} if request.method == u"GET": story = None try: storyId = request.GET["storyId"] if storyId == "null": storyId = "" storyName = request.GET["storyName"] storyRallyId = request.GET["storyRallyId"] storyURL = request.GET["storyURL"] if len(storyId) > 0 or len(storyRallyId) > 0: if len(storyId) > 0: try: story = Story.objects.get(id=storyId) except ObjectDoesNotExist: pass if not story and len(storyRallyId) > 0: try: story = Story.objects.get(rally_id=storyRallyId) except ObjectDoesNotExist: pass if not story: story = Story() if len(storyRallyId) > 0: story.rally_id = storyRallyId story.url = "https://rally1.rallydev.com/slm/detail/" + story.rally_id if len(storyURL) > 0: story.url = storyURL if len(storyName) > 0: story.name = storyName story.save() objectIds = request.GET.getlist("itemid") objects = DeployableObject.objects.filter(id__in=objectIds) for object in objects: if story: object.pending_stories.add(story) object.release_status = "p" object.save() transIds = request.GET.getlist("transid") translations = DeployableTranslation.objects.filter(id__in=transIds) for translation in translations: if story: translation.pending_stories.add(story) translation.release_status = "p" translation.save() results = {"success": True} except Exception as ex: tb = traceback.format_exc() results = {"success": False, "error": "ERROR: " + tb} json = simplejson.dumps(results) return HttpResponse(json, mimetype="application/json")
def addtostory(request): log = logging.getLogger('user') results = {'success':False} if request.method == u'GET': story = None try: storyId = request.GET['storyId'] if (storyId == 'null'): storyId = '' storyName = request.GET['storyName'] storyRallyId = request.GET['storyRallyId'] storyURL = request.GET['storyURL'] if len(storyId) > 0 or len(storyRallyId) > 0: if len(storyId) > 0: try: story = Story.objects.get(id=storyId) except ObjectDoesNotExist: pass if not story and len(storyRallyId) > 0: try: story = Story.objects.get(rally_id=storyRallyId) except ObjectDoesNotExist: pass if not story: story = Story() if len(storyRallyId) > 0: story.rally_id = storyRallyId story.url = "https://rally1.rallydev.com/slm/detail/" + story.rally_id if len(storyURL) > 0: story.url = storyURL if len(storyName) > 0: story.name = storyName story.save() objectIds = request.GET.getlist('itemid'); objects = DeployableObject.objects.filter(id__in=objectIds) for object in objects: if story: object.pending_stories.add(story) object.release_status = 'p' object.save() transIds = request.GET.getlist('transid'); translations = DeployableTranslation.objects.filter(id__in=transIds) for translation in translations: if story: translation.pending_stories.add(story) translation.release_status = 'p' translation.save() results = {'success':True} except Exception as ex: tb = traceback.format_exc() results = {'success':False, 'error':'ERROR: ' + tb} json = simplejson.dumps(results) return HttpResponse(json, mimetype='application/json')