def Project_view(request, slug): """ A Project view with User stories, tasks, iterations, their time, etc. """ domain = Site.objects.get_current().domain user = request.user project = Project.objects.get(user=user, slug=slug) title = project.project_title description = project.project_description iterations = Iteration.objects.filter(user = user, project = project).order_by('-date') stories = Story.objects.filter(user = user, project = project).order_by('-date') form = IterationForm taskForm = TaskForm(request.POST, project = project) addDev = addDevForm(request.POST) if request.method == 'POST': form = IterationForm if form.is_valid(): user = request.user project = Project.objects.get(user=user, slug=slug) new_iteration = Iteration(user = request.user, duration = form.cleaned_data['duration'], project = Project.objects.get(user=user, slug=slug), name = form.cleaned_data['name'],) new_iteration.save() return HttpResponseRedirect("/dashboard/") try: developers = Dev.objects.filter(user = request.user, project = project) return render(request, "project.html", {"title" : title, "description" : description, "iterations" : iterations, "developers" : developers, "domain" : domain, "form" : form, "stories" : stories, "taskForm" : taskForm, "addDev" : addDev}) except Developer.DoesNotExist: return render(request, "project.html", {"title" : title, "description" : description, "iterations" : iterations, "domain" : domain, "form" : form, "stories" : stories, "taskForm" : taskForm, "addDev" : add})
def New_project(request): if request.method == 'POST': user = request.user new_project = Project(project_title = request.POST['project_title'], project_description = request.POST['project_description'], user = user) new_project.save() #creating a new Iteration because each project has to have "Iteration zero": new_iteration = Iteration(user = user, project = new_project, name = "Iteration zero") new_iteration.save() return HttpResponseRedirect("/dashboard/") else: return HttpResponseRedirect("/dashboard/")
def New_iteration(request, slug): form = IterationForm() user = request.user project = Project.objects.get(user=user, slug=slug) domain = Site.objects.get_current().domain if request.method == 'POST': form = IterationForm(request.POST) errors = form.errors if form.is_valid(): user = request.user project = Project.objects.get(user=user, slug=slug) new_iteration = Iteration(user = request.user, duration = form.cleaned_data['duration'], project = Project.objects.get(user=user, slug=slug), name = form.cleaned_data['name']) new_iteration.save() return HttpResponseRedirect(domain + slug) else: return render(request, "new_iteration.html", {"errors" : errors, "form" : form}) return render(request, "new_iteration.html", {"form" : form, "project" : project, "user" : user})