Requirements are now dynamic

main
emile 2 years ago
parent 5c2b4c6eae
commit 7cfc68a208

Binary file not shown.

@ -246,27 +246,25 @@ 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):
# Handle the case where customer_profile or manager_profile is not found
pass
# Create and save the 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

@ -62,15 +62,15 @@
<div class="w-full p-3 border border-gray-300 mt-4 rounded-md">
<div class="w-full mt-2" id="addReqContainer">
<input type="text" placeholder="Requirement"
class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none" required>
<input name="requirements" type="text" placeholder="Requirement"
class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none">
</div>
<!-- THE CLONED CONTAINER -->
<div class="mt-2 hidden" id="addReqContainerTemplate">
<div class="w-full flex flex-col gap-2">
<input type="text" placeholder="Requirement"
class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none" required>
<input name="requirements" type="text" placeholder="Requirement"
class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none">
<button
class="w-full h-[55px] rounded-md bg-gray-300 border-none outline-none shadow-md text-white text-xl cursor-pointer py-2"
id="removeReqButton" type="button">

Loading…
Cancel
Save