emile 4 months ago
parent a6840a9c6d
commit e886b874a7

BIN
.DS_Store vendored

Binary file not shown.

BIN
osinaweb/.DS_Store vendored

Binary file not shown.

Binary file not shown.

@ -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 = {

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

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

@ -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/<str:email>/<str:key>/', views.login_with_email, name='login_with_email'),
path('login/', views.signin, name='signin'),

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

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save