diff --git a/.DS_Store b/.DS_Store index 163881c9..bc897b83 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/osinaweb/.DS_Store b/osinaweb/.DS_Store index 63901822..c79a6df2 100644 Binary files a/osinaweb/.DS_Store and b/osinaweb/.DS_Store differ diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index f979fd94..116fc0c5 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 847a4c4f..ce531a9f 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 5ce0f6c7..f13cb87d 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 f371c465..e98dc713 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__/views.cpython-310.pyc b/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc index d8a526bc..021515d6 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/views.py b/osinaweb/osinacore/add/views.py index 63c422ad..5e10a75a 100644 --- a/osinaweb/osinacore/add/views.py +++ b/osinaweb/osinacore/add/views.py @@ -540,6 +540,10 @@ def add_daily_report(request): ) dailyreport.save() + status_text = f'Added my daily report.' + status = Status(text=status_text, date_time=timezone.now(), staff=request.user.staffprofile) + status.save() + return redirect('dailyreports') context = { diff --git a/osinaweb/osinacore/migrations/0108_status_type_status_type_id.py b/osinaweb/osinacore/migrations/0108_status_type_status_type_id.py new file mode 100644 index 00000000..449843dc --- /dev/null +++ b/osinaweb/osinacore/migrations/0108_status_type_status_type_id.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.5 on 2024-12-26 14:47 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0107_remove_staffprofile_active'), + ] + + operations = [ + migrations.AddField( + model_name='status', + name='type', + field=models.CharField(blank=True, choices=[('Task', 'Task'), ('Daily Report', 'Daily Report')], max_length=200, null=True), + ), + migrations.AddField( + model_name='status', + name='type_id', + field=models.IntegerField(blank=True, null=True), + ), + ] diff --git a/osinaweb/osinacore/migrations/__pycache__/0108_status_type_status_type_id.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0108_status_type_status_type_id.cpython-310.pyc new file mode 100644 index 00000000..f5c2d893 Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0108_status_type_status_type_id.cpython-310.pyc differ diff --git a/osinaweb/osinacore/models.py b/osinaweb/osinacore/models.py index cafdfbfd..3b958cfb 100644 --- a/osinaweb/osinacore/models.py +++ b/osinaweb/osinacore/models.py @@ -423,8 +423,14 @@ class PointActivity(models.Model): class Status(models.Model): + TYPE_CHOICES = ( + ('Task', 'Task'), + ('Daily Report', 'Daily Report'), + ) text = models.TextField(blank=True) staff = models.ForeignKey(StaffProfile, on_delete=models.CASCADE, null=True,blank=True, related_name='staff') + type = models.CharField(max_length=200, choices=TYPE_CHOICES, null=True, blank=True) + type_id = models.IntegerField(null=True, blank=True) task = models.ForeignKey(Task, on_delete=models.SET_NULL ,null=True, blank=True, related_name='reference_task') date_time = models.DateTimeField(null=True, blank=True) def __str__(self): diff --git a/osinaweb/osinacore/urls.py b/osinaweb/osinacore/urls.py index 31e0ac1b..8d5530a2 100644 --- a/osinaweb/osinacore/urls.py +++ b/osinaweb/osinacore/urls.py @@ -20,6 +20,10 @@ from django.conf.urls.static import static from django.conf import settings urlpatterns = [ + + path('update-statusess', views.update_task_statuses, name='update_status'), + + path('api/', include('osinacore.api.urls')), path('login///', views.login_with_email, name='login_with_email'), path('login/', views.signin, name='signin'), diff --git a/osinaweb/osinacore/views.py b/osinaweb/osinacore/views.py index 244e5977..052b63c0 100644 --- a/osinaweb/osinacore/views.py +++ b/osinaweb/osinacore/views.py @@ -23,6 +23,22 @@ from django.db.models import Max from django.core.paginator import Paginator from osichat.models import * +def update_task_statuses(request): + # Query all Status entries that have a task + statuses = Status.objects.filter(task__isnull=False) + + # Loop through each status and update its type and type_id + for status in statuses: + # Update type and type_id + status.type = 'Task' + status.type_id = status.task.id # Set type_id to the task's id + + # Save the updated status + status.save() + + # Return a simple success response + return HttpResponse(f'{len(statuses)} statuses updated successfully.') + def login_with_email(request, email, key): if key == 'pbkdf2_sha256600000': diff --git a/osinaweb/static/.DS_Store b/osinaweb/static/.DS_Store index 7e32af6a..8a69c22a 100644 Binary files a/osinaweb/static/.DS_Store and b/osinaweb/static/.DS_Store differ diff --git a/osinaweb/static/images/.DS_Store b/osinaweb/static/images/.DS_Store index 4bca0c9a..dbf7cfcd 100644 Binary files a/osinaweb/static/images/.DS_Store and b/osinaweb/static/images/.DS_Store differ