Upgrade code
This commit is contained in:
+3
-2
@@ -1,5 +1,5 @@
|
||||
import logging
|
||||
from flask import Blueprint, jsonify, request
|
||||
from flask import Blueprint, jsonify, request, abort
|
||||
from flask_login import login_required, current_user
|
||||
from flask_socketio import emit, join_room, leave_room
|
||||
from app import db, socketio
|
||||
@@ -66,7 +66,7 @@ def mark_all_read():
|
||||
def get_comments(ticket_id):
|
||||
"""Return all visible comments for a ticket as JSON."""
|
||||
from app.models import Ticket, Comment, UserRole
|
||||
ticket = Ticket.query.get_or_404(ticket_id)
|
||||
ticket = db.session.get(Ticket, ticket_id) or abort(404)
|
||||
# Employees may only see their own tickets
|
||||
if not current_user.is_it_staff and ticket.created_by_id != current_user.id:
|
||||
return jsonify({'error': 'Forbidden'}), 403
|
||||
@@ -81,6 +81,7 @@ def get_comments(ticket_id):
|
||||
'id' : c.id,
|
||||
'author_name': c.author.full_name,
|
||||
'author_init': c.author.full_name[0].upper(),
|
||||
'author_avatar': c.author.avatar_url or '',
|
||||
'is_it_staff': c.author.is_it_staff,
|
||||
'is_internal': c.is_internal,
|
||||
'body' : c.body,
|
||||
|
||||
Reference in New Issue
Block a user