diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index a08e60db..74d4e51c 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/osinacore/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/__pycache__/views.cpython-310.pyc index c0c1c1a4..5c60a206 100644 Binary files a/osinaweb/osinacore/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/osinacore/views.py b/osinaweb/osinacore/views.py index e7581e2d..37723c6a 100644 --- a/osinaweb/osinacore/views.py +++ b/osinaweb/osinacore/views.py @@ -246,28 +246,26 @@ def save_note(request): return render(request, 'addnote-modal.html') - @login_required def save_project(request): if request.method == 'POST': name = request.POST.get('name') customer_username = request.POST.get('customer') manager_username = request.POST.get('manager') - project_type = request.POST.getlist('project_type') # Use getlist for multi-select fields + project_type = request.POST.getlist('project_type') details = request.POST.get('details') - members_usernames = request.POST.getlist('members') # Use getlist for multi-select fields + members_usernames = request.POST.getlist('members') status = request.POST.get('status') start_date = request.POST.get('start_date') end_date = request.POST.get('end_date') - # Fetch the associated profiles try: customer_profile = CustomerProfile.objects.get(user__username=customer_username) manager_profile = StaffProfile.objects.get(user__username=manager_username) members_profiles = StaffProfile.objects.filter(user__username__in=members_usernames) except (CustomerProfile.DoesNotExist, StaffProfile.DoesNotExist): - - pass + # Handle the case where customer_profile or manager_profile is not found + pass # Create and save the project project = Project( @@ -281,13 +279,18 @@ def save_project(request): ) project.save() - project.project_type.set(project_type) project.members.set(members_profiles) + # Save project requirements + requirements = request.POST.getlist('requirements') # Assuming 'requirements' is the name of your requirement input field + for requirement_content in requirements: + if requirement_content: + requirement = ProjectRequirement(content=requirement_content, project=project) + requirement.save() + return redirect('my-projects') - return render(request, 'createproject.html') @login_required diff --git a/osinaweb/templates/create-project.html b/osinaweb/templates/create-project.html index da835ec3..cd7218de 100644 --- a/osinaweb/templates/create-project.html +++ b/osinaweb/templates/create-project.html @@ -62,15 +62,15 @@