Skip to content

Commit

Permalink
feat(core): set project ID to match url kwarg
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-nfc committed Sep 11, 2024
1 parent 91af43a commit cfda7e5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
2 changes: 2 additions & 0 deletions app/core/forms/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def __init__(self, request, *args, **kwargs):

self.fields['status'].choices = self.Meta.model.TicketStatus.ProjectTask

self._project: int = kwargs['initial']['project']

self.fields['ticket_type'].initial = self.Meta.model.TicketType.PROJECT_TASK.value

# self.fields['status'].widget = self.fields['status'].hidden_widget()
Expand Down
9 changes: 3 additions & 6 deletions app/core/forms/validate_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,6 @@ def validate_request_ticket(self):

def validate_project_task_ticket(self):

# check status

# check type

# raise ValidationError('Test to see what it looks like')
pass
self.cleaned_data.update({
'project': self._project
})
23 changes: 20 additions & 3 deletions app/core/views/ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def get_initial(self):
'type_ticket': self.kwargs['ticket_type'],
})

if self.kwargs['ticket_type'] == 'project_task':

initial.update({
'project': int(self.kwargs['project_id'])
})

return initial


Expand Down Expand Up @@ -106,9 +112,20 @@ def get_form_kwargs(self):


def get_initial(self):
return {

initial = super().get_initial()

initial.update({
'type_ticket': self.kwargs['ticket_type'],
}
})

if self.kwargs['ticket_type'] == 'project_task':

initial.update({
'project': int(self.kwargs['project_id'])
})

return initial


def get_success_url(self, **kwargs):
Expand Down Expand Up @@ -261,7 +278,7 @@ def get_context_data(self, **kwargs):

elif self.kwargs['ticket_type'] == 'project_task':

path = 'Project Management:_project_task_view'
path = 'Project Management:_project_task_change'

url_kwargs = { 'project_id': self.object.project.id,'ticket_type': self.kwargs['ticket_type'], 'pk': self.kwargs['pk']}

Expand Down

0 comments on commit cfda7e5

Please sign in to comment.