예제 #1
0
파일: views.py 프로젝트: bodzio528/bagile
    def get(self, request):
        current_sprint = Sprint.get_current_sprint()

        if 'current_sprint_pk' in request.session:
            session_sprint = Sprint.objects.get(pk=request.session['current_sprint_pk'])
            if session_sprint in Sprint.get_active_sprints():
                current_sprint = session_sprint
            else:
                request.session['current_sprint_pk'] = current_sprint.pk

        from django.http import JsonResponse
        return JsonResponse({'current_sprint': model_to_dict(current_sprint)})
예제 #2
0
def scrumboard_sprint_active_select(context):
    from django.forms import model_to_dict
    from scrumboard.models import Sprint

    active_sprints = [model_to_dict(sprint, fields=['id', 'name']) for sprint in Sprint.get_active_sprints()]

    if 'current_sprint_pk' in context.request.session:
        current_sprint = Sprint.objects.get(pk=context.request.session['current_sprint_pk'])
    else:
        current_sprint = Sprint.get_current_sprint()

    return {'active_sprints': active_sprints,
            'current_sprint': model_to_dict(current_sprint),
            'current_url': context.request.get_full_path()}
예제 #3
0
    def test_returns_active_sprint_as_current_sprint(self):
        sprint = Sprint.objects.create(start_date=self.three_days_ago, end_date=self.in_four_days)

        active_sprints = Sprint.get_active_sprints()

        assert 1 == len(active_sprints)
        assert sprint in active_sprints
예제 #4
0
파일: views.py 프로젝트: bodzio528/bagile
 def get_current_sprint(self):
     if 'pk' in self.kwargs:
         return Sprint.objects.get(id=self.kwargs['pk'])
     elif 'current_sprint_pk' in self.request.session:
         return Sprint.objects.get(id=self.request.session['current_sprint_pk'])
     else:
         return Sprint.get_current_sprint()
예제 #5
0
    def test_returns_single_sprint_if_active_count_is_one(self, active_sprints):
        sprint = Sprint.objects.create(start_date=self.date_now, end_date=self.date_now)
        active_sprints.return_value = [sprint]

        assert sprint == Sprint.get_current_sprint()
예제 #6
0
 def test_returns_none_if_no_sprint_in_database(self):
     assert Sprint.get_current_sprint() is None
예제 #7
0
    def test_returns_none_if_no_sprints_active(self):
        Sprint.objects.create(start_date=self.one_week_ago, end_date=self.three_days_ago)

        assert [] == Sprint.get_active_sprints()
예제 #8
0
 def test_returns_empty_list_if_no_sprint_in_database(self):
     assert [] == Sprint.get_active_sprints()
예제 #9
0
    def test_returns_earlier_started_sprint_if_they_overlap(self, active_sprints):
        sprint1 = Sprint.objects.create(start_date=self.date_now, end_date=self.date_future)
        sprint2 = Sprint.objects.create(start_date=self.date_past, end_date=self.date_now)
        active_sprints.return_value = [sprint1, sprint2]

        assert sprint2 == Sprint.get_current_sprint()
예제 #10
0
    def test_returns_single_objects_if_active_count_is_more_than_one(self, active_sprints):
        sprint1 = Sprint.objects.create(start_date=self.date_past, end_date=self.date_now)
        sprint2 = Sprint.objects.create(start_date=self.date_now, end_date=self.date_future)
        active_sprints.return_value = [sprint1, sprint2]

        assert sprint1 == Sprint.get_current_sprint()
예제 #11
0
파일: views.py 프로젝트: bodzio528/bagile
 def get(self, request):
     from django.http import JsonResponse
     active_sprints = [model_to_dict(sprint, fields=['id', 'name']) for sprint in Sprint.get_active_sprints()]
     return JsonResponse(active_sprints, safe=False)