You can now add notes via Osina!

main
emile 2 years ago
parent bedab56704
commit 19a1669955

Binary file not shown.

@ -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',
),
]

@ -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),
),
]

@ -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)

@ -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)
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')

@ -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'),

@ -14,11 +14,12 @@
</head>
<body>
<div id="hiddenContent">
<form id="hiddenContent" method="POST" action="{% url 'save_note' %}">
{% csrf_token %}
<h1 class="text-slate-800 text-2xl font-semibold text-center">Add Note</h1>
<div class="w-full flex justify-center items-center">
<input type="text" placeholder="Type your note here..."
<input required name="note_text" type="text" placeholder="Type your note here..."
class="w-full p-3 border border-gray-300 rounded-md bg-transparent outline-none mt-4">
</div>
@ -55,7 +56,7 @@
</div>
<div>
<input type="text"
<input required name="note_color" type="text"
class="w-full border border-gray-300 rounded-md py-1 px-3 outline-none h-[50px] mt-4 hidden"
id="hexCodeDisplay">
</div>
@ -101,10 +102,10 @@
</script>
<div class="w-full flex justify-center items-center mt-6">
<button
<button type="submit"
class="w-fit bg-blue-500 border border-blue-500 rounded-md text-white text-xl px-3 py-2 hover:bg-white hover:text-blue-500">Add</button>
</div>
</div>
</form>
</body>
</html>

@ -27,7 +27,7 @@
id="notesContainer">
{% for note in notes %}
<div class="w-[16.33%] h-[150px] shadow-xl p-5 rounded-bl-lg" style="background-color: {{note.color}}">
<div class="w-[16.33%] h-[150px] shadow-xl p-5" style="background-color: {{note.color}}">
<p class="text-base text-slate-800">{{note.text}}</p>
</div>
{% endfor %}

Loading…
Cancel
Save