Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions services/platform/apps/tickets/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ def _validate_internal_note_permission(
request: HttpRequest, user: User, is_internal: bool, ticket_pk: int
) -> HttpResponse | None:
"""Validate user permission to create internal notes."""
if is_internal and not (user.is_staff or getattr(user, "staff_role", None)):
if is_internal and not user.is_staff_user:
messages.error(request, _("❌ You do not have permission to create internal notes."))
return redirect("tickets:detail", pk=ticket_pk)
return None


def _determine_comment_type(user: User, is_internal: bool) -> str:
"""Determine the appropriate comment type based on user permissions."""
if is_internal and (user.is_staff or getattr(user, "staff_role", None)):
if is_internal and user.is_staff_user:
return "internal"
elif user.staff_role in ["support", "admin", "manager"]:
return "support"
Expand Down Expand Up @@ -426,7 +426,7 @@ def _handle_ticket_reply_post(request: HttpRequest, ticket: Ticket) -> HttpRespo

# Create comment with reply action
comment_type = _determine_comment_type(user, reply_data.is_internal)
is_public = not (reply_data.is_internal and (user.is_staff or getattr(user, "staff_role", None)))
is_public = not (reply_data.is_internal and user.is_staff_user)

logger.debug(
f"🔍 [Tickets] Reply processing: action={reply_data.reply_action}, is_internal={reply_data.is_internal}, comment_type={comment_type}, is_public={is_public}"
Expand Down Expand Up @@ -609,7 +609,7 @@ def download_attachment(request: HttpRequest, attachment_id: int) -> HttpRespons
attachment.comment
and hasattr(attachment.comment, "comment_type")
and attachment.comment.comment_type == "internal"
and not user.is_staff
and not user.is_staff_user
):
raise PermissionDenied("Access denied to internal attachments.")

Expand Down
2 changes: 1 addition & 1 deletion services/platform/templates/components/mobile_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</div>

<!-- Business Section (Staff only) -->
{% if user.is_staff or user.staff_role %}
{% if user.is_staff_user %}
<div class="space-y-4 mb-10">
<div class="px-4 py-4 text-sm font-bold text-slate-300 uppercase tracking-wider">
{% trans 'Business' %}
Expand Down
2 changes: 1 addition & 1 deletion services/platform/templates/tickets/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h1 class="text-3xl font-bold text-white mb-6">{% trans 'Ticket' %} #{{ ticket.t
<a href="{% url 'tickets:list' %}" class="inline-block align-baseline font-bold text-sm text-blue-400 hover:text-blue-300">
← {% trans 'Back to Tickets' %}
</a>
{% if ticket.status == 'closed' and user.is_staff %}
{% if ticket.status == 'closed' and user.is_staff_user %}
<!-- Reopen button for closed tickets -->
<form method="post" action="{% url 'tickets:reopen' pk=ticket.pk %}" class="inline-block">
{% csrf_token %}
Expand Down
16 changes: 8 additions & 8 deletions services/platform/templates/tickets/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
</div>
<div>
<h1 class="text-2xl font-bold text-white">
{% if user.is_staff %}
{% if user.is_staff_user %}
{% trans "Support Tickets" %}
{% else %}
{% trans "My Support Tickets" %}
{% endif %}
</h1>
<p class="text-slate-400">
{% if user.is_staff %}
{% if user.is_staff_user %}
{% trans "Manage customer support requests" %}
{% else %}
{% trans "Get help with your hosting services" %}
Expand Down Expand Up @@ -61,7 +61,7 @@ <h1 class="text-2xl font-bold text-white">
</div>
<div>
<h1 class="text-lg font-bold text-white">
{% if user.is_staff %}
{% if user.is_staff_user %}
{% trans "Tickets" %}
{% else %}
{% trans "Support Tickets" %}
Expand Down Expand Up @@ -117,7 +117,7 @@ <h1 class="text-lg font-bold text-white">
</div>
<input type="text" id="search" name="q" value="{{ search_query|default:'' }}" autocomplete="off"
class="block w-full pl-10 pr-3 py-2 border border-slate-600 rounded-lg bg-slate-700 text-white placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
placeholder="{% if user.is_staff %}{% trans 'Search by number, title or customer...' %}{% else %}{% trans 'Search' %}{% endif %}">
placeholder="{% if user.is_staff_user %}{% trans 'Search by number, title or customer...' %}{% else %}{% trans 'Search' %}{% endif %}">
</div>
</div>
<select name="status"
Expand All @@ -137,10 +137,10 @@ <h1 class="text-lg font-bold text-white">
<div class="hidden md:block bg-slate-800/50 border border-slate-700 rounded-lg overflow-hidden">
<div class="animate-pulse">
<div class="bg-slate-800 px-6 py-3">
<div class="grid {% if user.is_staff %}grid-cols-5{% else %}grid-cols-4{% endif %} gap-4">
<div class="grid {% if user.is_staff_user %}grid-cols-5{% else %}grid-cols-4{% endif %} gap-4">
<div class="h-4 bg-slate-600 rounded"></div>
<div class="h-4 bg-slate-600 rounded"></div>
{% if user.is_staff %}<div class="h-4 bg-slate-600 rounded"></div>{% endif %}
{% if user.is_staff_user %}<div class="h-4 bg-slate-600 rounded"></div>{% endif %}
<div class="h-4 bg-slate-600 rounded"></div>
<div class="h-4 bg-slate-600 rounded"></div>
</div>
Expand Down Expand Up @@ -201,10 +201,10 @@ <h1 class="text-lg font-bold text-white">
<div class="w-full bg-slate-800/50 border border-slate-700 rounded-lg overflow-hidden h-full">
<div class="animate-pulse h-full">
<div class="bg-slate-800 px-6 py-3">
<div class="grid {% if user.is_staff %}grid-cols-5{% else %}grid-cols-4{% endif %} gap-4">
<div class="grid {% if user.is_staff_user %}grid-cols-5{% else %}grid-cols-4{% endif %} gap-4">
<div class="h-4 bg-slate-600 rounded"></div>
<div class="h-4 bg-slate-600 rounded"></div>
{% if user.is_staff %}<div class="h-4 bg-slate-600 rounded"></div>{% endif %}
{% if user.is_staff_user %}<div class="h-4 bg-slate-600 rounded"></div>{% endif %}
<div class="h-4 bg-slate-600 rounded"></div>
<div class="h-4 bg-slate-600 rounded"></div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
{# HTMX Partial Template for Ticket Comments #}
{% for comment in comments %}
{# Only show internal comments to staff - following same pattern as billing templates #}
{% if comment.comment_type == 'internal' and user.is_staff %}
{% if comment.comment_type == 'internal' and user.is_staff_user %}
<div class="bg-amber-900/50 border-2 border-amber-600 rounded-xl p-6 mb-8 shadow-2xl ring-1 ring-amber-500/50">
{% elif comment.comment_type != 'internal' %}
<div class="mb-8{% if not forloop.last %} border-b border-slate-700 pb-8{% endif %}">
{% endif %}

{# Render comment content only if it should be visible #}
{% if comment.comment_type != 'internal' or user.is_staff %}
{% if comment.comment_type != 'internal' or user.is_staff_user %}
<div class="flex items-start space-x-3 sm:space-x-4">
<!-- Avatar -->
<div class="flex-shrink-0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h3 class="text-lg font-medium text-white flex items-center">
</h3>
</div>

<div class="px-6 py-4 max-h-96 overflow-y-auto" id="comments-container">
<div class="px-6 py-4 max-h-150 overflow-y-auto" id="comments-container">
{% include 'tickets/partials/comments_list.html' with comments=comments %}
</div>

Expand Down Expand Up @@ -138,7 +138,7 @@ <h3 class="text-lg font-medium text-white flex items-center">
</div>

<!-- Staff Reply Actions -->
{% if user.is_staff or user.staff_role %}
{% if user.is_staff_user %}
<div class="flex flex-col sm:flex-row sm:items-center gap-3">
<!-- Reply Action Dropdown -->
<div class="flex-1 min-w-0">
Expand Down Expand Up @@ -182,7 +182,7 @@ <h3 class="text-lg font-medium text-white flex items-center">
<div class="mt-2 flex items-center space-x-1 text-xs text-slate-500">
{% icon "info" size="xs" css_class="flex-shrink-0" %}
<p>
{% if user.is_staff or user.staff_role %}
{% if user.is_staff_user %}
{% trans 'Your reply will be visible to the customer unless marked as internal.' %}
{% else %}
{% trans 'Your reply will be visible to both you and the customer.' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-slate-300 uppercase tracking-wider">
{% trans 'Subject' %}
</th>
{% if user.is_staff %}
{% if user.is_staff_user %}
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-slate-300 uppercase tracking-wider">
{% trans 'Customer' %}
</th>
Expand Down Expand Up @@ -59,7 +59,7 @@
{% if ticket.title %}{{ ticket.title }}{% elif ticket.subject %}{{ ticket.subject }}{% else %}{{ ticket.description|truncatechars:50 }}{% endif %}
</div>
</td>
{% if user.is_staff %}
{% if user.is_staff_user %}
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-white">{{ ticket.customer.name }}</div>
{% if ticket.contact_email %}
Expand Down Expand Up @@ -137,7 +137,7 @@
<p class="text-white text-sm truncate">
{% if ticket.title %}{{ ticket.title }}{% elif ticket.subject %}{{ ticket.subject }}{% else %}{{ ticket.description|truncatechars:50 }}{% endif %}
</p>
{% if user.is_staff %}
{% if user.is_staff_user %}
<p class="text-slate-400 text-xs mt-1">{{ ticket.customer.name }}</p>
{% endif %}
</div>
Expand All @@ -164,7 +164,7 @@ <h3 class="text-lg font-medium text-white mb-2">{% trans 'No Support Tickets Fou
<p class="text-slate-400 mb-6 max-w-sm mx-auto">
{% if search_query or status_filter %}
{% trans 'No tickets match your current filters. Try adjusting your search criteria.' %}
{% elif user.is_staff %}
{% elif user.is_staff_user %}
{% trans 'No support tickets have been created yet. Customers can create tickets when they need assistance with their services.' %}
{% else %}
{% trans 'You have not created any support tickets yet. Create a ticket when you need help with your services.' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h3 class="text-lg font-medium text-white flex items-center">
</div>

<div class="relative">
<div class="px-6 py-4 max-h-96 overflow-y-auto" id="comments-container">
<div class="px-6 py-4 max-h-150 overflow-y-auto" id="comments-container">
{% comment %} replies will be inserted here {% endcomment %}
<!-- Sticky hint under header inside scrollable area (debug visible) -->
<div id="scroll-hint-sticky" class="sticky top-0 -mt-4 z-20 pointer-events-none">
Expand Down
Loading