|
|
@@ -1,4 +1,4 @@
|
|
|
-from datetime import datetime
|
|
|
+from datetime import datetime, timedelta
|
|
|
|
|
|
from django.contrib.auth import logout, login, update_session_auth_hash
|
|
|
from django.contrib.auth.decorators import login_required
|
|
|
@@ -13,7 +13,7 @@ from notifications.models import Notification
|
|
|
from notifications.signals import notify
|
|
|
|
|
|
from main.forms import StoryForm, EpicForm, RegisterForm, ProfileForm, \
|
|
|
- CommentForm, SprintForm
|
|
|
+ CommentForm, SprintForm, NewSprintForm
|
|
|
from main.models import Story, Epic, Sprint, Comment, Project
|
|
|
|
|
|
|
|
|
@@ -72,11 +72,40 @@ def backlog_editor(request):
|
|
|
|
|
|
return render(request, 'backlog_editor.html', {'epics': epics, 'closed': closed})
|
|
|
|
|
|
+def sprint_new(request):
|
|
|
+ if request.method == 'POST':
|
|
|
+ form = NewSprintForm(request.POST)
|
|
|
+ if form.is_valid():
|
|
|
+ form.save()
|
|
|
+ return redirect("sprint_end")
|
|
|
+ else:
|
|
|
+ sprint = Sprint()
|
|
|
+
|
|
|
+ current_sprint = Sprint.current()
|
|
|
+ sprint.number = current_sprint.number + 1
|
|
|
+
|
|
|
+ new_start = current_sprint.date_end + timedelta(days=1)
|
|
|
+ while new_start.weekday() >= 5:
|
|
|
+ new_start = new_start + timedelta(days=1)
|
|
|
+
|
|
|
+ new_end = new_start + timedelta(days=13)
|
|
|
+ while new_end.weekday() >= 5:
|
|
|
+ new_end = new_end - timedelta(days=1)
|
|
|
+
|
|
|
+ sprint.date_start = new_start.strftime('%d/%m/%Y')
|
|
|
+ sprint.date_end = new_end.strftime('%d/%m/%Y')
|
|
|
+
|
|
|
+ form = NewSprintForm(instance=sprint)
|
|
|
+ return render(request, 'sprint_new.html', {'form': form })
|
|
|
+
|
|
|
def sprint_end(request):
|
|
|
|
|
|
current_sprint = Sprint.current()
|
|
|
next_sprint = Sprint.next()
|
|
|
|
|
|
+ if not next_sprint:
|
|
|
+ return redirect("sprint_new")
|
|
|
+
|
|
|
if request.method == 'POST':
|
|
|
current_sprint.retro = request.POST["retro"]
|
|
|
current_sprint.closed = True
|
|
|
@@ -314,7 +343,7 @@ def report_activity(request):
|
|
|
epics_activity[epic]["sixmonths"] = 0
|
|
|
|
|
|
current = True
|
|
|
- for sprint in Sprint.objects.filter(date_end__lt = datetime.today()).order_by('-date_start')[:12]:
|
|
|
+ for sprint in Sprint.objects.filter(date_end__lt = datetime.datetime.today()).order_by('-date_start')[:12]:
|
|
|
for story in sprint.stories.all():
|
|
|
if not story.epic:
|
|
|
continue
|