feat: add automation activity and employer intelligence

This commit is contained in:
Jens
2026-07-22 20:17:20 +02:00
parent 4fa2a34447
commit afe18e5b96
16 changed files with 679 additions and 18 deletions
+93 -1
View File
@@ -15,7 +15,8 @@ from django.views.generic import DetailView, ListView, TemplateView, UpdateView
from apps.profiles.models import SearchProfile
from .forms import ApplicationForm
from .models import Application, Feedback, JobPosting, ScoreRun
from .models import Application, Employer, Feedback, JobPosting, ScoreRun
from .services.activity import ACTIVITY_FILTERS, build_activity_page
from .services.applications import (
build_application_export,
build_print_html,
@@ -24,6 +25,11 @@ from .services.applications import (
track_application_changes,
)
from .services.cockpit import annotate_latest_profile_score, build_job_intelligence
from .services.employer_intelligence import (
build_employer_detail,
employer_index_queryset,
filter_employers,
)
from .services.feedback import record_feedback
from .services.relevance import it_relevance_query
from .services.skill_demand import build_skill_demand_report
@@ -48,6 +54,92 @@ class SkillInsightsView(LoginRequiredMixin, TemplateView):
return context
class ActivityListView(LoginRequiredMixin, TemplateView):
template_name = "activity/list.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
event_type = self.request.GET.get("type", "all")
valid_types = {value for value, _label in ACTIVITY_FILTERS}
if event_type not in valid_types:
event_type = "all"
context.update(
{
"event_page": build_activity_page(
user=self.request.user,
event_type=event_type,
query=self.request.GET.get("q", ""),
page=self.request.GET.get("page", 1),
),
"activity_filters": ACTIVITY_FILTERS,
"current_type": event_type,
}
)
return context
class EmployerListView(LoginRequiredMixin, ListView):
model = Employer
template_name = "employers/list.html"
context_object_name = "employers"
paginate_by = 40
def get_queryset(self):
self.profile = SearchProfile.objects.filter(user=self.request.user, is_active=True).first()
return filter_employers(
employer_index_queryset(user=self.request.user, profile=self.profile),
query=self.request.GET.get("q", ""),
channel=self.request.GET.get("channel", ""),
active_only=self.request.GET.get("active") == "1",
)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
employers = list(context["employers"])
selected_id = self.request.GET.get("selected", "")
selected = next((item for item in employers if str(item.pk) == selected_id), None)
if selected is None and employers:
selected = employers[0]
context.update(
{
"selected_employer": selected,
"selected_detail": build_employer_detail(
employer=selected, user=self.request.user, profile=self.profile
)
if selected
else None,
"active_profile": self.profile,
"employer_total": Employer.objects.count(),
"employer_active_total": Employer.objects.filter(
jobs__status=JobPosting.Status.ACTIVE
)
.distinct()
.count(),
}
)
return context
class EmployerDetailView(LoginRequiredMixin, DetailView):
model = Employer
template_name = "employers/detail.html"
context_object_name = "employer"
def get_queryset(self):
self.profile = SearchProfile.objects.filter(user=self.request.user, is_active=True).first()
return employer_index_queryset(user=self.request.user, profile=self.profile)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context.update(
build_employer_detail(
employer=self.object, user=self.request.user, profile=self.profile
)
)
context["active_profile"] = self.profile
return context
class JobListView(LoginRequiredMixin, ListView):
model = JobPosting
template_name = "jobs/list.html"