Pull groups from WhatsApp
This commit is contained in:
@@ -3497,12 +3497,6 @@ def _workspace_nav_urls(person):
|
||||
}
|
||||
|
||||
|
||||
def _person_plan_or_404(request, person_id, plan_id):
|
||||
person = get_object_or_404(Person, pk=person_id, user=request.user)
|
||||
plan = get_object_or_404(PatternMitigationPlan, id=plan_id, user=request.user)
|
||||
return person, plan
|
||||
|
||||
|
||||
class AIWorkspace(LoginRequiredMixin, View):
|
||||
template_name = "pages/ai-workspace.html"
|
||||
|
||||
@@ -4437,7 +4431,12 @@ class AIWorkspaceMitigationChat(LoginRequiredMixin, View):
|
||||
if type not in self.allowed_types:
|
||||
return HttpResponseBadRequest("Invalid type specified")
|
||||
|
||||
person, plan = _person_plan_or_404(request, person_id, plan_id)
|
||||
person = get_object_or_404(Person, pk=person_id, user=request.user)
|
||||
plan = get_object_or_404(
|
||||
PatternMitigationPlan,
|
||||
id=plan_id,
|
||||
user=request.user,
|
||||
)
|
||||
text = (request.POST.get("message") or "").strip()
|
||||
active_tab = _sanitize_active_tab(
|
||||
request.POST.get("active_tab"), default="ask_ai"
|
||||
@@ -4519,11 +4518,14 @@ class AIWorkspaceMitigationChat(LoginRequiredMixin, View):
|
||||
text=assistant_text,
|
||||
)
|
||||
|
||||
return _render_mitigation_panel(
|
||||
return render(
|
||||
request,
|
||||
person,
|
||||
plan,
|
||||
active_tab=active_tab,
|
||||
"partials/ai-workspace-mitigation-panel.html",
|
||||
_mitigation_panel_context(
|
||||
person=person,
|
||||
plan=plan,
|
||||
active_tab=active_tab,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -4534,7 +4536,12 @@ class AIWorkspaceExportArtifact(LoginRequiredMixin, View):
|
||||
if type not in self.allowed_types:
|
||||
return HttpResponseBadRequest("Invalid type specified")
|
||||
|
||||
person, plan = _person_plan_or_404(request, person_id, plan_id)
|
||||
person = get_object_or_404(Person, pk=person_id, user=request.user)
|
||||
plan = get_object_or_404(
|
||||
PatternMitigationPlan,
|
||||
id=plan_id,
|
||||
user=request.user,
|
||||
)
|
||||
|
||||
artifact_type = (request.POST.get("artifact_type") or "rulebook").strip()
|
||||
if artifact_type not in {"rulebook", "rules", "games", "corrections"}:
|
||||
@@ -4581,7 +4588,8 @@ class AIWorkspaceCreateArtifact(LoginRequiredMixin, View):
|
||||
if type not in self.allowed_types:
|
||||
return HttpResponseBadRequest("Invalid type specified")
|
||||
|
||||
person, plan = _person_plan_or_404(request, person_id, plan_id)
|
||||
person = get_object_or_404(Person, pk=person_id, user=request.user)
|
||||
plan = get_object_or_404(PatternMitigationPlan, id=plan_id, user=request.user)
|
||||
kind_key = (kind or "").strip().lower()
|
||||
if kind_key not in self.kind_map:
|
||||
return HttpResponseBadRequest("Invalid artifact kind")
|
||||
@@ -4635,7 +4643,8 @@ class AIWorkspaceUpdateArtifact(LoginRequiredMixin, View):
|
||||
if type not in self.allowed_types:
|
||||
return HttpResponseBadRequest("Invalid type specified")
|
||||
|
||||
person, plan = _person_plan_or_404(request, person_id, plan_id)
|
||||
person = get_object_or_404(Person, pk=person_id, user=request.user)
|
||||
plan = get_object_or_404(PatternMitigationPlan, id=plan_id, user=request.user)
|
||||
kind_key = (kind or "").strip().lower()
|
||||
if kind_key not in self.kind_map:
|
||||
return HttpResponseBadRequest("Invalid artifact kind")
|
||||
@@ -4710,7 +4719,8 @@ class AIWorkspaceDeleteArtifact(LoginRequiredMixin, View):
|
||||
if type not in self.allowed_types:
|
||||
return HttpResponseBadRequest("Invalid type specified")
|
||||
|
||||
person, plan = _person_plan_or_404(request, person_id, plan_id)
|
||||
person = get_object_or_404(Person, pk=person_id, user=request.user)
|
||||
plan = get_object_or_404(PatternMitigationPlan, id=plan_id, user=request.user)
|
||||
kind_key = (kind or "").strip().lower()
|
||||
if kind_key not in self.kind_map:
|
||||
return HttpResponseBadRequest("Invalid artifact kind")
|
||||
@@ -4749,7 +4759,8 @@ class AIWorkspaceDeleteArtifactList(LoginRequiredMixin, View):
|
||||
if type not in self.allowed_types:
|
||||
return HttpResponseBadRequest("Invalid type specified")
|
||||
|
||||
person, plan = _person_plan_or_404(request, person_id, plan_id)
|
||||
person = get_object_or_404(Person, pk=person_id, user=request.user)
|
||||
plan = get_object_or_404(PatternMitigationPlan, id=plan_id, user=request.user)
|
||||
kind_key = (kind or "").strip().lower()
|
||||
if kind_key not in self.kind_map:
|
||||
return HttpResponseBadRequest("Invalid artifact kind")
|
||||
@@ -4786,7 +4797,8 @@ class AIWorkspaceEngageShare(LoginRequiredMixin, View):
|
||||
if type not in self.allowed_types:
|
||||
return HttpResponseBadRequest("Invalid type specified")
|
||||
|
||||
person, plan = _person_plan_or_404(request, person_id, plan_id)
|
||||
person = get_object_or_404(Person, pk=person_id, user=request.user)
|
||||
plan = get_object_or_404(PatternMitigationPlan, id=plan_id, user=request.user)
|
||||
|
||||
source_ref = (request.POST.get("source_ref") or "").strip()
|
||||
share_target = (request.POST.get("share_target") or "self").strip()
|
||||
@@ -5051,7 +5063,8 @@ class AIWorkspaceAutoSettings(LoginRequiredMixin, View):
|
||||
if type not in self.allowed_types:
|
||||
return HttpResponseBadRequest("Invalid type specified")
|
||||
|
||||
person, plan = _person_plan_or_404(request, person_id, plan_id)
|
||||
person = get_object_or_404(Person, pk=person_id, user=request.user)
|
||||
plan = get_object_or_404(PatternMitigationPlan, id=plan_id, user=request.user)
|
||||
auto_settings = _get_or_create_auto_settings(request.user, plan.conversation)
|
||||
|
||||
auto_settings.enabled = _is_truthy(request.POST.get("enabled"))
|
||||
@@ -5121,7 +5134,8 @@ class AIWorkspaceUpdateFundamentals(LoginRequiredMixin, View):
|
||||
if type not in self.allowed_types:
|
||||
return HttpResponseBadRequest("Invalid type specified")
|
||||
|
||||
person, plan = _person_plan_or_404(request, person_id, plan_id)
|
||||
person = get_object_or_404(Person, pk=person_id, user=request.user)
|
||||
plan = get_object_or_404(PatternMitigationPlan, id=plan_id, user=request.user)
|
||||
fundamentals_text = request.POST.get("fundamentals_text") or ""
|
||||
active_tab = _sanitize_active_tab(
|
||||
request.POST.get("active_tab"), default="fundamentals"
|
||||
@@ -5145,7 +5159,8 @@ class AIWorkspaceUpdatePlanMeta(LoginRequiredMixin, View):
|
||||
if type not in self.allowed_types:
|
||||
return HttpResponseBadRequest("Invalid type specified")
|
||||
|
||||
person, plan = _person_plan_or_404(request, person_id, plan_id)
|
||||
person = get_object_or_404(Person, pk=person_id, user=request.user)
|
||||
plan = get_object_or_404(PatternMitigationPlan, id=plan_id, user=request.user)
|
||||
active_tab = _sanitize_active_tab(
|
||||
request.POST.get("active_tab"), default="plan_board"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user