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_developer(request, slug): """ Creates (and assigns) a new Developer to current project that Project manager is in. """ if request.method == 'POST': user = request.user project = Project.objects.get(user=user, slug=slug) form = addDevForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect("/" + project.slug) else: return HttpResponse("form not valid") else: return HttpResponseRedirect("/dashboard/")