diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index fa3ec6ff..bb2a1ce5 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/osinacore/__pycache__/models.cpython-310.pyc b/osinaweb/osinacore/__pycache__/models.cpython-310.pyc index 80b0c54f..b16808f2 100644 Binary files a/osinaweb/osinacore/__pycache__/models.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/models.cpython-310.pyc differ diff --git a/osinaweb/osinacore/__pycache__/urls.cpython-310.pyc b/osinaweb/osinacore/__pycache__/urls.cpython-310.pyc index b9f2d71f..33f6f5b9 100644 Binary files a/osinaweb/osinacore/__pycache__/urls.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/osinacore/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/__pycache__/views.cpython-310.pyc index c00748e1..f058def1 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/add/__pycache__/urls.cpython-310.pyc b/osinaweb/osinacore/add/__pycache__/urls.cpython-310.pyc index f36e1851..4f733527 100644 Binary files a/osinaweb/osinacore/add/__pycache__/urls.cpython-310.pyc and b/osinaweb/osinacore/add/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc index 725635fb..fd644263 100644 Binary files a/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/osinacore/add/urls.py b/osinaweb/osinacore/add/urls.py index bd222b07..f5aefc7d 100644 --- a/osinaweb/osinacore/add/urls.py +++ b/osinaweb/osinacore/add/urls.py @@ -21,6 +21,7 @@ urlpatterns = [ path('epic//', views.add_epic, name='addepic'), path('note/', views.add_note_modal, name='addnotemodal'), path('dailyreport/', views.add_daily_report, name='adddailyreport'), + path('department/', views.add_department_modal, name='adddepartmentmodal'), path('projecttype/', views.add_projecttype_modal, name='addprojecttypemodal'), path('staffposition/', views.add_staffposition_modal, name='addstaffpositionmodal'), path('businesstype/', views.add_businesstype_modal, name='addbusinesstypemodal'), diff --git a/osinaweb/osinacore/add/views.py b/osinaweb/osinacore/add/views.py index 80127020..f6c01766 100644 --- a/osinaweb/osinacore/add/views.py +++ b/osinaweb/osinacore/add/views.py @@ -494,27 +494,50 @@ def add_daily_report(request): return render(request, 'add_templates/add-daily-report.html', context) + +@staff_login_required +def add_department_modal(request, *args, **kwargs): + if request.method == 'POST': + name = request.POST.get('name') + department = Department( + name = name, + + ) + department.save() + + # Reload the parent page + return HttpResponse('') + return render(request, 'add_templates/add-department-modal.html') + + @staff_login_required def add_projecttype_modal(request, *args, **kwargs): + departments = Department.objects.all().order_by('name') if request.method == 'POST': name = request.POST.get('name') projecttype = ProjectType( name = name, + department = get_object_or_404(Department, id= request.POST.get('department')) ) projecttype.save() # Reload the parent page return HttpResponse('') - return render(request, 'add_templates/add-projecttype-modal.html') + context ={ + 'departments': departments, + } + return render(request, 'add_templates/add-projecttype-modal.html', context) @staff_login_required def add_staffposition_modal(request): + departments = Department.objects.all().order_by('name') if request.method == 'POST': name = request.POST.get('name') staffposition = StaffPosition( name = name, + department = get_object_or_404(Department, id= request.POST.get('department')) ) @@ -522,7 +545,10 @@ def add_staffposition_modal(request): # Reload the parent page return HttpResponse('') - return render(request, 'add_templates/add-staffposition-modal.html') + context ={ + 'departments': departments, + } + return render(request, 'add_templates/add-staffposition-modal.html', context) @staff_login_required diff --git a/osinaweb/osinacore/edit/__pycache__/urls.cpython-310.pyc b/osinaweb/osinacore/edit/__pycache__/urls.cpython-310.pyc index d35e37c3..52e5e308 100644 Binary files a/osinaweb/osinacore/edit/__pycache__/urls.cpython-310.pyc and b/osinaweb/osinacore/edit/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/osinacore/edit/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/edit/__pycache__/views.cpython-310.pyc index a8ff0648..6cbbdc3b 100644 Binary files a/osinaweb/osinacore/edit/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/edit/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/osinacore/edit/urls.py b/osinaweb/osinacore/edit/urls.py index 87dd8d29..c8ef0e2f 100644 --- a/osinaweb/osinacore/edit/urls.py +++ b/osinaweb/osinacore/edit/urls.py @@ -8,14 +8,15 @@ urlpatterns = [ path('business//', views.edit_business, name='editbusiness'), path('staff//', views.edit_staff, name='editstaff'), path('project//', views.edit_project, name='editproject'), - path('task/', views.edit_task, name='edittask'), - path('task-status/', views.edit_task_status_modal, name='edittaskstatusmodal'), + path('task//', views.edit_task, name='edittask'), + path('task-status//', views.edit_task_status_modal, name='edittaskstatusmodal'), path('epic/', views.edit_epic, name='editepic'), - path('projecttype/', views.edit_project_type, name='editprojecttype'), - path('staffposition/', views.edit_staff_position, name='editstaffposition'), - path('businesstype/', views.edit_business_type, name='editbusinesstype'), - path('reference/', views.edit_reference, name='editreference'), - path('tag/', views.edit_tag, name='edittag'), + path('department//', views.edit_department, name='editdepartment'), + path('projecttype//', views.edit_project_type, name='editprojecttype'), + path('staffposition//', views.edit_staff_position, name='editstaffposition'), + path('businesstype//', views.edit_business_type, name='editbusinesstype'), + path('reference//', views.edit_reference, name='editreference'), + path('tag//', views.edit_tag, name='edittag'), #Mark Points diff --git a/osinaweb/osinacore/edit/views.py b/osinaweb/osinacore/edit/views.py index e62aed19..eaa5275f 100644 --- a/osinaweb/osinacore/edit/views.py +++ b/osinaweb/osinacore/edit/views.py @@ -285,28 +285,50 @@ def edit_epic(request, *args, **kwargs): +@staff_login_required +def edit_department(request, department_id): + + department = get_object_or_404(Department, id=department_id) + + if request.method == 'POST': + department.name = request.POST.get('name') + department.save() + + return redirect('departments') + + return render(request, 'edit_templates/edit-department.html', {'department': department}) + + @staff_login_required def edit_project_type(request, projecttype_id): projecttype = get_object_or_404(ProjectType, id=projecttype_id) + departments = Department.objects.all().order_by('name') if request.method == 'POST': projecttype.name = request.POST.get('name') + projecttype.department = get_object_or_404(Department, id=request.POST.get('department')) projecttype.save() return redirect('projecttypes') - return render(request, 'edit_templates/edit-project-type.html', {'projecttype': projecttype}) + return render(request, 'edit_templates/edit-project-type.html', {'projecttype': projecttype,'departments': departments}) @staff_login_required -def edit_staff_position(request): +def edit_staff_position(request, staffposition_id): + staffposition = get_object_or_404(StaffPosition, id=staffposition_id) + departments = Department.objects.all().order_by('name') + + if request.method == 'POST': + staffposition.name = request.POST.get('name') + staffposition.department = get_object_or_404(Department, id=request.POST.get('department')) + staffposition.save() - context = { + return redirect('staffpositions') - } - return render(request, 'edit_templates/edit-staff-position.html', context) + return render(request, 'edit_templates/edit-staff-position.html', {'staffposition': staffposition,'departments': departments}) diff --git a/osinaweb/osinacore/migrations/0076_alter_reference_date.py b/osinaweb/osinacore/migrations/0076_alter_reference_date.py new file mode 100644 index 00000000..5ce6c16e --- /dev/null +++ b/osinaweb/osinacore/migrations/0076_alter_reference_date.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.5 on 2024-04-27 19:36 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0075_remove_ticketattachment_ticket_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='reference', + name='date', + field=models.DateField(), + ), + ] diff --git a/osinaweb/osinacore/migrations/__pycache__/0076_alter_reference_date.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0076_alter_reference_date.cpython-310.pyc new file mode 100644 index 00000000..0ee882dd Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0076_alter_reference_date.cpython-310.pyc differ diff --git a/osinaweb/osinacore/models.py b/osinaweb/osinacore/models.py index f369d091..81949334 100644 --- a/osinaweb/osinacore/models.py +++ b/osinaweb/osinacore/models.py @@ -14,13 +14,10 @@ from datetime import timedelta class Reference(models.Model): name = models.CharField(max_length=50) - date = models.CharField(max_length=200) + date = models.DateField() def __str__(self): return self.name - def formatted_date(self): - # Assuming start_date is stored as "day-month-year" - parts = self.date.split('-') - return f"{parts[2]}-{parts[1]}-{parts[0]}" + diff --git a/osinaweb/osinacore/templates/add_templates/add-department-modal.html b/osinaweb/osinacore/templates/add_templates/add-department-modal.html new file mode 100644 index 00000000..645485f9 --- /dev/null +++ b/osinaweb/osinacore/templates/add_templates/add-department-modal.html @@ -0,0 +1,32 @@ +{% load static %} + + + + + + + Osina + + + + + + + +
+ {% csrf_token %} +

Add Department

+ +
+ +
+ +
+ +
+
+ + \ No newline at end of file diff --git a/osinaweb/osinacore/templates/add_templates/add-projecttype-modal.html b/osinaweb/osinacore/templates/add_templates/add-projecttype-modal.html index 0ee4df1d..436a7e2e 100644 --- a/osinaweb/osinacore/templates/add_templates/add-projecttype-modal.html +++ b/osinaweb/osinacore/templates/add_templates/add-projecttype-modal.html @@ -22,6 +22,18 @@ class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none mt-4" required> + +
+ + +
+
+ + +
+ + +
+
+ + + + + + + + + + + + +{% endblock content %} \ No newline at end of file diff --git a/osinaweb/osinacore/templates/edit_templates/edit-project-type.html b/osinaweb/osinacore/templates/edit_templates/edit-project-type.html index a3b9c4af..151d4c8e 100644 --- a/osinaweb/osinacore/templates/edit_templates/edit-project-type.html +++ b/osinaweb/osinacore/templates/edit_templates/edit-project-type.html @@ -19,6 +19,16 @@ +
+ + +
+
diff --git a/osinaweb/osinacore/templates/edit_templates/edit-reference.html b/osinaweb/osinacore/templates/edit_templates/edit-reference.html index ef7c3755..f5101b4c 100644 --- a/osinaweb/osinacore/templates/edit_templates/edit-reference.html +++ b/osinaweb/osinacore/templates/edit_templates/edit-reference.html @@ -20,7 +20,7 @@
-
diff --git a/osinaweb/osinacore/templates/edit_templates/edit-staff-position.html b/osinaweb/osinacore/templates/edit_templates/edit-staff-position.html index aa507de8..12563226 100644 --- a/osinaweb/osinacore/templates/edit_templates/edit-staff-position.html +++ b/osinaweb/osinacore/templates/edit_templates/edit-staff-position.html @@ -8,14 +8,24 @@ Edit Staff Position -
+ {% csrf_token %}
- +
+ + +
+
diff --git a/osinaweb/osinacore/templates/listing_pages/departments.html b/osinaweb/osinacore/templates/listing_pages/departments.html new file mode 100644 index 00000000..fda1ac24 --- /dev/null +++ b/osinaweb/osinacore/templates/listing_pages/departments.html @@ -0,0 +1,89 @@ +{% extends "main.html" %} +{%load static%} +{% block content %} + + +
+
+

Departments

+ + +
+
+
+ + +
+
+
+ +
+
+ +
+ + + + + + + + + + + + + {% for department in departments %} + + + + + + {% endfor %} + +
+ Business Type + + Actions +
+

{{department.name}}

+
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+ + + + + + + +{% endblock content %} \ No newline at end of file diff --git a/osinaweb/osinacore/templates/listing_pages/project-types.html b/osinaweb/osinacore/templates/listing_pages/project-types.html index 4080dff0..c84926e2 100644 --- a/osinaweb/osinacore/templates/listing_pages/project-types.html +++ b/osinaweb/osinacore/templates/listing_pages/project-types.html @@ -37,6 +37,10 @@ class="px-6 py-3 text-sm font-medium text-gray-500 uppercase border-r border-gray-300 whitespace-nowrap"> Project Type + + Department + Actions @@ -51,7 +55,9 @@

{{type.name}}

- + +

{{type.department.name}}

+
diff --git a/osinaweb/osinacore/templates/listing_pages/references.html b/osinaweb/osinacore/templates/listing_pages/references.html index b629524e..e1acd6aa 100644 --- a/osinaweb/osinacore/templates/listing_pages/references.html +++ b/osinaweb/osinacore/templates/listing_pages/references.html @@ -57,7 +57,7 @@ -

{{reference.formatted_date}}

+

{{reference.date}}

diff --git a/osinaweb/osinacore/templates/listing_pages/staff-positions.html b/osinaweb/osinacore/templates/listing_pages/staff-positions.html index 10d8dfd9..37cd6bf3 100644 --- a/osinaweb/osinacore/templates/listing_pages/staff-positions.html +++ b/osinaweb/osinacore/templates/listing_pages/staff-positions.html @@ -38,6 +38,10 @@ class="px-6 py-3 text-sm font-medium text-gray-500 uppercase border-r border-gray-300 whitespace-nowrap"> Position + + Department + Actions @@ -52,10 +56,12 @@

{{position.name}}

- + +

{{position.department.name}}

+