def get_stories(projectIds): stories = {} start = 1 pagesize = 200 for projId in projectIds: 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) rest_header['X-Zen-ApiKey'] = ConfigCache.get_config_value( 'agilezen.apikey') 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'] 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: 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) rest_header['X-Zen-ApiKey'] = ConfigCache.get_config_value('agilezen.apikey') 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'] 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} js = json.dumps(results) return HttpResponse(js, content_type='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} js = json.dumps(results) return HttpResponse(js, content_type='application/json')