Example #1
0
def getAgentForBranch(branch, logger=None):
    if not logger: logger = logging.getLogger('root')

    user = branch.api_user
    password = branch.api_pass
    authkey = branch.api_auth
    if authkey is None: authkey = ''
    path = branch.api_store
    types = branch.api_assets.split(',')
    svcurl = 'https://' + branch.api_env + '.salesforce.com/services/Soap/u/' + CSBase.CS_SF_API_VERSION  #branch.api_ver

    #    print("user='******' path='%s' types=[%s] url='%s'", user, path, ' '.join(types), svcurl)

    partner_wsdl = 'file://' + os.path.join(CSBase.CSCONF_DIR, 'partner.wsdl')
    meta_wsdl = 'file://' + os.path.join(CSBase.CSCONF_DIR, 'metadata.wsdl')

    proxy_host = ConfigCache.get_config_value('proxy.host')
    proxy_port = ConfigCache.get_config_value('proxy.port')

    if len(proxy_host) > 0 and len(proxy_port) > 0:
        agent = SalesforceAgent(partner_wsdl,
                                meta_wsdl,
                                clientLogger=logger,
                                proxy_host=proxy_host,
                                proxy_port=proxy_port)
    else:
        agent = SalesforceAgent(partner_wsdl, meta_wsdl, clientLogger=logger)

    agent.login(user, password + authkey, server_url=svcurl)
    return agent
Example #2
0
def rally_projects(request):
    if request.method == u'GET' and request.GET.__contains__('chkProject'):
         pickedProjs = request.GET.getlist('chkProject')
         isFirst = True
         projectConfValue = ''
         for p in pickedProjs:
            if not isFirst:
                projectConfValue = projectConfValue + ';'
            isFirst = False
            projectConfValue = projectConfValue + p

         ConfigCache.store_config_value('rally.pickedprojects', projectConfValue)
         return redirect('/configs/')

    projects = []
    if ConfigCache.get_config_value('rally.enabled') == '1':
        projlist = rallyintegration.get_projects(True)
        for project in projlist:
            projects.append( project )
            
    if ConfigCache.get_config_value('agilezen.enabled') == '1':
        projlist = agilezenintegration.get_projects(True)
        for project in projlist:
            projects.append( project )

    data = {'projects': projects}
    return render_to_response('rally_projects.html', data, context_instance=RequestContext(request))
Example #3
0
def getAgentForBranch(branch, logger = None):
    if not logger: logger = logging.getLogger('root')

    user = branch.api_user
    password = branch.api_pass
    authkey = branch.api_auth
    if authkey is None: authkey = ''
    path = branch.api_store
    types = branch.api_assets.split(',')
    svcurl = 'https://' + branch.api_env + '.salesforce.com/services/Soap/u/' + CSBase.CS_SF_API_VERSION #branch.api_ver

#    print("user='******' path='%s' types=[%s] url='%s'", user, path, ' '.join(types), svcurl)

    partner_wsdl = 'file://' + os.path.join(CSBase.CSCONF_DIR, 'partner.wsdl')
    meta_wsdl = 'file://' + os.path.join(CSBase.CSCONF_DIR, 'metadata.wsdl')

    proxy_host = ConfigCache.get_config_value('proxy.host')
    proxy_port = ConfigCache.get_config_value('proxy.port')

    if len(proxy_host) > 0 and len(proxy_port) > 0:
        agent = SalesforceAgent(partner_wsdl, meta_wsdl, clientLogger=logger, proxy_host=proxy_host, proxy_port=proxy_port)
    else:
        agent = SalesforceAgent(partner_wsdl, meta_wsdl, clientLogger=logger)

    agent.login(user, password+authkey,server_url=svcurl)
    return agent
def email_results(batch, failures, runs):
    long_runners = UnitTestRunResult.objects.filter(test_run__in=runs).order_by('-runtime')[:5]
    long_runners.select_related()
    long_runner_classes = UnitTestRun.objects.filter(batch=batch).order_by('-runtime')[:5]
    long_runner_classes.select_related()
    
    try:
        schedule = UnitTestSchedule.objects.get(branch=batch.branch)
    except ObjectDoesNotExist:
        logger.error('No Schedule exists for this branch (' + batch.branch.name + '), so no way to figure out who to email')
        return

    email_host = ConfigCache.get_config_value('email.host')
    conn = mail.get_connection(host=email_host)
    
    from_address = ConfigCache.get_config_value('email.from')
    
    if schedule.email_only_failures and len(failures) == 0:
        return
    
    template = get_template('unit_test_results_email.html')
    c = Context({'batch': batch, 'failures': failures, 'long_runners': long_runners, 'long_runner_classes': long_runner_classes})
        
    subject = 'Unit test results for ' + batch.branch.name.upper() + ' started at ' + str(batch.batch_time)
    from_email, to = from_address, schedule.results_email_address
    text_content = 'Please join the 21st century and get an HTML compatible email client to see the content of this email.'
    html_content = template.render(c)
    msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
    msg.attach_alternative(html_content, "text/html")
    msg.connection = conn
    msg.send(fail_silently=False)
Example #5
0
def rally_projects(request):
    if request.method == u'GET' and request.GET.__contains__('chkProject'):
        pickedProjs = request.GET.getlist('chkProject')
        isFirst = True
        projectConfValue = ''
        for p in pickedProjs:
            if not isFirst:
                projectConfValue = projectConfValue + ';'
            isFirst = False
            projectConfValue = projectConfValue + p

        ConfigCache.store_config_value('rally.pickedprojects',
                                       projectConfValue)
        return redirect('/configs/')

    projects = []
    if ConfigCache.get_config_value('rally.enabled') == '1':
        projlist = rallyintegration.get_projects(True)
        for project in projlist:
            projects.append(project)

    if ConfigCache.get_config_value('agilezen.enabled') == '1':
        projlist = agilezenintegration.get_projects(True)
        for project in projlist:
            projects.append(project)

    data = {'projects': projects}
    return render_to_response('rally_projects.html',
                              data,
                              context_instance=RequestContext(request))
def connect():
    rally_user = ConfigCache.get_config_value('rally.login')
    rally_pass = ConfigCache.get_config_value('rally.password')

    credentials = requests.auth.HTTPBasicAuth(rally_user, rally_pass)

    proxy_host = ConfigCache.get_config_value('proxy.host')
    proxy_port = ConfigCache.get_config_value('proxy.port')

    if len(proxy_host) > 0 and len(proxy_port) > 0:
        proxydict = {
            "http": "%s:%s" % (proxy_host, proxy_port),
            "https": "%s:%s" % (proxy_host, proxy_port),
        }
    else:
        proxydict = {}

    session = requests.session(headers=RALLY_REST_HEADERS,
                               auth=credentials,
                               timeout=45.0,
                               proxies=proxydict,
                               config={})

    logger.debug('Logging in with username ' + rally_user)

    return session
def connect():
    rally_user = ConfigCache.get_config_value('rally.login')
    rally_pass = ConfigCache.get_config_value('rally.password')
    
    logger.debug('Logging in with username ' + rally_user)

    password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
    password_manager.add_password( None, 'https://' + settings.RALLY_SERVER + '/', rally_user, rally_pass )
    auth_handler = urllib2.HTTPBasicAuthHandler(password_manager)
    opener = urllib2.build_opener(auth_handler)
    urllib2.install_opener(opener)

    return urllib2
def connect():
    rally_user = ConfigCache.get_config_value('rally.login')
    rally_pass = ConfigCache.get_config_value('rally.password')

    logger.debug('Logging in with username ' + rally_user)

    password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
    password_manager.add_password(None,
                                  'https://' + settings.RALLY_SERVER + '/',
                                  rally_user, rally_pass)
    auth_handler = urllib2.HTTPBasicAuthHandler(password_manager)
    opener = urllib2.build_opener(auth_handler)
    urllib2.install_opener(opener)

    return urllib2
def refresh():
        projectList = ConfigCache.get_config_value('rally.pickedprojects')
        #print 'project list: '+projectList
        if len(projectList) > 0:
            rallyStories = get_stories(projectList.split(';'))
            dbstories = Story.objects.filter(rally_id__in=rallyStories.keys())
            dbStoryMap = {}
            for dbstory in dbstories:
                #print 'storing story %d' % int(dbstory.rally_id)
                dbStoryMap[int(dbstory.rally_id)] = dbstory

            for story in rallyStories.values():
                dbstory = story
                if story.rally_id in dbStoryMap:
                    #print 'match found %d' % story.rally_id
                    logger.debug('Updating [%d]' % story.rally_id)
                    # Override with database version if it exists
                    dbstory = dbStoryMap[story.rally_id]
                    dbstory.url = story.url
                    dbstory.name = story.name
                    dbstory.sprint = story.sprint
                else:
                    #print 'no match found %d' % story.rally_id
                    logger.debug('Creating [%d]' % story.rally_id)
                    dbstory.sprint = story.sprint
                
                dbstory.save()
def refresh():
    projectList = ConfigCache.get_config_value('rally.pickedprojects')
    #print 'project list: '+projectList
    if len(projectList) > 0:
        rallyStories = get_stories(projectList.split(';'))
        dbstories = Story.objects.all()
        dbStoryMap = {}
        for dbstory in dbstories:
            # generage a key here based on the project id (rally_id) and (sprint)
            # previously generating a key based only in rally_id lead to stories
            # across projects getting confused (eg: proj1-story1 == proj2-story1)
            # creating a more complex key resolves that logical error
            key = '%s-%s' % (dbstory.rally_id, dbstory.sprint)
            dbStoryMap[key] = dbstory
        for story in rallyStories.values():
            dbstory = story
            storykey = '%s-%s' % (story.rally_id, story.sprint)
            if (storykey in dbStoryMap):
                # This logic is used to update a story when it already exists
                # and has been downloaded again
                logger.debug('Updating [%d]-sprint[%s]' % (story.rally_id, story.sprint))
                # Override with database version if it exists
                dbstory = dbStoryMap[storykey]
                dbstory.url = story.url
                dbstory.name = story.name
                dbstory.sprint = story.sprint
            else:
                #print 'no match found %d' % story.rally_id
                logger.debug('Creating [%d]' % story.rally_id)
                dbstory.sprint = story.sprint
                
            dbstory.save()
def refresh():
    projectList = ConfigCache.get_config_value('rally.pickedprojects')
    #print 'project list: '+projectList
    if len(projectList) > 0:
        rallyStories = get_stories(projectList.split(';'))
        dbstories = Story.objects.filter(rally_id__in=rallyStories.keys())
        dbStoryMap = {}
        for dbstory in dbstories:
            #print 'storing story %d' % int(dbstory.rally_id)
            dbStoryMap[int(dbstory.rally_id)] = dbstory

        for story in rallyStories.values():
            dbstory = story
            if story.rally_id in dbStoryMap:
                #print 'match found %d' % story.rally_id
                logger.debug('Updating [%d]' % story.rally_id)
                # Override with database version if it exists
                dbstory = dbStoryMap[story.rally_id]
                dbstory.url = story.url
                dbstory.name = story.name
                dbstory.sprint = story.sprint
            else:
                #print 'no match found %d' % story.rally_id
                logger.debug('Creating [%d]' % story.rally_id)
                dbstory.sprint = story.sprint

            dbstory.save()
Example #12
0
def refresh():
    projectList = ConfigCache.get_config_value('rally.pickedprojects')
    #print 'project list: '+projectList
    if len(projectList) > 0:
        rallyStories = get_stories(projectList.split(';'))
        dbstories = Story.objects.all()
        dbStoryMap = {}
        for dbstory in dbstories:
            # generage a key here based on the project id (rally_id) and (sprint)
            # previously generating a key based only in rally_id lead to stories
            # across projects getting confused (eg: proj1-story1 == proj2-story1)
            # creating a more complex key resolves that logical error
            key = '%s-%s' % (dbstory.rally_id, dbstory.sprint)
            dbStoryMap[key] = dbstory
        for story in rallyStories.values():
            dbstory = story
            storykey = '%s-%s' % (story.rally_id, story.sprint)
            if (storykey in dbStoryMap):
                # This logic is used to update a story when it already exists
                # and has been downloaded again
                logger.debug('Updating [%d]-sprint[%s]' %
                             (story.rally_id, story.sprint))
                # Override with database version if it exists
                dbstory = dbStoryMap[storykey]
                dbstory.url = story.url
                dbstory.name = story.name
                dbstory.sprint = story.sprint
            else:
                #print 'no match found %d' % story.rally_id
                logger.debug('Creating [%d]' % story.rally_id)
                dbstory.sprint = story.sprint

            dbstory.save()
Example #13
0
def home(request):
    data = {'branches': Branch.objects.filter(enabled__exact = True)}

    data['calendar_host'] = ConfigCache.get_config_value('calendar.host')
    if data['calendar_host'] == 'localhost':
        data['calendar_host'] = request.get_host().split(':')[0]

    return render_to_response('home.html', data, context_instance=RequestContext(request))
Example #14
0
def configs(request):
    allsettings = ConfigSetting.objects.all()

    if request.method == u'POST':
        logger.debug('Got a post!')
        params = dict(request.POST.items())
        for param in params:
            if param.startswith('key_'):
                key = smart_str(param, 'utf-8', False)[4:]
                value = request.POST[param]
                for setting in allsettings:
                    if key == setting.key:
                        logger.debug('Working on ' + setting.key + '!')
                        if setting.value != value:
                            if setting.masked:
                                repValue = request.POST[param + '_2']
                                logger.debug('Checking if the values match!')
                                if repValue == value:
                                    logger.debug('Values Match!')
                                    setting.value = value
                                    setting.save()
                            else:
                                setting.value = value
                                setting.save()

        # Handle checkboxes
        for setting in allsettings:
            if setting.type == 'check':
                if not request.POST.__contains__('key_' + setting.key):
                    setting.value = '0'
                    setting.save()

        ConfigCache.refresh()
        allsettings = ConfigSetting.objects.all()

    data = {'settings': allsettings}
    for setting in allsettings:
        if setting.type == 'check':
            data[setting.key.replace('.', '_')] = setting.value == '1'
        else:
            data[setting.key.replace('.', '_')] = setting.value

    return render_to_response('configs.html',
                              data,
                              context_instance=RequestContext(request))
Example #15
0
def configs(request):
    allsettings = ConfigSetting.objects.all();

    if request.method == u'POST':
        logger.debug('Got a post!')
        params = dict(request.POST.items())
        for param in params:
            if param.startswith('key_'):
                key = smart_str(param,'utf-8',False)[4:]
                value = request.POST[param]
                for setting in allsettings:
                    if key == setting.key:
                        logger.debug('Working on ' + setting.key + '!')
                        if setting.value != value:
                            if setting.masked:
                                # only proceed with update if masked value is not empty
                                if value != '':
                                    repValue = request.POST[param + '_2']
                                    logger.debug('Checking if the values match!')
                                    if repValue == value:
                                       logger.debug('Values Match!')
                                       setting.value = value
                                       setting.save()
                            else:
                                setting.value = value
                                setting.save()

        # Handle checkboxes
        for setting in allsettings:
            if setting.type == 'check':
                if not request.POST.__contains__('key_' + setting.key):
                    setting.value = '0'
                    setting.save()

        ConfigCache.refresh()
        allsettings = ConfigSetting.objects.all();

    data = {'settings': allsettings.order_by('key')}
    for setting in allsettings:
        if setting.type == 'check':
            data[setting.key.replace('.','_')] = setting.value == '1'
        else:
            data[setting.key.replace('.','_')] = setting.value
    
    return render_to_response('configs.html', data, context_instance=RequestContext(request))
Example #16
0
def removeCalendarReleaseEvent(release_id):
    params = urllib.urlencode({'ReleaseId': release_id, 'guid': ConfigCache.get_uuid()})
    submitCalendarREST('removerelease', params)
#    try:
#        event = CalendarEvent.objects.get(release_id=release_id)
#        event.delete()
#    except ObjectDoesNotExist:
#        pass
    pass
Example #17
0
def submitCalendarREST(method, params):
    cal_host = ConfigCache.get_config_value('calendar.host')
    if cal_host is None or len(cal_host) == 0: return

    headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/javascript"}
    conn = httplib.HTTPConnection(cal_host)
    conn.request("POST", "/wdcalendar/php/datafeed.php?method=%s" % method, params, headers)
    response = conn.getresponse()
    print "%s=%s %s" % (method, response.status, response.reason)
    conn.close()
Example #18
0
def home(request):
    data = {'branches': Branch.objects.filter(enabled__exact=True)}

    data['calendar_host'] = ConfigCache.get_config_value('calendar.host')
    if data['calendar_host'] == 'localhost':
        data['calendar_host'] = request.get_host().split(':')[0]

    return render_to_response('home.html',
                              data,
                              context_instance=RequestContext(request))
def email_results(batch, failures, runs):
    long_runners = UnitTestRunResult.objects.filter(
        test_run__in=runs).order_by('-runtime')[:5]
    long_runners.select_related()
    long_runner_classes = UnitTestRun.objects.filter(
        batch=batch).order_by('-runtime')[:5]
    long_runner_classes.select_related()

    try:
        schedule = UnitTestSchedule.objects.get(branch=batch.branch)
    except ObjectDoesNotExist:
        logger.error('No Schedule exists for this branch (' +
                     batch.branch.name +
                     '), so no way to figure out who to email')
        return

    email_host = ConfigCache.get_config_value('email.host')
    conn = mail.get_connection(host=email_host)

    from_address = ConfigCache.get_config_value('email.from')

    if schedule.email_only_failures and len(failures) == 0:
        return

    template = get_template('unit_test_results_email.html')
    c = Context({
        'batch': batch,
        'failures': failures,
        'long_runners': long_runners,
        'long_runner_classes': long_runner_classes
    })

    subject = 'Unit test results for ' + batch.branch.name.upper(
    ) + ' started at ' + str(batch.batch_time)
    from_email, to = from_address, schedule.results_email_address
    text_content = 'Please join the 21st century and get an HTML compatible email client to see the content of this email.'
    html_content = template.render(c)
    msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
    msg.attach_alternative(html_content, "text/html")
    msg.connection = conn
    msg.send(fail_silently=False)
Example #20
0
def stories(request):
    if request.method == u'POST' and request.POST.__contains__('releaseid'):
        release = Release.objects.get(id=request.POST['releaseid'])
        release.stories.clear()
        if request.POST.__contains__('storyId'):
            ids = request.POST.getlist('storyId')
            stories = Story.objects.filter(id__in=ids)
            for s in stories.all():
                if s not in release.stories.all():
                    release.stories.add(s)
        release.save()
        return redirect('/release/' + str(release.id))

    if request.method == u'GET' and request.GET.__contains__('delete'):
        story = Story.objects.get(id=request.GET['delete'])
        objects = DeployableObject.objects.filter(pending_stories=story)
        for object in objects:
            object.pending_stories.remove(story)
            object.save()
        story.delete()

    if request.method == u'GET' and request.GET.__contains__('refresh'):
        rallyintegration.refresh()
        
    releaseid = ''
    in_release = {}
    if request.method == u'GET' and request.GET.__contains__('releaseid'):
        releaseid = request.GET['releaseid']
        if len(releaseid) > 0:
            release = Release.objects.get(id=request.GET['releaseid'])
            for story in release.stories.all():
                in_release[story.id] = True

    sprint = ''
    if request.method == u'GET' and request.GET.__contains__('sprint'):
        sprint = request.GET['sprint']

    sprintList = []
    sprints = Story.objects.values('sprint').filter(sprint__isnull=False).order_by('sprint').distinct()

    for sprintName in sprints:
        if len(sprintName['sprint']) > 0 and not sprintList.__contains__(sprintName['sprint']):
            sprintList.append(sprintName['sprint'])
        
    stories = Story.objects.all()
    if len(sprint) > 0:
        stories = stories.filter(sprint=sprint)
    stories = stories.order_by('sprint', 'rally_id', 'name')
    stories.select_related()
    data = {'stories': stories, 'rally_refresh' : ConfigCache.get_config_value('rally.enabled') == '1', 'releaseid': releaseid, 'in_release': in_release, 'sprintList': sprintList, 'sprint': sprint}
    return render_to_response('stories.html', data, context_instance=RequestContext(request))
def connect():
    rally_user = ConfigCache.get_config_value('rally.login')
    rally_pass = ConfigCache.get_config_value('rally.password')
    
    credentials = requests.auth.HTTPBasicAuth(rally_user, rally_pass)

    proxy_host = ConfigCache.get_config_value('proxy.host')
    proxy_port = ConfigCache.get_config_value('proxy.port')

    if len(proxy_host) > 0 and len(proxy_port) > 0:
        proxydict = {
            "http": "%s:%s" % (proxy_host, proxy_port),
            "https": "%s:%s" % (proxy_host, proxy_port),
        }
    else:
        proxydict = {}

    session = requests.session(headers=RALLY_REST_HEADERS, auth=credentials,
                                    timeout=45.0, proxies=proxydict, config={})    
    
    logger.debug('Logging in with username ' + rally_user)

    return session
def refresh():
        projectList = ConfigCache.get_config_value('rally.pickedprojects')
        if len(projectList) > 0:
            rallyStories = get_stories(projectList.split(';'))
            dbstories = Story.objects.filter(rally_id__in=rallyStories.keys())
            dbStoryMap = {}
            for dbstory in dbstories:
                dbStoryMap[dbstory.rally_id] = dbstory

            for story in rallyStories.values():
                dbstory = story
                if story.rally_id in dbStoryMap:
                    #logger.debug('Updating [' + story.rally_id + ']')
                    # Override with database version if it exists
                    dbstory = dbStoryMap[story.rally_id]
                    dbstory.name = story.name
                #else:
                    #logger.debug('Creating [' + story.rally_id + ']')
                    
                dbstory.sprint = story.sprint
                dbstory.save()
def refresh():
    projectList = ConfigCache.get_config_value('rally.pickedprojects')
    if len(projectList) > 0:
        rallyStories = get_stories(projectList.split(';'))
        dbstories = Story.objects.filter(rally_id__in=rallyStories.keys())
        dbStoryMap = {}
        for dbstory in dbstories:
            dbStoryMap[dbstory.rally_id] = dbstory

        for story in rallyStories.values():
            dbstory = story
            if story.rally_id in dbStoryMap:
                #logger.debug('Updating [' + story.rally_id + ']')
                # Override with database version if it exists
                dbstory = dbStoryMap[story.rally_id]
                dbstory.name = story.name
            #else:
            #logger.debug('Creating [' + story.rally_id + ']')

            dbstory.sprint = story.sprint
            dbstory.save()
Example #24
0
def updateCalendarReleaseEvent(relid, release_name, relDate):
    datestr = relDate.strftime('%m/%d/%Y')
    params = urllib.urlencode({'StartTime': datestr, 'EndTime': datestr, 'Subject': release_name, 'ReleaseId': relid, 'guid': ConfigCache.get_uuid()})
    submitCalendarREST('updaterelease', params)
Example #25
0
def stories(request):
    if request.method == u'POST' and request.POST.__contains__('releaseid'):
        release = Release.objects.get(id=request.POST['releaseid'])
        if request.POST.__contains__('storyId'):
            ids = request.POST.getlist('storyId')
            sprint_name = request.POST['cboSprints']
            
            print 'sprint_name ' + sprint_name
            
            if sprint_name != '':
                for story in release.stories.all():
                    if story.sprint == sprint_name:
                        print 'removing ' + story.name
                        release.stories.remove(story)
            else:
                release.stories.clear()
            
            stories = Story.objects.filter(id__in=ids)
            for s in stories.all():
                if s not in release.stories.all():
                    #this print was causing a unicode issue adding a story, so commented out
                    #print 'adding ' + s.name
                    release.stories.add(s)
        release.save()
        return redirect('/release/' + str(release.id))

    if request.method == u'GET' and request.GET.__contains__('delete'):
        story = Story.objects.get(id=request.GET['delete'])
        objects = DeployableObject.objects.filter(pending_stories=story)
        for object in objects:
            object.pending_stories.remove(story)
            object.save()
        story.delete()

    if request.method == u'GET' and request.GET.__contains__('refresh'):
        if ConfigCache.get_config_value('agilezen.enabled') == '1':
            agilezenintegration.refresh()
        if ConfigCache.get_config_value('rally.enabled') == '1':
            rallyintegration.refresh()
        
    releaseid = ''
    in_release = {}
    if request.method == u'GET' and request.GET.__contains__('releaseid'):
        releaseid = request.GET['releaseid']
        if len(releaseid) > 0:
            release = Release.objects.get(id=request.GET['releaseid'])
            for story in release.stories.all():
                in_release[story.id] = True

    sprint = ''
    if request.method == u'GET' and request.GET.__contains__('sprint'):
        sprint = request.GET['sprint']

    sprintList = []
    sprints = Story.objects.values('sprint').filter(sprint__isnull=False).order_by('sprint').distinct()

    for sprintName in sprints:
        if len(sprintName['sprint']) > 0 and not sprintList.__contains__(sprintName['sprint']):
            sprintList.append(sprintName['sprint'])
        
    stories = Story.objects.all()
    if len(sprint) > 0:
        stories = stories.filter(sprint=sprint)
    stories = stories.order_by('sprint', 'rally_id', 'name')
    # Need to cast the rally_id to prevent duplicate stories from coming over
    # different SQL needed for mySQL and SQLite
    ## MySQL compatible call
    stories = stories.extra(select={'rally_id': 'CAST(rally_id AS SIGNED)'}).extra(order_by = ['rally_id'])
    ## SQLite compatible call
    # stories = stories.extra(select={'rally_id': 'CAST(rally_id AS INTEGER)'}).extra(order_by = ['rally_id'])
    stories.select_related()
    stories_refresh_enabled = (ConfigCache.get_config_value('rally.enabled') == '1') or (ConfigCache.get_config_value('agilezen.enabled') == '1')
    data = {'stories': stories, 'rally_refresh' : stories_refresh_enabled, 'releaseid': releaseid, 'in_release': in_release, 'sprintList': sprintList, 'sprint': sprint}

    return render_to_response('stories.html', data, context_instance=RequestContext(request))
Example #26
0
#
#    You should have received a copy of the GNU General Public License
#    along with StratoSource.  If not, see <http://www.gnu.org/licenses/>.
#
#import json
#import urllib
import requests
import re
from stratosource.admin.management import ConfigCache
from stratosource.admin.models import Story
from stratosource import settings
#from operator import attrgetter
import logging
from django.db import transaction

agilezen_apikey = ConfigCache.get_config_value('agilezen.apikey')
rest_header = {
    "X-Zen-ApiKey": agilezen_apikey,
    "Accept": "application/json;charset=utf-8"
}
logger = logging.getLogger('console')
agileurl = 'https://agilezen.com/'
apiurl = 'api/v1/'


def print_proj_tree(pList):
    for p in pList:
        logger.debug('%d - %s - %s' % (p[u'id'], p[u'name'], p[u'owner']))


def get_page_query_params(page, page_size):
#
#    You should have received a copy of the GNU General Public License
#    along with StratoSource.  If not, see <http://www.gnu.org/licenses/>.
#    
#import json
#import urllib
import requests
import re
from stratosource.admin.management import ConfigCache
from stratosource.admin.models import Story
from stratosource import settings
#from operator import attrgetter
import logging
from django.db import transaction

agilezen_apikey = ConfigCache.get_config_value('agilezen.apikey')
rest_header = {"X-Zen-ApiKey": agilezen_apikey, "Accept" : "application/json;charset=utf-8"}
logger = logging.getLogger('console')    
agileurl = 'https://agilezen.com/'
apiurl = 'api/v1/'

def print_proj_tree(pList):
    for p in pList:
        logger.debug('%d - %s - %s' % (p[u'id'] , p[u'name'] , p[u'owner']))
        
def get_page_query_params(page, page_size):
    return "page=%d&pageSize=%d" % (page, page_size)

def get_projects(leaves):
    logger.debug('Start getting projects')
    projurl = agileurl+apiurl+'projects'  #?' #+ get_page_query_params(1, 200)
Example #28
0
def stories(request):
    if request.method == u'POST' and request.POST.__contains__('releaseid'):
        release = Release.objects.get(id=request.POST['releaseid'])
        release.stories.clear()
        if request.POST.__contains__('storyId'):
            ids = request.POST.getlist('storyId')
            stories = Story.objects.filter(id__in=ids)
            for s in stories.all():
                if s not in release.stories.all():
                    release.stories.add(s)
        release.save()
        return redirect('/release/' + str(release.id))

    if request.method == u'GET' and request.GET.__contains__('delete'):
        story = Story.objects.get(id=request.GET['delete'])
        objects = DeployableObject.objects.filter(pending_stories=story)
        for object in objects:
            object.pending_stories.remove(story)
            object.save()
        story.delete()

    if request.method == u'GET' and request.GET.__contains__('refresh'):
        rallyintegration.refresh()

    releaseid = ''
    in_release = {}
    if request.method == u'GET' and request.GET.__contains__('releaseid'):
        releaseid = request.GET['releaseid']
        if len(releaseid) > 0:
            release = Release.objects.get(id=request.GET['releaseid'])
            for story in release.stories.all():
                in_release[story.id] = True

    sprint = ''
    if request.method == u'GET' and request.GET.__contains__('sprint'):
        sprint = request.GET['sprint']

    sprintList = []
    sprints = Story.objects.values('sprint').filter(
        sprint__isnull=False).order_by('sprint').distinct()

    for sprintName in sprints:
        if len(sprintName['sprint']) > 0 and not sprintList.__contains__(
                sprintName['sprint']):
            sprintList.append(sprintName['sprint'])

    stories = Story.objects.all()
    if len(sprint) > 0:
        stories = stories.filter(sprint=sprint)
    stories = stories.order_by('sprint', 'rally_id', 'name')
    stories.select_related()
    data = {
        'stories': stories,
        'rally_refresh': ConfigCache.get_config_value('rally.enabled') == '1',
        'releaseid': releaseid,
        'in_release': in_release,
        'sprintList': sprintList,
        'sprint': sprint
    }
    return render_to_response('stories.html',
                              data,
                              context_instance=RequestContext(request))