diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index a463b92e..d0eae15c 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 34b8a161..9000d0af 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__/views.cpython-310.pyc b/osinaweb/osinacore/__pycache__/views.cpython-310.pyc index b9cef5a6..2735aca8 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/migrations/0010_remove_note_date.py b/osinaweb/osinacore/migrations/0010_remove_note_date.py new file mode 100644 index 00000000..35241ec4 --- /dev/null +++ b/osinaweb/osinacore/migrations/0010_remove_note_date.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.5 on 2023-09-11 15:02 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0009_alter_project_project_id'), + ] + + operations = [ + migrations.RemoveField( + model_name='note', + name='date', + ), + ] diff --git a/osinaweb/osinacore/migrations/0011_note_date_alter_note_color_alter_note_text_and_more.py b/osinaweb/osinacore/migrations/0011_note_date_alter_note_color_alter_note_text_and_more.py new file mode 100644 index 00000000..5cd7b9cc --- /dev/null +++ b/osinaweb/osinacore/migrations/0011_note_date_alter_note_color_alter_note_text_and_more.py @@ -0,0 +1,37 @@ +# Generated by Django 4.2.5 on 2023-09-11 15:04 + +import colorfield.fields +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('osinacore', '0010_remove_note_date'), + ] + + operations = [ + migrations.AddField( + model_name='note', + name='date', + field=models.DateTimeField(blank=True, null=True), + ), + migrations.AlterField( + model_name='note', + name='color', + field=colorfield.fields.ColorField(blank=True, default='#FF0000', image_field=None, max_length=25, samples=None), + ), + migrations.AlterField( + model_name='note', + name='text', + field=models.TextField(blank=True), + ), + migrations.AlterField( + model_name='note', + name='user', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/osinaweb/osinacore/migrations/__pycache__/0010_remove_note_date.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0010_remove_note_date.cpython-310.pyc new file mode 100644 index 00000000..f948eaad Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0010_remove_note_date.cpython-310.pyc differ diff --git a/osinaweb/osinacore/migrations/__pycache__/0011_note_date_alter_note_color_alter_note_text_and_more.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0011_note_date_alter_note_color_alter_note_text_and_more.cpython-310.pyc new file mode 100644 index 00000000..66cf8a34 Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0011_note_date_alter_note_color_alter_note_text_and_more.cpython-310.pyc differ diff --git a/osinaweb/osinacore/models.py b/osinaweb/osinacore/models.py index 6274480d..7cabf785 100644 --- a/osinaweb/osinacore/models.py +++ b/osinaweb/osinacore/models.py @@ -133,7 +133,7 @@ class Epic(models.Model): class Note(models.Model): - text = models.TextField() - date = models.DateTimeField() - user = models.ForeignKey(User, on_delete=models.CASCADE, null=True) - color = ColorField(default='#FF0000') + text = models.TextField(blank=True) + 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) diff --git a/osinaweb/osinacore/views.py b/osinaweb/osinacore/views.py index 8aec24d8..c18a19a5 100644 --- a/osinaweb/osinacore/views.py +++ b/osinaweb/osinacore/views.py @@ -4,6 +4,7 @@ from django.contrib.auth import authenticate, login, logout from django.contrib.auth.decorators import login_required from django.contrib import messages from .forms import * +from django.utils import timezone # Create your views here. @@ -105,6 +106,8 @@ def add_note_modal(request, *args, **kwargs): } return render(request, 'addnote-modal.html', context) + + def add_status_modal(request, *args, **kwargs): context = { @@ -145,4 +148,26 @@ def update_status_modal(request, *args, **kwargs): context = { } - return render(request, 'update-status-modal.html', context) \ No newline at end of file + return render(request, 'update-status-modal.html', context) + + +@login_required +def save_note(request): + if request.method == 'POST': + text = request.POST.get('note_text') + color= request.POST.get('note_color') + user = request.user + date = timezone.now() + + note = Note( + text = text, + color = color, + user = user, + date = date, + ) + note.save() + + + return redirect('home') # Redirect to a success page or another view + + return render(request, 'addnote-modal.html') \ No newline at end of file diff --git a/osinaweb/osinaweb/__pycache__/settings.cpython-310.pyc b/osinaweb/osinaweb/__pycache__/settings.cpython-310.pyc index 74a5d232..90303bd9 100644 Binary files a/osinaweb/osinaweb/__pycache__/settings.cpython-310.pyc and b/osinaweb/osinaweb/__pycache__/settings.cpython-310.pyc differ diff --git a/osinaweb/osinaweb/__pycache__/urls.cpython-310.pyc b/osinaweb/osinaweb/__pycache__/urls.cpython-310.pyc index 07d3a308..cc7b6184 100644 Binary files a/osinaweb/osinaweb/__pycache__/urls.cpython-310.pyc and b/osinaweb/osinaweb/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/osinaweb/urls.py b/osinaweb/osinaweb/urls.py index 016270e1..ccd25fc6 100644 --- a/osinaweb/osinaweb/urls.py +++ b/osinaweb/osinaweb/urls.py @@ -28,9 +28,12 @@ urlpatterns = [ path('createproject/', views.create_project, name='createproject'), path('createepic/', views.create_epic, name='createepic'), + path('addstatus/', views.add_status_modal, name='addstatus'), path('updatestatus/', views.update_status_modal, name='updatestatus'), path('addnote/', views.add_note_modal, name='addnote'), + path('save_note/', views.save_note, name='save_note'), + path('addpoint/', views.add_point_modal, name='addpoint'), path('showpoints/', views.show_points_modal, name='showpoints'), path('addtime/', views.add_time_modal, name='addtime'), diff --git a/osinaweb/templates/addnote-modal.html b/osinaweb/templates/addnote-modal.html index 38088312..bca1834d 100644 --- a/osinaweb/templates/addnote-modal.html +++ b/osinaweb/templates/addnote-modal.html @@ -14,11 +14,12 @@
-