diff --git a/app/core/models/ticket/ticket.py b/app/core/models/ticket/ticket.py index 29a2401c0..c75928167 100644 --- a/app/core/models/ticket/ticket.py +++ b/app/core/models/ticket/ticket.py @@ -874,7 +874,83 @@ def save(self, force_insert=False, force_update=False, using=None, update_fields if field == 'project_id': - comment_field_value = f"changed {field.replace('_id','')} to {self.project}" + value = 'None' + + if before[field]: + + value = f"$project-{before[field]}" + + to_value = getattr(self.project, 'id', 'None') + + if to_value != 'None': + + to_value = f"$project-{getattr(self.project, 'id', 'None')}" + + + comment_field_value = f"changed project from {value} to {to_value}" + + if field == 'milestone_id': + + value = 'None' + + if before[field]: + + value = f"$milestone-{before[field]}" + + to_value = getattr(self.milestone, 'id', 'None') + + if to_value != 'None': + + to_value = f"$milestone-{getattr(self.milestone, 'id', 'None')}" + + + comment_field_value = f"changed milestone from {value} to {to_value}" + + if field == 'planned_start_date': + + to_value = after[field] + + if to_value: + + to_value = str(after[field].utcfromtimestamp(after[field].timestamp()))+ '+00:00' + + comment_field_value = f"changed Planned Start Date from _{before[field]}_ to **{to_value}**" + + if field == 'planned_finish_date': + + to_value = after[field] + + if to_value: + + to_value = str(after[field].utcfromtimestamp(after[field].timestamp()))+ '+00:00' + + comment_field_value = f"changed Planned Finish Date from _{before[field]}_ to **{to_value}**" + + if field == 'real_start_date': + + to_value = after[field] + + if to_value: + + to_value = str(after[field].utcfromtimestamp(after[field].timestamp()))+ '+00:00' + + comment_field_value = f"changed Real Start Date from _{before[field]}_ to **{to_value}**" + + to_value = after[field] + + if to_value: + + to_value = str(after[field].utcfromtimestamp(after[field].timestamp()))+ '+00:00' + + if field == 'real_finish_date': + + to_value = after[field] + + if to_value: + + to_value = str(after[field].utcfromtimestamp(after[field].timestamp()))+ '+00:00' + + comment_field_value = f"changed Real Finish Date from _{before[field]}_ to **{to_value}**" if comment_field_value: diff --git a/app/core/tests/unit/ticket/test_ticket_permission.py b/app/core/tests/unit/ticket/test_ticket_permission.py index 29771fdcb..2e9b7109a 100644 --- a/app/core/tests/unit/ticket/test_ticket_permission.py +++ b/app/core/tests/unit/ticket/test_ticket_permission.py @@ -1,5 +1,7 @@ import re +from datetime import datetime + from django.contrib.auth import get_user_model from django.contrib.auth.models import AnonymousUser, User from django.contrib.contenttypes.models import ContentType @@ -15,6 +17,7 @@ from app.tests.abstract.model_permissions import ModelPermissions from project_management.models.projects import Project +from project_management.models.project_milestone import ProjectMilestone from core.models.ticket.ticket import Ticket, RelatedTickets from core.models.ticket.ticket_comment import TicketComment @@ -24,9 +27,8 @@ from settings.models.user_settings import UserSettings -class TicketPermissions( - ModelPermissions, -): + +class SetUp: ticket_type:str = None @@ -280,11 +282,9 @@ def setUpTestData(self): ) - @pytest.mark.skip(reason="To be written") - def test_permission_purge(self): - pass +class ActionComments(SetUp): def test_ticket_action_comment_assign_user_added_status_change(self): """Action Comment test @@ -829,173 +829,1035 @@ def test_ticket_action_comment_related_ticket_added_type_blocked_by_destination( @pytest.mark.skip(reason='to be written') + def test_ticket_action_comment_related_ticket_removed(self): + """Action Comment test + Confirm an action comment is created when a related ticket is removed + """ + + pass + + + def test_ticket_action_comment_project_added(self): """Action Comment test Confirm a 'project added' action comment is created for the ticket when a project is added """ - pass + from_ticket = self.item + to_ticket = self.second_item + # prepare + self.item.project = None + self.item.save() - @pytest.mark.skip(reason='to be written') - def test_ticket_action_comment_related_ticket_removed(self): + # create fresh project as id will be unique for test + project = Project.objects.create( + organization = self.item.organization, + name = 'ticket_project_add' + ) + + # add project + self.item.project = project + self.item.save() + + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) + + action_comment: bool = False + + comment_body: str = f'changed project from None to $project-{project.id}' + + for comment in comments: + + if str(comment_body).lower() == str(comment.body).lower(): + + action_comment = True + + assert action_comment + + + def test_ticket_action_comment_project_removed(self): """Action Comment test - Confirm an action comment is created when a related ticket is removed + Confirm a 'project added' action comment is created for the ticket + when a project is added """ - pass + from_ticket = self.item + to_ticket = self.second_item + # create fresh project as id will be unique for test + project = Project.objects.create( + organization = self.item.organization, + name = 'ticket_project_remove' + ) + # prepare + self.item.project = project + self.item.save() -class ITSMTicketPermissions( - TicketPermissions, - ITSMTicketFieldBasedPermissions, -): + # remove project + self.item.project = None + self.item.save() - pass + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) + + action_comment: bool = False + comment_body: str = f'changed project from $project-{project.id} to None' + for comment in comments: -class ProjectTicketPermissions( - TicketPermissions, - ProjectTicketFieldBasedPermissions, -): + if str(comment_body).lower() == str(comment.body).lower(): - pass + action_comment = True + assert action_comment -class ChangeTicketPermissions(ITSMTicketPermissions, TestCase): + def test_ticket_action_comment_project_changed(self): + """Action Comment test + Confirm a 'project added' action comment is created for the ticket + when a project is added + """ - ticket_type = 'change' + from_ticket = self.item + to_ticket = self.second_item - ticket_type_enum: int = int(Ticket.TicketType.CHANGE.value) + # create fresh project as id will be unique for test + project = Project.objects.create( + organization = self.item.organization, + name = 'ticket_project_change' + ) - app_namespace = 'ITIM' + project_two = Project.objects.create( + organization = self.item.organization, + name = 'ticket_project_change_two' + ) - url_name_view = '_ticket_change_view' + # prepare + self.item.project = project + self.item.save() - url_name_add = '_ticket_change_add' + # remove project + self.item.project = project_two + self.item.save() - url_name_change = '_ticket_change_change' + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) - url_name_delete = '_ticket_change_delete' + action_comment: bool = False - url_delete_response = reverse('ITIM:Changes') + comment_body: str = f'changed project from $project-{project.id} to $project-{project_two.id}' + for comment in comments: + if str(comment_body).lower() == str(comment.body).lower(): -class IncidentTicketPermissions(ITSMTicketPermissions, TestCase): + action_comment = True - ticket_type = 'incident' + assert action_comment - ticket_type_enum: int = int(Ticket.TicketType.INCIDENT.value) - app_namespace = 'ITIM' - url_name_view = '_ticket_incident_view' + def test_ticket_action_comment_milestone_added(self): + """Action Comment test + Confirm a 'project added' action comment is created for the ticket + when a project is added + """ - url_name_add = '_ticket_incident_add' + from_ticket = self.item + to_ticket = self.second_item - url_name_change = '_ticket_incident_change' + # create fresh project as id will be unique for test + project = Project.objects.create( + organization = self.item.organization, + name = 'ticket_project_milestone_add' + ) - url_name_delete = '_ticket_incident_delete' + milestone = ProjectMilestone.objects.create( + organization = self.item.organization, + name = 'ticket_milestone_add', + project = project + ) - url_delete_response = reverse('ITIM:Incidents') + # prepare + self.item.project = project + self.item.save() + # add milestone + self.item.milestone = milestone + self.item.save() + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) -class ProblemTicketPermissions(ITSMTicketPermissions, TestCase): + action_comment: bool = False - ticket_type = 'problem' + comment_body: str = f'changed milestone from None to $milestone-{milestone.id}' - ticket_type_enum: int = int(Ticket.TicketType.PROBLEM.value) + for comment in comments: - app_namespace = 'ITIM' + if str(comment_body).lower() == str(comment.body).lower(): - url_name_view = '_ticket_problem_view' + action_comment = True - url_name_add = '_ticket_problem_add' + assert action_comment - url_name_change = '_ticket_problem_change' - url_name_delete = '_ticket_problem_delete' + def test_ticket_action_comment_milestone_removed(self): + """Action Comment test + Confirm a 'project added' action comment is created for the ticket + when a project is added + """ - url_delete_response = reverse('ITIM:Problems') + from_ticket = self.item + to_ticket = self.second_item + # create fresh project as id will be unique for test + project = Project.objects.create( + organization = self.item.organization, + name = 'ticket_project_milestone_remove' + ) + milestone = ProjectMilestone.objects.create( + organization = self.item.organization, + name = 'ticket_milestone_remove', + project = project + ) -class ProjectTaskPermissions(ProjectTicketPermissions, TestCase): + # prepare + self.item.project = project + self.item.milestone = milestone + self.item.save() - ticket_type = 'project_task' + # remove milestone + self.item.milestone = None + self.item.save() - ticket_type_enum: int = int(Ticket.TicketType.PROJECT_TASK.value) + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) - app_namespace = 'Project Management' + action_comment: bool = False - url_name_view = '_project_task_view' + comment_body: str = f'changed milestone from $milestone-{milestone.id} to None' - url_name_add = '_project_task_add' + for comment in comments: - url_name_change = '_project_task_change' + if str(comment_body).lower() == str(comment.body).lower(): - url_name_delete = '_project_task_delete' + action_comment = True + assert action_comment + def test_ticket_action_comment_milestone_changed(self): + """Action Comment test + Confirm a 'project added' action comment is created for the ticket + when a project is added + """ - @classmethod - def setUpTestData(self): - """Setup Test + from_ticket = self.item + to_ticket = self.second_item - 1. Create an organization for user and item - . create an organization that is different to item - 2. Create a manufacturer - 3. create teams with each permission: view, add, change, delete - 4. create a user per team + # create fresh project as id will be unique for test + project = Project.objects.create( + organization = self.item.organization, + name = 'ticket_project_milestone_change' + ) + + + milestone = ProjectMilestone.objects.create( + organization = self.item.organization, + name = 'ticket_milestone_change', + project = project + ) + + + milestone_two = ProjectMilestone.objects.create( + organization = self.item.organization, + name = 'ticket_milestone_change_two', + project = project + ) + + + # prepare + self.item.project = project + self.item.milestone = milestone + self.item.save() + + # change milestone + self.item.milestone = milestone_two + self.item.save() + + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) + + action_comment: bool = False + + comment_body: str = f'changed milestone from $milestone-{milestone.id} to $milestone-{milestone_two.id}' + + for comment in comments: + + if str(comment_body).lower() == str(comment.body).lower(): + + action_comment = True + + assert action_comment + + + + def test_ticket_action_comment_planned_start_date_added(self): + """Action Comment test + + When the field `planned_start_date` has a value added it must create + an action comment """ - super().setUpTestData() + from_value = None + to_value = '2025-01-27 00:01:00+00:00' - self.item = self.model.objects.create( - organization = self.organization, - title = 'Amended ' + self.ticket_type + ' ticket', - description = 'the ticket body', - ticket_type = int(Ticket.TicketType.REQUEST.value), - opened_by = self.add_user, - status = int(Ticket.TicketStatus.All.NEW.value), - project = self.project + # prepare + self.item.planned_start_date = from_value + self.item.save() + + # add desired value + self.item.planned_start_date = datetime.strptime(to_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() + + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION ) - self.url_add_kwargs = {'project_id': self.project.id, 'ticket_type': self.ticket_type} + action_comment: bool = False - self.url_change_kwargs = {'project_id': self.project.id, 'ticket_type': self.ticket_type, 'pk': self.item.id} + comment_body: str = f'changed Planned Start Date from _{from_value}_ to **{to_value}**' - self.url_delete_kwargs = {'project_id': self.project.id, 'ticket_type': self.ticket_type, 'pk': self.project.id} + for comment in comments: - # self.url_delete_kwargs = {'pk': self.project.id} + if str(comment_body).lower() == str(comment.body).lower(): - self.url_view_kwargs = {'project_id': self.project.id, 'ticket_type': self.ticket_type, 'pk': self.item.id} + action_comment = True - self.url_delete_response = reverse('Project Management:_project_view', kwargs={'pk': self.project.id}) + assert action_comment + def test_ticket_action_comment_planned_start_date_change(self): + """Action Comment test + + When the field `planned_start_date` has a value change it must create + an action comment + """ -class RequestTicketPermissions(ITSMTicketPermissions, TestCase): + from_value = '2025-01-27 00:02:00+00:00' + to_value = '2025-01-27 00:03:00+00:00' - ticket_type = 'request' + # prepare + self.item.planned_start_date = datetime.strptime(from_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() - ticket_type_enum: int = int(Ticket.TicketType.REQUEST.value) + # add desired value + self.item.planned_start_date = datetime.strptime(to_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() - app_namespace = 'Assistance' + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) - url_name_view = '_ticket_request_view' + action_comment: bool = False - url_name_add = '_ticket_request_add' + comment_body: str = f'changed Planned Start Date from _{from_value}_ to **{to_value}**' + + for comment in comments: + + if str(comment_body).lower() == str(comment.body).lower(): + + action_comment = True + + assert action_comment + + + def test_ticket_action_comment_planned_start_date_remove(self): + """Action Comment test + + When the field `planned_start_date` has a value removed it must create + an action comment + """ + + from_value = '2025-01-27 00:02:00+00:00' + to_value = None + + # prepare + self.item.planned_start_date = datetime.strptime(from_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() + + # add desired value + self.item.planned_start_date = None + self.item.save() + + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) + + action_comment: bool = False + + comment_body: str = f'changed Planned Start Date from _{from_value}_ to **{to_value}**' + + for comment in comments: + + if str(comment_body).lower() == str(comment.body).lower(): + + action_comment = True + + assert action_comment + + + + def test_ticket_action_comment_planned_finish_date_added(self): + """Action Comment test + + When the field `planned_finish_date` has a value added it must create + an action comment + """ + + from_value = None + to_value = '2025-01-27 01:01:00+00:00' + + # prepare + self.item.planned_finish_date = from_value + self.item.save() + + # add desired value + self.item.planned_finish_date = datetime.strptime(to_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() + + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) + + action_comment: bool = False + + comment_body: str = f'changed Planned Finish Date from _{from_value}_ to **{to_value}**' + + for comment in comments: + + if str(comment_body).lower() == str(comment.body).lower(): + + action_comment = True + + assert action_comment + + + def test_ticket_action_comment_planned_finish_date_change(self): + """Action Comment test + + When the field `planned_finish_date` has a value change it must create + an action comment + """ + + from_value = '2025-01-27 01:02:00+00:00' + to_value = '2025-01-27 01:03:00+00:00' + + # prepare + self.item.planned_finish_date = datetime.strptime(from_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() + + # add desired value + self.item.planned_finish_date = datetime.strptime(to_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() + + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) + + action_comment: bool = False + + comment_body: str = f'changed Planned Finish Date from _{from_value}_ to **{to_value}**' + + for comment in comments: + + if str(comment_body).lower() == str(comment.body).lower(): + + action_comment = True + + assert action_comment + + + def test_ticket_action_comment_planned_finish_date_remove(self): + """Action Comment test + + When the field `planned_finish_date` has a value removed it must create + an action comment + """ + + from_value = '2025-01-27 01:04:00+00:00' + to_value = None + + # prepare + self.item.planned_finish_date = datetime.strptime(from_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() + + # add desired value + self.item.planned_finish_date = None + self.item.save() + + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) + + action_comment: bool = False + + comment_body: str = f'changed Planned Finish Date from _{from_value}_ to **{to_value}**' + + for comment in comments: + + if str(comment_body).lower() == str(comment.body).lower(): + + action_comment = True + + assert action_comment + + + + def test_ticket_action_comment_real_start_date_added(self): + """Action Comment test + + When the field `real_start_date` has a value added it must create + an action comment + """ + + from_value = None + to_value = '2025-01-27 00:01:00+00:00' + + # prepare + self.item.real_start_date = from_value + self.item.save() + + # add desired value + self.item.real_start_date = datetime.strptime(to_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() + + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) + + action_comment: bool = False + + comment_body: str = f'changed Real Start Date from _{from_value}_ to **{to_value}**' + + for comment in comments: + + if str(comment_body).lower() == str(comment.body).lower(): + + action_comment = True + + assert action_comment + + + def test_ticket_action_comment_real_start_date_change(self): + """Action Comment test + + When the field `real_start_date` has a value change it must create + an action comment + """ + + from_value = '2025-01-27 00:02:00+00:00' + to_value = '2025-01-27 00:03:00+00:00' + + # prepare + self.item.real_start_date = datetime.strptime(from_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() + + # add desired value + self.item.real_start_date = datetime.strptime(to_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() + + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) + + action_comment: bool = False + + comment_body: str = f'changed Real Start Date from _{from_value}_ to **{to_value}**' + + for comment in comments: + + if str(comment_body).lower() == str(comment.body).lower(): + + action_comment = True + + assert action_comment + + + def test_ticket_action_comment_real_start_date_remove(self): + """Action Comment test + + When the field `real_start_date` has a value removed it must create + an action comment + """ + + from_value = '2025-01-27 00:02:00+00:00' + to_value = None + + # prepare + self.item.real_start_date = datetime.strptime(from_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() + + # add desired value + self.item.real_start_date = None + self.item.save() + + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) + + action_comment: bool = False + + comment_body: str = f'changed Real Start Date from _{from_value}_ to **{to_value}**' + + for comment in comments: + + if str(comment_body).lower() == str(comment.body).lower(): + + action_comment = True + + assert action_comment + + + + def test_ticket_action_comment_real_finish_date_added(self): + """Action Comment test + + When the field `real_finish_date` has a value added it must create + an action comment + """ + + from_value = None + to_value = '2025-01-27 01:01:00+00:00' + + # prepare + self.item.real_finish_date = from_value + self.item.save() + + # add desired value + self.item.real_finish_date = datetime.strptime(to_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() + + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) + + action_comment: bool = False + + comment_body: str = f'changed Real Finish Date from _{from_value}_ to **{to_value}**' + + for comment in comments: + + if str(comment_body).lower() == str(comment.body).lower(): + + action_comment = True + + assert action_comment + + + def test_ticket_action_comment_real_finish_date_change(self): + """Action Comment test + + When the field `real_finish_date` has a value change it must create + an action comment + """ + + from_value = '2025-01-27 01:02:00+00:00' + to_value = '2025-01-27 01:03:00+00:00' + + # prepare + self.item.real_finish_date = datetime.strptime(from_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() + + # add desired value + self.item.real_finish_date = datetime.strptime(to_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() + + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) + + action_comment: bool = False + + comment_body: str = f'changed Real Finish Date from _{from_value}_ to **{to_value}**' + + for comment in comments: + + if str(comment_body).lower() == str(comment.body).lower(): + + action_comment = True + + assert action_comment + + + def test_ticket_action_comment_real_finish_date_remove(self): + """Action Comment test + + When the field `real_finish_date` has a value removed it must create + an action comment + """ + + from_value = '2025-01-27 01:04:00+00:00' + to_value = None + + # prepare + self.item.real_finish_date = datetime.strptime(from_value, '%Y-%m-%d %H:%M:%S%z') + self.item.save() + + # add desired value + self.item.real_finish_date = None + self.item.save() + + comments = TicketComment.objects.filter( + ticket=self.item, + comment_type = TicketComment.CommentType.ACTION + ) + + action_comment: bool = False + + comment_body: str = f'changed Real Finish Date from _{from_value}_ to **{to_value}**' + + for comment in comments: + + if str(comment_body).lower() == str(comment.body).lower(): + + action_comment = True + + assert action_comment + + + +class TicketPermissions( + SetUp, + ModelPermissions, +): + + + @pytest.mark.skip(reason="To be written") + def test_permission_purge(self): + + pass + + + +class ITSMTicketPermissions( + TicketPermissions, + ITSMTicketFieldBasedPermissions, +): + + pass + + + +class ProjectTicketPermissions( + TicketPermissions, + ProjectTicketFieldBasedPermissions, +): + + pass + + + +class ChangeTicketPermissions(ITSMTicketPermissions, TestCase): + + ticket_type = 'change' + + ticket_type_enum: int = int(Ticket.TicketType.CHANGE.value) + + app_namespace = 'ITIM' + + url_name_view = '_ticket_change_view' + + url_name_add = '_ticket_change_add' + + url_name_change = '_ticket_change_change' + + url_name_delete = '_ticket_change_delete' + + url_delete_response = reverse('ITIM:Changes') + + + +class IncidentTicketPermissions(ITSMTicketPermissions, TestCase): + + ticket_type = 'incident' + + ticket_type_enum: int = int(Ticket.TicketType.INCIDENT.value) + + app_namespace = 'ITIM' + + url_name_view = '_ticket_incident_view' + + url_name_add = '_ticket_incident_add' + + url_name_change = '_ticket_incident_change' + + url_name_delete = '_ticket_incident_delete' + + url_delete_response = reverse('ITIM:Incidents') + + + +class ProblemTicketPermissions(ITSMTicketPermissions, TestCase): + + ticket_type = 'problem' + + ticket_type_enum: int = int(Ticket.TicketType.PROBLEM.value) + + app_namespace = 'ITIM' + + url_name_view = '_ticket_problem_view' + + url_name_add = '_ticket_problem_add' + + url_name_change = '_ticket_problem_change' + + url_name_delete = '_ticket_problem_delete' + + url_delete_response = reverse('ITIM:Problems') + + + +class ProjectTaskPermissions(ProjectTicketPermissions, TestCase): + + ticket_type = 'project_task' + + ticket_type_enum: int = int(Ticket.TicketType.PROJECT_TASK.value) + + app_namespace = 'Project Management' + + url_name_view = '_project_task_view' + + url_name_add = '_project_task_add' + + url_name_change = '_project_task_change' + + url_name_delete = '_project_task_delete' + + + + + @classmethod + def setUpTestData(self): + """Setup Test + + 1. Create an organization for user and item + . create an organization that is different to item + 2. Create a manufacturer + 3. create teams with each permission: view, add, change, delete + 4. create a user per team + """ + + super().setUpTestData() + + self.item = self.model.objects.create( + organization = self.organization, + title = 'Amended ' + self.ticket_type + ' ticket', + description = 'the ticket body', + ticket_type = int(Ticket.TicketType.REQUEST.value), + opened_by = self.add_user, + status = int(Ticket.TicketStatus.All.NEW.value), + project = self.project + ) + + self.url_add_kwargs = {'project_id': self.project.id, 'ticket_type': self.ticket_type} + + self.url_change_kwargs = {'project_id': self.project.id, 'ticket_type': self.ticket_type, 'pk': self.item.id} + + self.url_delete_kwargs = {'project_id': self.project.id, 'ticket_type': self.ticket_type, 'pk': self.project.id} + + # self.url_delete_kwargs = {'pk': self.project.id} + + self.url_view_kwargs = {'project_id': self.project.id, 'ticket_type': self.ticket_type, 'pk': self.item.id} + + self.url_delete_response = reverse('Project Management:_project_view', kwargs={'pk': self.project.id}) + + + +class RequestTicketPermissions(ITSMTicketPermissions, TestCase): + + ticket_type = 'request' + + ticket_type_enum: int = int(Ticket.TicketType.REQUEST.value) + + app_namespace = 'Assistance' + + url_name_view = '_ticket_request_view' + + url_name_add = '_ticket_request_add' + + url_name_change = '_ticket_request_change' + + url_name_delete = '_ticket_request_delete' + + url_delete_response = reverse('Assistance:Requests') + + + + + +class ChangeTicketActionComments(ActionComments, TestCase): + + ticket_type = 'change' + + ticket_type_enum: int = int(Ticket.TicketType.CHANGE.value) + + app_namespace = 'ITIM' + + url_name_view = '_ticket_change_view' + + url_name_add = '_ticket_change_add' + + url_name_change = '_ticket_change_change' + + url_name_delete = '_ticket_change_delete' + + url_delete_response = reverse('ITIM:Changes') + + + +class IncidentTicketActionComments(ActionComments, TestCase): + + ticket_type = 'incident' + + ticket_type_enum: int = int(Ticket.TicketType.INCIDENT.value) + + app_namespace = 'ITIM' + + url_name_view = '_ticket_incident_view' + + url_name_add = '_ticket_incident_add' + + url_name_change = '_ticket_incident_change' + + url_name_delete = '_ticket_incident_delete' + + url_delete_response = reverse('ITIM:Incidents') + + + +class ProblemTicketActionComments(ActionComments, TestCase): + + ticket_type = 'problem' + + ticket_type_enum: int = int(Ticket.TicketType.PROBLEM.value) + + app_namespace = 'ITIM' + + url_name_view = '_ticket_problem_view' + + url_name_add = '_ticket_problem_add' + + url_name_change = '_ticket_problem_change' + + url_name_delete = '_ticket_problem_delete' + + url_delete_response = reverse('ITIM:Problems') + + + +class ProjectTaskActionComments(ActionComments, TestCase): + + ticket_type = 'project_task' + + ticket_type_enum: int = int(Ticket.TicketType.PROJECT_TASK.value) + + app_namespace = 'Project Management' + + url_name_view = '_project_task_view' + + url_name_add = '_project_task_add' + + url_name_change = '_project_task_change' + + url_name_delete = '_project_task_delete' + + + + + @classmethod + def setUpTestData(self): + """Setup Test + + 1. Create an organization for user and item + . create an organization that is different to item + 2. Create a manufacturer + 3. create teams with each permission: view, add, change, delete + 4. create a user per team + """ + + super().setUpTestData() + + self.item = self.model.objects.create( + organization = self.organization, + title = 'Amended ' + self.ticket_type + ' ticket', + description = 'the ticket body', + ticket_type = int(Ticket.TicketType.REQUEST.value), + opened_by = self.add_user, + status = int(Ticket.TicketStatus.All.NEW.value), + project = self.project + ) + + self.url_add_kwargs = {'project_id': self.project.id, 'ticket_type': self.ticket_type} + + self.url_change_kwargs = {'project_id': self.project.id, 'ticket_type': self.ticket_type, 'pk': self.item.id} + + self.url_delete_kwargs = {'project_id': self.project.id, 'ticket_type': self.ticket_type, 'pk': self.project.id} + + # self.url_delete_kwargs = {'pk': self.project.id} + + self.url_view_kwargs = {'project_id': self.project.id, 'ticket_type': self.ticket_type, 'pk': self.item.id} + + self.url_delete_response = reverse('Project Management:_project_view', kwargs={'pk': self.project.id}) + + + +class RequestTicketActionComments(ActionComments, TestCase): + + ticket_type = 'request' + + ticket_type_enum: int = int(Ticket.TicketType.REQUEST.value) + + app_namespace = 'Assistance' + + url_name_view = '_ticket_request_view' + + url_name_add = '_ticket_request_add' + + url_name_change = '_ticket_request_change' + + url_name_delete = '_ticket_request_delete' + + url_delete_response = reverse('Assistance:Requests') - url_name_change = '_ticket_request_change' - url_name_delete = '_ticket_request_delete' - url_delete_response = reverse('Assistance:Requests') diff --git a/docs/projects/centurion_erp/index.md b/docs/projects/centurion_erp/index.md index 17c779ad2..71ef2ed1f 100644 --- a/docs/projects/centurion_erp/index.md +++ b/docs/projects/centurion_erp/index.md @@ -137,7 +137,7 @@ Below is a list of modules/features we intend to add to Centurion. To find out w - Software _[see #3](https://github.com/nofusscomputing/centurion_erp/issues/3)_ - - IT Operations + - IT Operations _[see #493](https://github.com/nofusscomputing/centurion_erp/issues/493)_ - Release and Deployment Management _[see #462](https://github.com/nofusscomputing/centurion_erp/issues/462)_