diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index 05ef66dc..aa8e16c0 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/osinacore/__pycache__/custom_context.cpython-310.pyc b/osinaweb/osinacore/__pycache__/custom_context.cpython-310.pyc index 0ad9bf7f..40d34837 100644 Binary files a/osinaweb/osinacore/__pycache__/custom_context.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/custom_context.cpython-310.pyc differ diff --git a/osinaweb/osinacore/__pycache__/models.cpython-310.pyc b/osinaweb/osinacore/__pycache__/models.cpython-310.pyc index 6ee63c3d..d32a970b 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 bee27ee6..f3b4c006 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/custom_context.py b/osinaweb/osinacore/custom_context.py index c050d67c..a5fc332d 100644 --- a/osinaweb/osinacore/custom_context.py +++ b/osinaweb/osinacore/custom_context.py @@ -1,12 +1,24 @@ -from .models import Task +from .models import Task, Status +from django.contrib.auth.models import AnonymousUser def utilities(request): - if request.user.is_superuser: + + + if request.user.is_authenticated and request.user.is_superuser: open_task_count = Task.objects.filter(status='Open').count() working_on_task_count = Task.objects.filter(status='Working On').count() - else: + last_status = Status.objects.filter(staff=request.user.staffprofile).last() + elif request.user.is_authenticated: open_task_count = Task.objects.filter(assigned_to=request.user.staffprofile, status='Open').count() working_on_task_count = Task.objects.filter(assigned_to=request.user.staffprofile, status='Working On').count() + last_status = Status.objects.filter(staff=request.user.staffprofile).last() + else: + # Handle the case when the user is not logged in + open_task_count = 0 + working_on_task_count = 0 + last_status = None total_tasks = open_task_count + working_on_task_count - return {'total_tasks': total_tasks} \ No newline at end of file + latest_statuses = Status.objects.all().order_by('-id')[:12] + + return {'total_tasks': total_tasks, 'last_status' : last_status, 'latest_statuses' : latest_statuses, } diff --git a/osinaweb/osinacore/migrations/0028_remove_projecttype_color.py b/osinaweb/osinacore/migrations/0028_remove_projecttype_color.py new file mode 100644 index 00000000..bf97bd3d --- /dev/null +++ b/osinaweb/osinacore/migrations/0028_remove_projecttype_color.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.5 on 2023-09-21 07:02 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0027_alter_status_staff'), + ] + + operations = [ + migrations.RemoveField( + model_name='projecttype', + name='color', + ), + ] diff --git a/osinaweb/osinacore/migrations/0029_alter_reference_date.py b/osinaweb/osinacore/migrations/0029_alter_reference_date.py new file mode 100644 index 00000000..1fa45828 --- /dev/null +++ b/osinaweb/osinacore/migrations/0029_alter_reference_date.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.5 on 2023-09-21 07:09 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0028_remove_projecttype_color'), + ] + + operations = [ + migrations.AlterField( + model_name='reference', + name='date', + field=models.CharField(max_length=200), + ), + ] diff --git a/osinaweb/osinacore/migrations/0030_tag.py b/osinaweb/osinacore/migrations/0030_tag.py new file mode 100644 index 00000000..4fbc5727 --- /dev/null +++ b/osinaweb/osinacore/migrations/0030_tag.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.5 on 2023-09-21 07:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0029_alter_reference_date'), + ] + + operations = [ + migrations.CreateModel( + name='Tag', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=50)), + ], + ), + ] diff --git a/osinaweb/osinacore/migrations/__pycache__/0028_remove_projecttype_color.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0028_remove_projecttype_color.cpython-310.pyc new file mode 100644 index 00000000..456637b4 Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0028_remove_projecttype_color.cpython-310.pyc differ diff --git a/osinaweb/osinacore/migrations/__pycache__/0029_alter_reference_date.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0029_alter_reference_date.cpython-310.pyc new file mode 100644 index 00000000..2daf3ddd Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0029_alter_reference_date.cpython-310.pyc differ diff --git a/osinaweb/osinacore/migrations/__pycache__/0030_tag.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0030_tag.cpython-310.pyc new file mode 100644 index 00000000..2010a3b4 Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0030_tag.cpython-310.pyc differ diff --git a/osinaweb/osinacore/models.py b/osinaweb/osinacore/models.py index 3239a06c..a9da4ba6 100644 --- a/osinaweb/osinacore/models.py +++ b/osinaweb/osinacore/models.py @@ -9,11 +9,17 @@ from django.db.models import Max class Reference(models.Model): name = models.CharField(max_length=50) - date = models.DateField(blank=True) + date = models.CharField(max_length=200) def __str__(self): return self.name + def formatted_date(self): + # Assuming start_date is stored as "day-month-year" + parts = self.date.split('-') + return f"{parts[2]}-{parts[1]}-{parts[0]}" +class Tag(models.Model): + name = models.CharField(max_length=50) class Business(models.Model): name = models.CharField(max_length=50) @@ -102,7 +108,7 @@ class StaffProfile(models.Model): class ProjectType(models.Model): name = models.CharField(max_length=50) - color = ColorField(default='#FF0000') + class Project(models.Model): diff --git a/osinaweb/osinacore/views.py b/osinaweb/osinacore/views.py index b5143e7d..3a270c53 100644 --- a/osinaweb/osinacore/views.py +++ b/osinaweb/osinacore/views.py @@ -237,6 +237,7 @@ def businesses(request): } return render(request, 'businesses.html', context) + @login_required def adduser(request): @@ -246,6 +247,7 @@ def adduser(request): } return render(request, 'add-user.html', context) + @login_required def userdetails(request): @@ -277,28 +279,38 @@ def detailed_task(request, task_id): return render(request, 'task-details.html', context) + + @login_required def project_types(request): + projecttypes = ProjectType.objects.all().order_by('-id') context = { - - + 'projecttypes' : projecttypes, } return render(request, 'project-types.html', context) + + @login_required def references(request): + references = Reference.objects.all().order_by('-id') context = { + 'references' : references, } return render(request, 'references.html', context) + + @login_required def tags(request): + tags = Tag.objects.all().order_by('-id') context = { + 'tags' : tags, } @@ -405,6 +417,32 @@ def add_business_modal(request, *args, **kwargs): +#Fetch Views +def fetch_related_tasks(request): + # Get the selected epic ID from the request + epic_id = request.GET.get("epic_id") + + # Fetch tasks related to the selected epic along with their project + related_tasks = Task.objects.filter(epic_id=epic_id).select_related("project") + + task_data = [ + { + "name": task.name, + "status": task.status, + "start_date": task.formatted_start_date(), + "end_date": task.formatted_end_date(), + "extra": task.extra, + "task_id": task.task_id, + } + for task in related_tasks + ] + + return JsonResponse({"tasks": task_data}) + + + + + #Save Functions @login_required def save_note(request): @@ -571,27 +609,6 @@ def save_task(request): return redirect(redirect_url) -def fetch_related_tasks(request): - # Get the selected epic ID from the request - epic_id = request.GET.get("epic_id") - - # Fetch tasks related to the selected epic along with their project - related_tasks = Task.objects.filter(epic_id=epic_id).select_related("project") - - task_data = [ - { - "name": task.name, - "status": task.status, - "start_date": task.formatted_start_date(), - "end_date": task.formatted_end_date(), - "extra": task.extra, - "task_id": task.task_id, - } - for task in related_tasks - ] - - return JsonResponse({"tasks": task_data}) - @login_required def save_business(request): @@ -698,7 +715,7 @@ def save_status(request): text = request.POST.get('text') current_datetime = timezone.now() date = current_datetime.date() - time = current_datetime.hour + time = current_datetime.strftime("%I:%M %p") try: staff_profile = StaffProfile.objects.get(user=request.user) @@ -718,3 +735,66 @@ def save_status(request): return HttpResponse('') return render(request, 'addstatus-modal.html') + + + +@login_required +def save_projecttype(request): + if request.method == 'POST': + name = request.POST.get('name') + + + projecttype = ProjectType( + name = name, + + ) + projecttype.save() + + + # Reload the parent page + return HttpResponse('') + + return redirect('projecttypes') + + + +@login_required +def save_reference(request): + if request.method == 'POST': + name = request.POST.get('name') + date = request.POST.get('date') + + + reference = Reference( + name = name, + date = date, + + ) + reference.save() + + + # Reload the parent page + return HttpResponse('') + + return redirect('references') + + + +@login_required +def save_tag(request): + if request.method == 'POST': + name = request.POST.get('name') + + + + tag = Tag( + name = name, + + + ) + tag.save() + + # Reload the parent page + return HttpResponse('') + + return redirect('tags') \ 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 9eb08cb0..d16919b5 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 2e397fbd..2ea09a4b 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 fbbe56ef..954cc276 100644 --- a/osinaweb/osinaweb/urls.py +++ b/osinaweb/osinaweb/urls.py @@ -17,6 +17,8 @@ from django.contrib import admin from django.urls import path from osinacore import views from django.contrib.auth.decorators import login_required +from django.conf.urls.static import static +from django.conf import settings urlpatterns = [ # Pages urls @@ -46,6 +48,9 @@ urlpatterns = [ path('references/', views.references, name='references'), path('tags/', views.tags, name='tags'), + + + #Fetch urls path("fetch_related_tasks/", views.fetch_related_tasks, name="fetch_related_tasks"), @@ -75,4 +80,9 @@ urlpatterns = [ path('save_business_modal/', views.save_business_modal, name='save_business_modal'), path('save_customer/', views.save_customer, name='save_customer'), path('save_status/', views.save_status, name='save_status'), + path('save_projecttype/', views.save_projecttype, name='save_projecttype'), + path('save_reference/', views.save_reference, name='save_reference'), + path('save_tag/', views.save_tag, name='save_tag'), ] + +urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file diff --git a/osinaweb/static/images/1669023415919.jpeg b/osinaweb/static/images/1669023415919.jpeg new file mode 100644 index 00000000..d20fbe08 Binary files /dev/null and b/osinaweb/static/images/1669023415919.jpeg differ diff --git a/osinaweb/static/images/eHcWZi3-_400x400.jpg b/osinaweb/static/images/eHcWZi3-_400x400.jpg new file mode 100644 index 00000000..b7004b8c Binary files /dev/null and b/osinaweb/static/images/eHcWZi3-_400x400.jpg differ diff --git a/osinaweb/static/js/pop-modals.js b/osinaweb/static/js/pop-modals.js index b94d7e95..a5e60f38 100644 --- a/osinaweb/static/js/pop-modals.js +++ b/osinaweb/static/js/pop-modals.js @@ -54,7 +54,7 @@ document.addEventListener("DOMContentLoaded", function () { addButtonClickListener("addFileButton", "500px", "320px"); addButtonClickListener("addCredentialsButton", "500px", "300px"); addButtonClickListener("addProjectTypeButton", "fit-content", "160px"); - addButtonClickListener("addReferenceButton", "fit-content", "160px"); + addButtonClickListener("addReferenceButton", "fit-content", "230px"); addButtonClickListener("addTagButton", "fit-content", "160px"); addButtonClickListener("addBusinessButton", "550px", "500px"); diff --git a/osinaweb/templates/add-business.html b/osinaweb/templates/add-business.html index 62534e46..be7437ad 100644 --- a/osinaweb/templates/add-business.html +++ b/osinaweb/templates/add-business.html @@ -7,7 +7,7 @@