diff --git a/.DS_Store b/.DS_Store index 684dd60e..1cafa8f6 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/osinaweb/.DS_Store b/osinaweb/.DS_Store index ffeaec15..58a0e6e3 100644 Binary files a/osinaweb/.DS_Store and b/osinaweb/.DS_Store differ diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index b53e6f79..db026d21 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/osinacore/__pycache__/admin.cpython-310.pyc b/osinaweb/osinacore/__pycache__/admin.cpython-310.pyc index c1db5bfa..ba64e83f 100644 Binary files a/osinaweb/osinacore/__pycache__/admin.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/admin.cpython-310.pyc differ diff --git a/osinaweb/osinacore/__pycache__/models.cpython-310.pyc b/osinaweb/osinacore/__pycache__/models.cpython-310.pyc index e653eb11..b32e5975 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 1fd8c6a6..37df28a6 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/admin.py b/osinaweb/osinacore/admin.py index 5bca6652..b8d6537d 100644 --- a/osinaweb/osinacore/admin.py +++ b/osinaweb/osinacore/admin.py @@ -33,5 +33,5 @@ admin.site.register(Task) admin.site.register(Status) admin.site.register(Tag) admin.site.register(Point) - +admin.site.register(DailyReport) diff --git a/osinaweb/osinacore/migrations/0041_dailyreport.py b/osinaweb/osinacore/migrations/0041_dailyreport.py new file mode 100644 index 00000000..cb6dcbb4 --- /dev/null +++ b/osinaweb/osinacore/migrations/0041_dailyreport.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.5 on 2023-09-26 08:39 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0040_staffprofile_staff_id'), + ] + + operations = [ + migrations.CreateModel( + name='DailyReport', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.TextField(blank=True)), + ('date', models.CharField(max_length=40)), + ('time', models.CharField(max_length=40)), + ('staff', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='dailyreport_staff', to='osinacore.staffprofile')), + ], + ), + ] diff --git a/osinaweb/osinacore/migrations/__pycache__/0041_dailyreport.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0041_dailyreport.cpython-310.pyc new file mode 100644 index 00000000..f7d137ee Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0041_dailyreport.cpython-310.pyc differ diff --git a/osinaweb/osinacore/models.py b/osinaweb/osinacore/models.py index f4774585..17ad6a36 100644 --- a/osinaweb/osinacore/models.py +++ b/osinaweb/osinacore/models.py @@ -265,3 +265,12 @@ class Status(models.Model): date = models.CharField(max_length=40) time = models.CharField(max_length=40) staff = models.ForeignKey(StaffProfile, on_delete=models.CASCADE, null=True,blank=True, related_name='staff') + + + + +class DailyReport(models.Model): + text = models.TextField(blank=True) + date = models.CharField(max_length=40) + time = models.CharField(max_length=40) + staff = models.ForeignKey(StaffProfile, on_delete=models.CASCADE, null=True,blank=True, related_name='dailyreport_staff') diff --git a/osinaweb/osinacore/views.py b/osinaweb/osinacore/views.py index bbddfe7b..a1f0365e 100644 --- a/osinaweb/osinacore/views.py +++ b/osinaweb/osinacore/views.py @@ -10,7 +10,7 @@ from django.http import HttpResponse from django.db.models import Q from django.http import JsonResponse from .models import Task, Epic - +from datetime import date # Pages views @@ -348,9 +348,29 @@ def tags(request): return render(request, 'tags.html', context) +def daily_reports(request): + + dailyreports = DailyReport.objects.all().order_by('-id') + + context = { + 'dailyreports' : dailyreports, + + + } + return render(request, 'daily-reports.html', context) +def add_daily_report(request): + user = request.user + today = date.today() + statuses = Status.objects.filter(staff=user.staffprofile, date=today) + context = { + 'statuses': statuses, + + + } + return render(request, 'add-daily-report.html', context) @@ -459,22 +479,8 @@ def staff_position_modal(request): } return render(request, 'add-staffposition-modal.html', context) -def daily_reports(request): - - context = { - - - } - return render(request, 'daily-reports.html', context) - - -def add_daily_report(request): - - context = { - } - return render(request, 'add-daily-report.html', context) @@ -961,11 +967,12 @@ def save_point(request): return render(request, 'addpoint-modal.html') + @login_required def mark_point_working_on(request, point_id): point = get_object_or_404(Point, id=point_id) point.status = 'Working On' - current_datetime = timezone.now() + current_datetime = datetime.now() point.date_workingon = current_datetime.date() point.time_workingon = current_datetime.strftime("%I:%M %p") @@ -985,9 +992,9 @@ def mark_point_working_on(request, point_id): def mark_point_completed(request, point_id): point = get_object_or_404(Point, id=point_id) point.status = 'Completed' - current_datetime = timezone.now() - point.date_completed = current_datetime.date() - point.time_completed = current_datetime.strftime("%I:%M %p") + current_datetime = datetime.now() + point.date_workingon = current_datetime.date() + point.time_workingon = current_datetime.strftime("%I:%M %p") point.save() @@ -1001,6 +1008,34 @@ def mark_point_completed(request, point_id): return redirect(request, 'showpoints-modal.html') + +@login_required +def save_dailyreport(request): + if request.method == 'POST': + text = request.POST.get('text') + current_datetime = datetime.now() + date = datetime.now().date() + time = current_datetime.strftime("%I:%M %p") + try: + staff_profile = StaffProfile.objects.get(user=request.user) + except StaffProfile.DoesNotExist: + # Handle the case where a StaffProfile does not exist for the user + staff_profile = None + + + dailyreport = DailyReport( + text = text, + date = date, + time = time, + staff = staff_profile + ) + dailyreport.save() + + + return redirect('dailyreports') + + + # EDIT TEMPLATES @login_required diff --git a/osinaweb/osinaweb/__pycache__/urls.cpython-310.pyc b/osinaweb/osinaweb/__pycache__/urls.cpython-310.pyc index cb8398cf..8425a51a 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 9f4a736f..3fd4bcbe 100644 --- a/osinaweb/osinaweb/urls.py +++ b/osinaweb/osinaweb/urls.py @@ -90,6 +90,7 @@ urlpatterns = [ path('save_tag/', views.save_tag, name='save_tag'), path('save_point/', views.save_point, name='save_point'), path('save_staffposition/', views.save_staffposition, name='save_staffposition'), + path('save_dailyreport/', views.save_dailyreport, name='save_dailyreport'), diff --git a/osinaweb/templates/add-daily-report.html b/osinaweb/templates/add-daily-report.html index 23df3437..0ce654cd 100644 --- a/osinaweb/templates/add-daily-report.html +++ b/osinaweb/templates/add-daily-report.html @@ -7,10 +7,14 @@