From 47de74bde4c1cb6b0a23f858749c438396a76c07 Mon Sep 17 00:00:00 2001 From: Konrad du Plessis Date: Mon, 23 Feb 2026 00:49:57 +0200 Subject: [PATCH] Show active resources by default, collapse inactive + add project dates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dashboard Manage Resources now shows only active workers/projects/teams by default. Inactive items are hidden behind a collapsible "Show X Inactive" button — faded at 50% opacity. Tab badges show active counts. Also adds start_date and end_date fields to Project model (optional). Dates display under the project name in the resource list. Co-Authored-By: Claude Opus 4.6 --- core/admin.py | 2 +- .../0003_add_project_start_end_dates.py | 23 ++++ core/models.py | 2 + core/templates/core/index.html | 119 +++++++++++++++--- core/views.py | 21 ++-- 5 files changed, 143 insertions(+), 24 deletions(-) create mode 100644 core/migrations/0003_add_project_start_end_dates.py diff --git a/core/admin.py b/core/admin.py index 1fd949f..58aedc8 100644 --- a/core/admin.py +++ b/core/admin.py @@ -12,7 +12,7 @@ class UserProfileAdmin(admin.ModelAdmin): @admin.register(Project) class ProjectAdmin(admin.ModelAdmin): - list_display = ('name', 'active') + list_display = ('name', 'start_date', 'end_date', 'active') list_filter = ('active',) search_fields = ('name', 'description') filter_horizontal = ('supervisors',) diff --git a/core/migrations/0003_add_project_start_end_dates.py b/core/migrations/0003_add_project_start_end_dates.py new file mode 100644 index 0000000..f5914de --- /dev/null +++ b/core/migrations/0003_add_project_start_end_dates.py @@ -0,0 +1,23 @@ +# Generated by Django 5.2.7 on 2026-02-22 22:44 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0002_update_worker_id_numbers'), + ] + + operations = [ + migrations.AddField( + model_name='project', + name='end_date', + field=models.DateField(blank=True, null=True), + ), + migrations.AddField( + model_name='project', + name='start_date', + field=models.DateField(blank=True, null=True), + ), + ] diff --git a/core/models.py b/core/models.py index 31b5a5a..5ba2de3 100644 --- a/core/models.py +++ b/core/models.py @@ -25,6 +25,8 @@ def save_user_profile(sender, instance, **kwargs): class Project(models.Model): name = models.CharField(max_length=200) description = models.TextField(blank=True) + start_date = models.DateField(null=True, blank=True) + end_date = models.DateField(null=True, blank=True) supervisors = models.ManyToManyField(User, related_name='assigned_projects') active = models.BooleanField(default=True) diff --git a/core/templates/core/index.html b/core/templates/core/index.html index efc3638..f2d0dd1 100644 --- a/core/templates/core/index.html +++ b/core/templates/core/index.html @@ -179,61 +179,148 @@
- + + {# === WORKERS TAB === #}
    - {% for item in workers %} + {% for item in active_workers %}
  • {{ item.name }}
    - +
  • {% empty %} -
  • No workers found.
  • +
  • No active workers.
  • {% endfor %} + + {# Collapsible section for inactive workers #} + {% if inactive_workers %} +
  • + +
    +
      + {% for item in inactive_workers %} +
    • + {{ item.name }} +
      + +
      +
    • + {% endfor %} +
    +
    +
  • + {% endif %}
- + + {# === PROJECTS TAB === #}
    - {% for item in projects %} + {% for item in active_projects %}
  • - {{ item.name }} +
    + {{ item.name }} + {% if item.start_date or item.end_date %} +
    + {{ item.start_date|date:"j M Y"|default:"?" }} – {{ item.end_date|date:"j M Y"|default:"ongoing" }} + + {% endif %} +
    - +
  • {% empty %} -
  • No projects found.
  • +
  • No active projects.
  • {% endfor %} + + {# Collapsible section for inactive projects #} + {% if inactive_projects %} +
  • + +
    +
      + {% for item in inactive_projects %} +
    • +
      + {{ item.name }} + {% if item.start_date or item.end_date %} +
      + {{ item.start_date|date:"j M Y"|default:"?" }} – {{ item.end_date|date:"j M Y"|default:"?" }} + + {% endif %} +
      +
      + +
      +
    • + {% endfor %} +
    +
    +
  • + {% endif %}
- + + {# === TEAMS TAB === #}
    - {% for item in teams %} + {% for item in active_teams %}
  • {{ item.name }}
    - +
  • {% empty %} -
  • No teams found.
  • +
  • No active teams.
  • {% endfor %} + + {# Collapsible section for inactive teams #} + {% if inactive_teams %} +
  • + +
    +
      + {% for item in inactive_teams %} +
    • + {{ item.name }} +
      + +
      +
    • + {% endfor %} +
    +
    +
  • + {% endif %}
+
diff --git a/core/views.py b/core/views.py index eb9ded8..8ed6077 100644 --- a/core/views.py +++ b/core/views.py @@ -125,10 +125,14 @@ def index(request): 'project', 'supervisor' ).prefetch_related('workers').order_by('-date', '-id')[:5] - # All workers, projects, and teams for the Manage Resources tab - workers = Worker.objects.all().order_by('name') - projects = Project.objects.all().order_by('name') - teams = Team.objects.all().order_by('name') + # Workers, projects, and teams for the Manage Resources tab + # Split into active (shown by default) and inactive (collapsed section) + active_workers = Worker.objects.filter(active=True).order_by('name') + inactive_workers = Worker.objects.filter(active=False).order_by('name') + active_projects = Project.objects.filter(active=True).order_by('name') + inactive_projects = Project.objects.filter(active=False).order_by('name') + active_teams = Team.objects.filter(active=True).order_by('name') + inactive_teams = Team.objects.filter(active=False).order_by('name') context = { 'is_admin': True, @@ -139,9 +143,12 @@ def index(request): 'outstanding_by_project': outstanding_by_project, 'this_week_logs': this_week_logs, 'recent_activity': recent_activity, - 'workers': workers, - 'projects': projects, - 'teams': teams, + 'active_workers': active_workers, + 'inactive_workers': inactive_workers, + 'active_projects': active_projects, + 'inactive_projects': inactive_projects, + 'active_teams': active_teams, + 'inactive_teams': inactive_teams, } return render(request, 'core/index.html', context)