Application helpdesk

The helpdesk application contains pages that manges rticket creation and project organisation.

Templates

The helpdesk application contains 5 template :

  • ticket_detail.html : helpdesk page where the details about a ticket is returned

  • ticket_list.html : helpdesk page where the created tickets are returned

  • ticket_new.html : helpdesk page where a new a ticket is created and returned

  • ticket_report.html : helpdesk page where a report about the tickets is displayed

  • ticket_timeline.html : helpdesk page where the a timeline is shown for the tickets

Key files of the « helpdesk » application

admin.py

class apps.helpdesk.admin.TicketAdmin(model, admin_site)
class apps.helpdesk.admin.TicketCategoryAdmin(model, admin_site)
class apps.helpdesk.admin.TicketMessageAdmin(model, admin_site)

models.py

class apps.helpdesk.models.Ticket(*args, **kwargs)

ticket model table

exception DoesNotExist
exception MultipleObjectsReturned
class apps.helpdesk.models.TicketCategory(id, name, description)
exception DoesNotExist
exception MultipleObjectsReturned
class apps.helpdesk.models.TicketForm(*args, **kwargs)
property media

Return all media required to render the widgets on this form.

class apps.helpdesk.models.TicketMessage(id, ticket, date, message, message_by, message_type)
exception DoesNotExist
exception MultipleObjectsReturned

views.py

apps.helpdesk.views.Ticket_detail(request, pk)

The function « Ticket_detail » renders the details of a ticket, including the ticket object and its associated messages.

Paramètres
  • request – The request object represents the HTTP request made by the user. It contains information such as the user’s browser, IP address, and any data sent with the request

  • pk – The « pk » parameter in the « Ticket_detail » function is used to identify the primary key of the ticket object that needs to be retrieved. It is typically used in the URL pattern to specify which ticket’s details should be displayed

Renvoie

a rendered HTML template with the ticket details and messages.

apps.helpdesk.views.editorjs_to_markdown(content)

The editorjs_to_markdown function converts content from the Editor.js format to Markdown format.

Paramètres

content – The content parameter is a dictionary that represents the Editor.js content. It contains a list of blocks, where each block represents a different type of content (e.g., header, paragraph, image, list, etc.). Each block has a type field that indicates the type of content,

Renvoie

The function editorjs_to_markdown returns a string that represents the Markdown conversion of the given Editor JS content.

apps.helpdesk.views.editorjs_to_slack(content)

The editorjs_to_slack function converts content from the Editor.js format to Markdown format.

Paramètres

content – The content parameter is a dictionary that represents the Editor.js content. It contains a list of blocks, where each block epresents a different type of content (e.g., header, paragraph, image, list, etc.). Each block has its own properties and data

Renvoie

a string that represents the converted Markdown content from the Editor.js content.

apps.helpdesk.views.message_to_slack(text, channel, category, title, content, from_user, date)

The function message_to_slack sends a message to a specified Slack channel with the provided text, category, title, content, from_user, and date.

Paramètres
  • text – The text parameter is the main message text that you want to send to Slack. It can be a simple string or formatted text using Markdown

  • channel – The channel parameter is the name or ID of the Slack channel where you want to send the message

  • category – The category of the message, such as « announcement », « bug report », or « feedback »

  • title – The « title » parameter is a string that represents the title of the message. It is used to provide a brief summary or description of the message content

  • content – The content parameter is the main message content that you want to send to Slack. It can be a string containing any text or information that you want to share with the channel

  • from_user – The from_user parameter is the name or username of the user who is sending the message. It is used to display the sender’s information in the Slack message

  • date – The date parameter is a datetime object that represents the date and time of the message

apps.helpdesk.views.save_ticket_message(request, pk)

The function saves a ticket message with the given request and primary key.

Paramètres
  • request – The request parameter is an object that represents the HTTP request made by the client. It contains information such as the request method, headers, body, and user information

  • pk – The « pk » parameter in the « save_ticket_message » function is the primary key of the Ticket object. It is used to retrieve the specific Ticket object from the database

Renvoie

an HttpResponse object with the string “Ok”.

apps.helpdesk.views.ticket_list(request, notif_base=None)

The function ticket_list renders the ticket_list.html template and retrieves a list of tickets based on the user’s role.

Paramètres

request – The request parameter is an object that represents the HTTP request made by the user. It contains information such as the user making the request, the method used (GET, POST, etc.), and any data sent with the request :param notif_base: The notif_base parameter is an optional parameter that is used to pass a notification base to the ticket_list function. It is not used within the function itself, but it is passed as a context variable to the rendered template. The purpose of this parameter is to provide additional information or context

Renvoie

the rendered template « helpdesk/ticket_list.html » with the context variables « tickets », « cats », and « notif_base ».

apps.helpdesk.views.ticket_list_assign(request)

The function ticket_list_assign renders the ticket_list template and passes the tickets and cats variables as context.

Paramètres

request – The request parameter is an object that represents the HTTP request made by the user. It contains information about the request, such as the user making the request, the HTTP method used (GET, POST, etc.), and any data sent with the request

Renvoie

a rendered template called « ticket_list.html » with the context variables « tickets » and « cats ».

apps.helpdesk.views.ticket_new(request)

The ticket_new function is used to create a new ticket and save it to the database, and also sends a message to Slack and creates an issue in GitLab if the ticket category is « Issue ».

Paramètres

request – The request parameter is an object that represents the HTTP request made by the client. It contains information about the request, such as the method used (GET, POST, etc.), the user making the request, and any data sent with the request

Renvoie

an HTTP response redirect to the “ticket_list” view with the “notif_base” parameter set to “Saved !”.

apps.helpdesk.views.ticket_report(request)

The function « ticket_report » renders a ticket report in a web page.

Paramètres

request – The request parameter is an object that represents the HTTP request made by the client. It contains information about the request, such as the method (GET, POST, etc.), headers, and any data sent with the request. In this case, the request parameter is used to render the

Renvoie

the rendered template « helpdesk/ticket_report.html ».

apps.helpdesk.views.ticket_timeline(request)

The function « ticket_timeline » renders a ticket timeline page.

Paramètres

request – The request parameter is an object that represents the HTTP request made by the client. It contains information about the request, such as the HTTP method, headers, and any data sent with the request. In Django, the request object is automatically passed to view functions when a request is made

Renvoie

the rendered HTML template « helpdesk/ticket_timeline.html ».

apps.helpdesk.views.update_ticket_status(request, pk, status)

The function update_ticket_status updates the status of a ticket and creates a new ticket message based on the updated status.

Paramètres
  • request – The request parameter is an object that represents the HTTP request made by the client. It contains information about the request, such as the headers, body, and user session

  • pk – The « pk » parameter is the primary key of the ticket object. It is used to identify the specific ticket that needs to be updated

  • status – The « status » parameter is an integer that represents the new status of the ticket. The possible values and their corresponding meanings are as follows:

Renvoie

a rendered HTML template with the ticket details and messages.

tests.py

class apps.helpdesk.tests.TestHelpdesk(methodName='runTest')
setUp()

Hook method for setting up the test fixture before exercising it.

tearDown()

Hook method for deconstructing the test fixture after testing it.

test_ProjectManager()

Test project manager

urls.py