Skip to content

Commit

Permalink
temp-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-nfc committed Aug 21, 2024
1 parent c7dfbe7 commit 28cc3b3
Show file tree
Hide file tree
Showing 12 changed files with 696 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from .views import home

from core.views import history
from core.views import history, ticket

from settings.views import user_settings

Expand All @@ -48,6 +48,9 @@
path("history/<str:model_name>/<int:model_pk>", history.View.as_view(), name='_history'),
re_path(r'^static/(?P<path>.*)$', serve,{'document_root': settings.STATIC_ROOT}),


path('ticket/', ticket.View.as_view(), name="_ticket"),

]


Expand Down
Empty file added app/core/models/__init__.py
Empty file.
174 changes: 174 additions & 0 deletions app/core/models/comment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
from django.contrib.auth.models import User
from django.db import models
from django.forms import ValidationError

from access.models import TenancyObject

from change_ticket import ChangeTicket
from ticket.markdown import TicketMarkdown
from ticket.ticket import Ticket



class CommentCommonFields(models.Model):
Expand All @@ -26,8 +32,11 @@ class Meta:
class Comment(
TenancyObject,
CommentCommonFields,
TicketMarkdown,
):

# Validate comment organization is the same as the ticket.


class Meta:

Expand All @@ -36,3 +45,168 @@ class Meta:
'created',
'id',
]

verbose_name = "Comment"

verbose_name_plural = "Comments"



class Comment_ExternalSystem(models.TextChoices): # <null|github|gitlab>
GITHUB = '1', 'Github'
GITLAB = '2', 'Gitlab'


class CommentStatus(models.TextChoices): # <draft|open|closed|in progress|assigned|solved|invalid>
""" Comment Status
Status of the Comment. By design, not all statuses are available for ALL comment types.
## Tasks
"""

TODO = '1', 'Draft'
DONE = '2', 'New'




class CommentType(models.TextChoices):
"""Type of the ticket"""

COMMENT = '1', 'Comment'
TASK = '2', 'Task'
SOLUTION = '3', 'Solution'


parent = models.ForeignKey(
'self',
blank= True,
default = None,
help_text = 'Parent comment this comment creates a discussion with',
null = True,
on_delete=models.CASCADE,
verbose_name = 'Parent Comment',
)


comment_type = models.IntegerField(
blank = False,
choices=CommentType,
default=None,
help_text = 'The type of comment this is',
null=True,
verbose_name = 'Type',
)


ticket = models.ForeignKey(
Ticket,
blank= True,
default = None,
help_text = 'Parent comment this comment creates a discussion with',
null = True,
on_delete=models.CASCADE,
verbose_name = 'Parent Comment',
)


external_ref = models.IntegerField(
blank = True,
default=None,
help_text = 'External System reference',
null=True,
verbose_name = 'Reference Number',
) # external reference or null. i.e. github comment number


external_system = models.IntegerField(
blank = True,
choices=Comment_ExternalSystem,
default=None,
help_text = 'External system this item derives',
null=True,
verbose_name = 'External System',
)


# user


body = models.TextField(
blank = True,
default = None,
help_text = 'Body of Comment',
null = False,
verbose_name = 'Body',
) # text, markdown. validate to ensure a saved comment that does nothing creates nothing


# Duration


# is_private


status = models.IntegerField( # will require validation by ticket type as status for types will be different
blank = False,
choices=CommentStatus,
default=None,
help_text = 'Status of Comment',
null=True,
verbose_name = 'Status',
)


date_closed = models.DateTimeField(
blank = True,
help_text = 'Date closed',
null = True,
verbose_name = 'Closed Date',
)



#
# ITSM Fields
#


# Category

# is_template

# source # helpdesk|direct|phone|email

# responsible_user # user who task is for

# scheduled task # when the task is scheduled for



#
# Project Management fields
#

# planned start date

# planned finish date

# planned duration

# actual start date

# actual finish date



# def __str__(self): # ??????????? what will this need to be

# return self.name


@property
def markdown_comment(self) -> str:

return self.render_markdown(self.body)
1 change: 1 addition & 0 deletions app/core/models/ticket/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from markdown import *
14 changes: 14 additions & 0 deletions app/core/models/ticket/change_ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.forms import ValidationError


class ChangeTicket:


@property
def validate_change_ticket(self):

# check status

# check type

pass
19 changes: 19 additions & 0 deletions app/core/models/ticket/markdown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@



class TicketMarkdown:
"""Ticket and Comment markdown functions
Intended to be used for all areas of a tickets, projects and comments.
"""


def render_markdown(self, markdown):

# Requires context of ticket for ticket markdown

# Requires context of ticket for comment

# requires context of project for project task comment

pass
14 changes: 14 additions & 0 deletions app/core/models/ticket/problem_ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.forms import ValidationError


class ProblemTicket:


@property
def validate_problem_ticket(self):

# check status

# check type

pass
14 changes: 14 additions & 0 deletions app/core/models/ticket/request_ticket.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.forms import ValidationError


class RequestTicket:


@property
def validate_request_ticket(self):

# check status

# check type

pass
Loading

0 comments on commit 28cc3b3

Please sign in to comment.