main
emile 1 year ago
parent 51afebf4ac
commit 83e899f2ac

Binary file not shown.

@ -1146,14 +1146,67 @@ def save_dailyreport(request):
# EDIT TEMPLATES
@login_required
def edit_project(request, *args, **kwargs):
def edit_project(request, project_id):
project = get_object_or_404(Project, project_id=project_id)
staffs = StaffProfile.objects.all().order_by('-id')
current_manager = project.manager
customers = CustomerProfile.objects.all().order_by('-id')
current_client = project.customer
types = ProjectType.objects.all().order_by('-id')
if request.method == 'POST':
project.name = request.POST.get('name')
new_customer_id = request.POST.get('customer')
customer = get_object_or_404(CustomerProfile, id=new_customer_id)
project.customer = customer
new_manager_id = request.POST.get('manager')
manager = get_object_or_404(StaffProfile, id=new_manager_id)
project.manager = manager
members_ids = request.POST.getlist('members')
members_profiles = StaffProfile.objects.filter(id__in=members_ids)
project.members.set(members_profiles)
project.status = request.POST.get('status')
type_ids = request.POST.getlist('types')
types = ProjectType.objects.filter(id__in=type_ids)
project.project_type.set(type_ids)
project.details = request.POST.get('details')
project.start_date = request.POST.get('start_date')
project.end_date = request.POST.get('end_date')
project.save()
return redirect('detailed-project', project_id=project.project_id)
context = {
'project' : project,
'staffs' : staffs,
'current_manager' : current_manager,
'customers' : customers,
'current_client' : current_client,
'types' : types,
}
return render(request, 'edit_pages/edit-project.html', context)
@login_required
def edit_epic(request, *args, **kwargs):
@ -1164,10 +1217,14 @@ def edit_epic(request, *args, **kwargs):
@login_required
def edit_task(request, *args, **kwargs):
def edit_task(request, task_id):
task = get_object_or_404(Task, task_id=task_id)
projects = Project.objects.all().order_by('-id')
context = {
'task' :task,
'projects' : projects,
}
return render(request, 'edit_pages/edit-task.html', context)

@ -105,9 +105,9 @@ urlpatterns = [
#Edit Pages
path('edit-project/', views.edit_project, name='editproject'),
path('edit-project/<str:project_id>/', views.edit_project, name='editproject'),
path('edit-epic/', views.edit_epic, name='editepic'),
path('edit-task/', views.edit_task, name='edittask'),
path('edit-task/<str:task_id>', views.edit_task, name='edittask'),
path('edit-customer/<str:customer_id>/', views.edit_customer, name='editcustomer'),
path('edit-business/<str:business_id>/', views.edit_business, name='editbusiness'),
path('edit-staff/<str:staff_id>/', views.edit_staff, name='editstaff'),

@ -120,7 +120,7 @@
<button
class="w-fit text-base px-3 py-2 bg-red-500 text-white outline-none border border-red-500 rounded-md cursor-pointer hover:bg-white hover:text-red-500">Delete
Project</button>
<a href="{% url 'editproject' %}">
<a href="{% url 'editproject' project.project_id %}">
<button
class="w-fit text-base px-3 py-2 bg-blue-500 text-white outline-none border border-blue-500 rounded-md cursor-pointer hover:bg-white hover:text-blue-500">Edit
Project</button>

@ -76,7 +76,7 @@
<button
class="w-fit text-base px-3 py-2 bg-red-500 text-white outline-none border border-red-500 rounded-md cursor-pointer hover:bg-white hover:text-red-500">Delete
Task</button>
<a href="{% url 'edittask' %}">
<a href="{% url 'edittask' task.task_id %}">
<button
class="w-fit text-base px-3 py-2 bg-blue-500 text-white outline-none border border-blue-500 rounded-md cursor-pointer hover:bg-white hover:text-blue-500">Edit
Task</button>

@ -8,125 +8,106 @@
Edit Project
</h1>
<form class="w-full flex flex-col gap-3 justify-center items-center mt-5" method="POST"
action="{% url 'save_project' %}">
<form class="w-full flex flex-col gap-3 justify-center items-center" method="POST"
action="{% url 'editproject' project.project_id %}">
{% csrf_token %}
<input required name="name" type="text" placeholder="Project Name"
value="Winabig"
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md">
<select required name="customer" id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500">
<option value="" disabled>Clients</option>
<option value="" selected>Nataly</option>
{% for customer in customers %}
<option value="{{customer.user.username}}">{{customer.first_name}} {{customer.last_name}}</option>
{% endfor %}
</select>
<select required name="manager" id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500">
<option value="" disabled>Project Manager</option>
<option value="" selected>Emile</option>
{% for staff in staffs %}
<option value="{{staff.user.username}}">{{staff.first_name}} {{staff.last_name}}</option>
{% endfor %}
</select>
<select required name="members" id=""
class="w-full h-[100px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500"
multiple>
<option value="" disabled>Member(s)</option>
<option value="" selected>Salim</option>
{% for staff in staffs %}
<option value="{{staff.user.username}}">{{staff.first_name}} {{staff.last_name}}</option>
{% endfor %}
</select>
<select required name="status" id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500">
<option value="" disabled>Status</option>
<option value="Pending">Pending</option>
<option value="Active" selected>Active</option>
<option value="Completed">Completed</option>
<option value="Cancelled">Cancelled</option>
</select>
<select required name="members" id=""
class="w-full h-[100px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500"
multiple>
<option value="" disabled>Project Type</option>
<option value="" selected>Development</option>
{%for type in project_types %}
<option value="{{type.id}}">{{type.name}}</option>
{% endfor %}
</select>
<textarea required name="details" type="text" placeholder="Project Details" rows="5" cols="5"
class="w-full py-3 px-3 border border-gray-300 outline-none rounded-md resize-none">Lorem ipsum dolor sit amet consectetur adipisicing elit. Illum magnam ea temporibus commodi aspernatur culpa totam similique voluptate veritatis? Odit, excepturi? Itaque suscipit libero iure corrupti consequatur soluta expedita quod?
</textarea>
<div class="w-full p-3 border border-gray-300 mt-4 rounded-md">
<div class="w-full mt-2" id="addReqContainer">
<input name="requirements" type="text" placeholder="Requirement"
value="One"
class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none">
<div class="w-full flex flex-col gap-3 justify-center items-center mt-5">
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Name:</label>
<input required name="name" type="text" placeholder="Name"
value="{{project.name}}"
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md mt-2">
</div>
<!-- THE CLONED CONTAINER -->
<div class="mt-2 hidden" id="addReqContainerTemplate">
<div class="w-full flex flex-col gap-2">
<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">
<i class="fa fa-minus"></i>
</button>
</div>
</div>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Client:</label>
<select required name="customer" id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-2">
<option value="" disabled>Clients</option>
{% for customer in customers %}
<option value="{{customer.id}}" {% if customer.id == current_client.id %} selected {%endif%}>{{customer.user.first_name}} {{customer.user.last_name}}</option>
{% endfor %}
</select>
</div>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Project Manager:</label>
<select required name="manager" id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-2">
<option value="" disabled>Project Manager</option>
{% for staff in staffs %}
<option value="{{staff.id}}" {% if staff.id == current_manager.id %} selected {%endif%}>{{staff.user.first_name}} {{staff.user.last_name}}</option>
{% endfor %}
</select>
</div>
<button
class="w-full h-[55px] rounded-md bg-gray-400 border-none outline-none shadow-md text-white text-xl cursor-pointer py-2 mt-2"
id="addReqButton" type="button">
<i class="fa fa-plus"></i>
</button>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Member(s):</label>
<select required name="members" id=""
class="w-full h-[100px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-2"
multiple>
{% for staff in staffs %}
{% if staff in project.members.all %}
<option value="{{staff.id}}" selected>{{staff.user.first_name}} {{staff.user.last_name}}</option>
{% else %}
<option value="{{staff.id}}">{{staff.user.first_name}} {{staff.user.last_name}}</option>
{% endif %}
{% endfor %}
</select>
</div>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Status:</label>
<select required name="status" id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-2">
<option value="" disabled>Select Status</option>
<option value="Pending" {% if project.status == 'Pending' %} selected {%endif%}>Pending</option>
<option value="Active" {% if project.status == 'Active' %} selected {%endif%}>Active</option>
<option value="Completed" {% if project.status == 'Completed' %} selected {%endif%}>Completed</option>
<option value="Cancelled" {% if project.status == 'Cancelled' %} selected {%endif%}>Cancelled</option>
</select>
</div>
<script>
const addReqButton = document.getElementById("addReqButton");
const addReqContainerTemplate = document.getElementById("addReqContainerTemplate");
const addReqContainer = document.getElementById("addReqContainer");
addReqButton.addEventListener("click", function () {
// Clone the template and remove the "hidden" class
const newContainer = addReqContainerTemplate.cloneNode(true);
newContainer.classList.remove("hidden");
// Add an event listener to the new container's remove button
const removeReqButton = newContainer.querySelector("#removeReqButton");
removeReqButton.addEventListener("click", function () {
// Remove the clicked container when the remove button is clicked
newContainer.remove();
});
addReqContainer.appendChild(newContainer);
});
</script>
<div class="w-full">
<label class="text-gray-500">Start Date:</label>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Type(s):</label>
<select required name="types" id=""
class="w-full h-[100px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-2"
multiple>
{%for type in types %}
{% if type in project.project_type.all %}
<option value="{{type.id}}" selected>{{type.name}}</option>
{%else%}
<option value="{{type.id}}" >{{type.name}}</option>
{% endif %}
{% endfor %}
</select>
</div>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Description:</label>
<textarea required name="details" type="text" placeholder="Project Details" rows="5" cols="5"
class="w-full py-3 px-3 border border-gray-300 outline-none rounded-md resize-none mt-2">Lorem ipsum dolor sit amet consectetur adipisicing elit. Illum magnam ea temporibus commodi aspernatur culpa totam similique voluptate veritatis? Odit, excepturi? Itaque suscipit libero iure corrupti consequatur soluta expedita quod?
</textarea>
</div>
</div>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Start Date:</label>
<input required name="start_date" type="date" id="date" name="date"
value="2023-09-22"
class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none mt-1">
class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none mt-2">
</div>
<div class="w-full">
<label class="text-gray-500">End Date:</label>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">End Date:</label>
<input required name="end_date" type="date" id="date" name="date"
value="2023-10-22"
class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none mt-1">
class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none mt-2">
</div>
<div class="w-full flex justify-center items-center mt-3">
<button type="submit"
class="w-fit py-1 px-3 bg-blue-500 rounded-md outline-none text-white border border-blue-500 text-xl cursor-pointer hover:bg-white hover:text-blue-500">Save</button>

@ -11,97 +11,89 @@
<form class="w-full flex flex-col gap-3 justify-center items-center mt-5" method="POST"
action="{% url 'save_task' %}">
{% csrf_token %}
<input required name="name" type="text" placeholder="Task Name"
value="Task1"
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md">
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Name:</label>
<input required name="name" type="text" placeholder="Task Name"
value="{{task.name}}"
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md mt-2">
</div>
<select required name="project" id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500">
<option disabled>Select Project</option>
<option selected>Winabig</option>
<option value="{{project.id}}">{{project.name}}</option>
</select>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Project:</label>
<select required name="project" id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-2">
{% for project in projects %}
<option value="{{project.id}}" {% if project.id == task.project.id %} selected {% endif %}>{{project.name}}</option>
{% endfor %}
</select>
</div>
<select required name="epic" id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500">
<option value="" disabled>Select Epic</option>
<option value="" selected>Epic1</option>
{% for epic in epics_of_my_project %}
<option value="{{epic.id}}">{{epic.title}}</option>
{% endfor %}
</select>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Epic:</label>
<select required name="epic" id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-2">
<option value="" disabled>Select Epic</option>
<option value="" selected>Epic1</option>
{% for epic in epics_of_my_project %}
<option value="{{epic.id}}">{{epic.title}}</option>
{% endfor %}
</select>
</div>
<select required name="status" id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500">
<option value="" disabled>Status</option>
<option value="Open" selected>Open</option>
<option value="Working On">Working On</option>
<option value="Closed">Closed</option>
</select>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Status:</label>
<select required name="status" id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-2">
<option value="" disabled>Select Status</option>
<option value="Open" selected>Open</option>
<option value="Working On">Working On</option>
<option value="Closed">Closed</option>
</select>
</div>
<select name="assigned_to" required id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500">
<option value="" disabled>Assigned To</option>
<option value="" selected>Nataly</option>
{% for staff in staffs %}
<option value="{{staff.id}}">{{staff.first_name}} {{staff.last_name}}</option>
{% endfor %}
</select>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Assigned To:</label>
<select name="assigned_to" required id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-2">
<option value="" disabled>Assigned To</option>
<option value="" selected>Nataly</option>
{% for staff in staffs %}
<option value="{{staff.id}}">{{staff.first_name}} {{staff.last_name}}</option>
{% endfor %}
</select>
</div>
<textarea required name="description" type="text" placeholder="Task Description" rows="5" cols="5"
class="w-full py-3 px-3 border border-gray-300 outline-none rounded-md resize-none">Lorem ipsum dolor sit amet consectetur adipisicing elit. Ab laboriosam cum temporibus itaque vel atque, obcaecati voluptates porro dolorem, magnam quidem nemo corrupti ullam dicta excepturi pariatur inventore voluptatem beatae!
</textarea>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Description:</label>
<textarea required name="description" type="text" placeholder="Task Description" rows="5" cols="5"
class="w-full py-3 px-3 border border-gray-300 outline-none rounded-md resize-none mt-2">Lorem ipsum dolor sit amet consectetur adipisicing elit. Ab laboriosam cum temporibus itaque vel atque, obcaecati voluptates porro dolorem, magnam quidem nemo corrupti ullam dicta excepturi pariatur inventore voluptatem beatae!
</textarea>
</div>
<div class="w-full">
<label class="text-gray-500">Extra:</label>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Extra:</label>
<select required name="extra" id=""
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-1">
class="w-full h-[50px] py-1 px-3 border border-gray-300 outline-none rounded-md text-gray-500 mt-2">
<option value="True">Yes</option>
<option value="False" selected>No</option>
</select>
</div>
<div class="w-full">
<label class="text-gray-500">Start Date:</label>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">Start Date:</label>
<input required name="start_date" type="date" id="date" name="date"
value="2023-09-22"
class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none mt-1">
class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none mt-2">
</div>
<div class="w-full">
<label class="text-gray-500">End Date:</label>
<div class="w-full mt-4">
<label class="text-gray-500 text-xl">End Date:</label>
<input required name="end_date" type="date" id="date" name="date"
value="2023-09-22"
class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none mt-1">
</div>
<div class="inbox-box border border-gray-300 py-1 px-3 w-full rounded-md">
<div class="flex items-center justify-between">
<input name="cv" type="file" id="actual-btn" accept=".pdf,.docx" hidden multiple />
<span id="file-name" class="text-gray-500 text-base focus:outline-none outline-none">Upload
Document(s)</span>
<label for="actual-btn"
class="bg-transparent text-gray-500 border border-white py-2 h-14 cursor-pointer flex items-center"><i
class="fa fa-upload"></i></label>
</div>
class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none mt-2">
</div>
<!-- WHEN THE USER CHOOSE A FILE THE NAME OF THE FILE WILL APPEAR IN THE SPAN -->
<script>
const fileInput = document.getElementById('actual-btn');
const fileNameSpan = document.getElementById('file-name');
fileInput.addEventListener('change', (event) => {
const selectedFiles = event.target.files;
if (selectedFiles.length > 0) {
const fileNames = Array.from(selectedFiles).map(file => file.name).join(', ');
fileNameSpan.textContent = fileNames;
} else {
fileNameSpan.textContent = 'Upload Documents (PDF, docx)';
}
});
</script>
<div class="w-full flex justify-center items-center mt-3">
<button type="submit"

@ -128,7 +128,7 @@
<button class="p-2 border border-gray-200 text-base h-[70px] bg-gray-100 text-gray-500 deleteTaskButton"
data-modal-url="{% url 'deletetask' %}">Delete</button>
<a href="{% url 'edittask' %}">
<a href="{% url 'edittask' task.task_id %}">
<button
class="w-full p-2 border border-gray-200 text-base h-[70px] bg-gray-100 text-gray-500">Edit</button>
</a>

@ -198,7 +198,7 @@
class="p-2 border border-gray-200 text-base h-[70px] bg-gray-100 text-gray-500 deleteTaskButton"
data-modal-url="{% url 'deletetask' %}">Delete</button>
<a href="{% url 'edittask' %}">
<a href="{% url 'edittask' task.task_id %}">
<button
class="w-full p-2 border border-gray-200 text-base h-[70px] bg-gray-100 text-gray-500">Edit</button>
</a>
@ -345,7 +345,7 @@
class="p-2 border border-gray-200 text-sm h-[70px] bg-gray-100 text-gray-500 deleteTaskButton"
data-modal-url="{% url 'deletetask' %}">Delete</button>
<a href="{% url 'edittask' %}">
<a href="{% url 'edittask' task.task_id %}">
<button
class="w-full p-2 border border-gray-200 text-sm h-[70px] bg-gray-100 text-gray-500">Edit</button>
</a>

@ -158,7 +158,7 @@
<i class="fa fa-eye"></i>
</div>
</a>
<a href="{% url 'editproject' %}">
<a href="{% url 'editproject' project.project_id %}">
<div class="text-[15px] text-blue-500 cursor-pointer">
<i class="fa fa-edit"></i>
</div>

@ -217,7 +217,7 @@
class="p-2 border border-gray-200 text-base h-[70px] bg-gray-100 text-gray-500 deleteTaskButton"
data-modal-url="{% url 'deletetask' %}">Delete</button>
<a href="{% url 'edittask' %}">
<a href="{% url 'edittask' task.task_id %}">
<button
class="w-full p-2 border border-gray-200 text-base h-[70px] bg-gray-100 text-gray-500">Edit</button>
</a>

Loading…
Cancel
Save