diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index a568af4d..051849d6 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/input.css b/osinaweb/input.css index f3ffb053..c9028ebf 100644 --- a/osinaweb/input.css +++ b/osinaweb/input.css @@ -148,7 +148,7 @@ -@media screen and (max-width: 650px) { +@media screen and (max-width: 798px) { #notesContainer { display: block; } diff --git a/osinaweb/osinacore/__pycache__/models.cpython-311.pyc b/osinaweb/osinacore/__pycache__/models.cpython-311.pyc index 22004f53..58635d65 100644 Binary files a/osinaweb/osinacore/__pycache__/models.cpython-311.pyc and b/osinaweb/osinacore/__pycache__/models.cpython-311.pyc differ diff --git a/osinaweb/osinacore/__pycache__/views.cpython-311.pyc b/osinaweb/osinacore/__pycache__/views.cpython-311.pyc index 83467eec..d54a0c71 100644 Binary files a/osinaweb/osinacore/__pycache__/views.cpython-311.pyc and b/osinaweb/osinacore/__pycache__/views.cpython-311.pyc differ diff --git a/osinaweb/osinacore/migrations/0052_note_project.py b/osinaweb/osinacore/migrations/0052_note_project.py new file mode 100644 index 00000000..e764da4b --- /dev/null +++ b/osinaweb/osinacore/migrations/0052_note_project.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.5 on 2024-01-23 07:01 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0051_alter_task_requirement'), + ] + + operations = [ + migrations.AddField( + model_name='note', + name='project', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='osinacore.project'), + ), + ] diff --git a/osinaweb/osinacore/migrations/__pycache__/0052_note_project.cpython-311.pyc b/osinaweb/osinacore/migrations/__pycache__/0052_note_project.cpython-311.pyc new file mode 100644 index 00000000..537b9b1c Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0052_note_project.cpython-311.pyc differ diff --git a/osinaweb/osinacore/models.py b/osinaweb/osinacore/models.py index ec296931..b481741b 100644 --- a/osinaweb/osinacore/models.py +++ b/osinaweb/osinacore/models.py @@ -194,6 +194,7 @@ class Note(models.Model): date = models.DateTimeField(null=True,blank=True) user = models.ForeignKey(User, on_delete=models.CASCADE, null=True,blank=True) color = ColorField(default='#FF0000',blank=True) + project = models.ForeignKey(Project, on_delete=models.CASCADE, null=True, blank=True) class Task(models.Model): diff --git a/osinaweb/osinacore/views.py b/osinaweb/osinacore/views.py index f0e3f775..0cf2b9cd 100644 --- a/osinaweb/osinacore/views.py +++ b/osinaweb/osinacore/views.py @@ -71,6 +71,7 @@ def home(request, *args, **kwargs): +from django.db.models import Subquery, OuterRef #Listing Pages @login_required @@ -84,11 +85,19 @@ def my_projects(request, *args, **kwargs): # Non-superuser, filter projects where the user is either the manager or a member projects = Project.objects.filter(Q(manager=user.staffprofile) | Q(members=user.staffprofile)).distinct().order_by('-project_id') + # Annotate each project with its most recent note + projects = projects.annotate( + recent_note_text=Subquery( + Note.objects.filter(project=OuterRef('pk')).order_by('-date').values('text')[:1] + ), + recent_note_color=Subquery( + Note.objects.filter(project=OuterRef('pk')).order_by('-date').values('color')[:1] + ), + recent_note_date=Max('note__date') + ) context = { - - 'projects' : projects, - + 'projects': projects, } return render(request, 'listing_pages/projects.html', context) @@ -233,6 +242,8 @@ def detailed_project(request, project_id): epics = Epic.objects.filter(project=project) latest_epic = Epic.objects.filter(project=project).last() + project_notes = Note.objects.filter(project=project).order_by('-id') + if latest_epic: epics = epics.exclude(pk=latest_epic.pk) @@ -250,11 +261,14 @@ def detailed_project(request, project_id): 'epics': epics, 'selected_epic': selected_epic, 'related_tasks': related_tasks, - 'latest_epic': latest_epic + 'latest_epic': latest_epic, + 'project_notes' : project_notes, } return render(request, 'details_pages/project-details.html', context) + + @login_required def customerdetails(request, customer_id): customer = get_object_or_404(CustomerProfile, customer_id=customer_id) @@ -433,10 +447,13 @@ def add_note_modal(request, *args, **kwargs): return render(request, 'popup_modals/addnote-modal.html', context) -def add_project_note_modal(request, *args, **kwargs): - context = { +def add_project_note_modal(request, project_id): + project = get_object_or_404(Project, project_id=project_id) + context = { + 'project' : project } + return render(request, 'popup_modals/add-project-note-modal.html', context) @@ -696,6 +713,31 @@ def save_note(request): return render(request, 'addnote-modal.html') +def save_project_note(request): + + if request.method == 'POST': + text = request.POST.get('note_text') + color = request.POST.get('note_color') + user = request.user + date = timezone.now() + + project_id = request.POST.get('project') + project = get_object_or_404(Project, id=project_id) + + note = Note( + text=text, + color=color, + user=user, + date=date, + project=project, + ) + note.save() + + return HttpResponse('') + + return render(request, 'add-project-note-modal.html') + + @login_required def save_project(request): @@ -1697,6 +1739,25 @@ def delete_note_modal(request, note_id): return render(request, "delete_modals/delete-note-modal.html", context) +@login_required +def delete_project_note_modal(request, note_id): + note = get_object_or_404(Note, id=note_id) + + if request.method == 'POST': + project_id = note.project_id + project = get_object_or_404(Project, id=project_id) + note.delete() + + return redirect('detailed-project', project_id=project.project_id) + + context = { + 'note': note, + } + + return render(request, "delete_modals/delete-project-note-modal.html", context) + + + @login_required def delete_business_modal(request, business_id): business = get_object_or_404(Business, id=business_id) diff --git a/osinaweb/osinaweb/__pycache__/urls.cpython-311.pyc b/osinaweb/osinaweb/__pycache__/urls.cpython-311.pyc index 44568f53..fa089b97 100644 Binary files a/osinaweb/osinaweb/__pycache__/urls.cpython-311.pyc and b/osinaweb/osinaweb/__pycache__/urls.cpython-311.pyc differ diff --git a/osinaweb/osinaweb/urls.py b/osinaweb/osinaweb/urls.py index 8ee611c5..9a111e28 100644 --- a/osinaweb/osinaweb/urls.py +++ b/osinaweb/osinaweb/urls.py @@ -37,7 +37,6 @@ urlpatterns = [ path('addstaff/', views.addstaff, name='adduser'), path('staffs/', views.staffs, name='users'), path('staffpositions/', views.staff_positions, name='staffpositions'), - path('projectdetails//', views.detailed_project, name='detailed-project'), path('createproject/', views.create_project, name='createproject'), path('createepic//', views.create_epic, name='createepic'), path('createtask/', views.create_task, name='createtask'), @@ -59,6 +58,7 @@ urlpatterns = [ path('customers//', views.customerdetails, name='customerdetails'), path('staffs//', views.staffdetails, name='userdetails'), path('tasks//', views.detailed_task, name='detailed-task'), + path('projectdetails//', views.detailed_project, name='detailed-project'), @@ -72,7 +72,7 @@ urlpatterns = [ #Modals urls path('add-status/', views.add_status_modal, name='addstatus'), path('add-note/', views.add_note_modal, name='addnote'), - path('add-project-note/', views.add_project_note_modal, name='addprojectnote'), + path('add-project-note//', views.add_project_note_modal, name='addprojectnote'), path('add-file/', views.add_file_modal, name='addfile'), path('add-user-story//', views.add_user_story_modal, name='adduserstory'), path('add-credentials/', views.add_credentials_modal, name='addcredentials'), @@ -98,9 +98,12 @@ urlpatterns = [ path('deleteprojectmodal/', views.delete_project_modal, name='deleteprojectmodal'), path('deletetaskmodal/', views.delete_task_modal, name='deletetaskmodal'), path('deletenotemodal/', views.delete_note_modal, name='deletenotemodal'), + path('deleteprojectnotemodal/', views.delete_project_note_modal, name='deleteprojectnotemodal'), #Save Urls path('save_note/', views.save_note, name='save_note'), + path('save_project_note/', views.save_project_note, name='save_project_note'), + path('save_project/', views.save_project, name='save_project'), path('save_epic/', views.save_epic, name='save_epic'), path('save_task/', views.save_task, name='save_task'), diff --git a/osinaweb/static/dist/output.css b/osinaweb/static/dist/output.css index 57417685..1cf35dbe 100644 --- a/osinaweb/static/dist/output.css +++ b/osinaweb/static/dist/output.css @@ -1080,6 +1080,10 @@ video { min-width: 100%; } +.max-w-0 { + max-width: 0rem; +} + .max-w-2xl { max-width: 42rem; } @@ -1389,6 +1393,11 @@ video { border-color: rgb(59 130 246 / var(--tw-border-opacity)); } +.border-gray-100 { + --tw-border-opacity: 1; + border-color: rgb(243 244 246 / var(--tw-border-opacity)); +} + .border-gray-200 { --tw-border-opacity: 1; border-color: rgb(229 231 235 / var(--tw-border-opacity)); @@ -2285,7 +2294,7 @@ video { } } -@media screen and (max-width: 650px) { +@media screen and (max-width: 798px) { #notesContainer { display: block; } @@ -2439,6 +2448,10 @@ video { display: block; } + .md\:flex { + display: flex; + } + .md\:hidden { display: none; } diff --git a/osinaweb/static/js/pop-modals.js b/osinaweb/static/js/pop-modals.js index 020c4e55..456b5873 100644 --- a/osinaweb/static/js/pop-modals.js +++ b/osinaweb/static/js/pop-modals.js @@ -74,6 +74,8 @@ document.addEventListener("DOMContentLoaded", function () { addButtonClickListener("deleteProjectButton", "400px", "140px"); addButtonClickListener("deleteTaskButton", "400px", "140px"); addButtonClickListener("deleteNoteButton", "400px", "140px"); + addButtonClickListener("deleteProjectNoteButton", "400px", "140px"); + diff --git a/osinaweb/templates/delete_modals/delete-project-note-modal.html b/osinaweb/templates/delete_modals/delete-project-note-modal.html new file mode 100644 index 00000000..63c9d6ed --- /dev/null +++ b/osinaweb/templates/delete_modals/delete-project-note-modal.html @@ -0,0 +1,30 @@ +{%load static%} + + + + + + + + + + + + + + +
+ {% csrf_token %} + +
+

Are you sure you want to delete this note?

+ +
+ +
+
+
+ + + \ No newline at end of file diff --git a/osinaweb/templates/details_pages/business-details.html b/osinaweb/templates/details_pages/business-details.html index 99901f7d..32a80899 100644 --- a/osinaweb/templates/details_pages/business-details.html +++ b/osinaweb/templates/details_pages/business-details.html @@ -30,11 +30,11 @@ -
+\
-
+ -