Example #1
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))
Example #2
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 = []
    oneYear = timedelta(days=365)
    oneYearAgo = datetime.now() - oneYear

    if request.method == u"GET" and request.GET.__contains__("history"):
        sprints = Story.objects.values("sprint").filter(sprint__isnull=False).order_by("sprint").distinct()
    else:
        sprints = (
            Story.objects.values("sprint")
            .filter(sprint__isnull=False, date_added__gte=oneYearAgo)
            .order_by("sprint")
            .distinct()
        )

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

    if request.method == u"GET" and request.GET.__contains__("history"):
        stories = Story.objects.all()
    else:
        stories = Story.objects.filter(date_added__gte=oneYearAgo)

    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
    if ConfigCache.get_config_value("agilezen.enabled") == "1":
        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(request, "stories.html", data)
Example #3
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))
Example #4
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 = []
    oneYear = timedelta(days=365)
    oneYearAgo = datetime.now() - oneYear

    if request.method == u'GET' and request.GET.__contains__('history'):
        sprints = Story.objects.values('sprint').filter(
            sprint__isnull=False).order_by('sprint').distinct()
    else:
        sprints = Story.objects.values('sprint').filter(
            sprint__isnull=False,
            date_added__gte=oneYearAgo).order_by('sprint').distinct()

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

    if request.method == u'GET' and request.GET.__contains__('history'):
        stories = Story.objects.all()
    else:
        stories = Story.objects.filter(date_added__gte=oneYearAgo)

    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
    if ConfigCache.get_config_value('agilezen.enabled') == '1':
        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(request, 'stories.html', data)
Example #5
0
    def handle(self, *args, **options):

        rallyintegration.refresh()
Example #6
0
    def handle(self, *args, **options):

        rallyintegration.refresh()
Example #7
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))