Skip to content

Commit

Permalink
fix: ticket dependences
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Nov 10, 2023
1 parent fc7be06 commit 4ee3a1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions uniticket/uni_ticket/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def __init__(self, *args, **kwargs):
user = kwargs.pop("user", None)
structure = kwargs.pop("structure", None)
current_ticket_id = kwargs.pop("ticket_id", None)
ticket_dependences_code_list = kwargs.pop("ticket_dependences", [])
ticket_dependences_pk_list = kwargs.pop("ticket_dependences", [])
ticket_id_list = []
# if user is manager/default_office operator:
# he views all tickets followed by structure offices
Expand All @@ -380,12 +380,12 @@ def __init__(self, *args, **kwargs):
ticket_id_list = TicketAssignment.get_ticket_in_office_list(
offices_list=offices_list,
taken=True)
ticket_id_list = ticket_id_list.exclude(ticket__code=current_ticket_id)
ticket_id_list = ticket_id_list.exclude(ticket__pk=current_ticket_id)
cleaned_list = [
code for code in ticket_id_list if code not in ticket_dependences_code_list
pk for pk in ticket_id_list if pk not in ticket_dependences_pk_list
]
ticket_list = Ticket.objects.filter(
code__in=cleaned_list, is_closed=False)
pk__in=cleaned_list, is_closed=False)
super().__init__(*args, **kwargs)
self.fields["ticket"].queryset = ticket_list
self.fields["ticket"].to_field_name = "code"
Expand Down
4 changes: 2 additions & 2 deletions uniticket/uni_ticket/views/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,15 +572,15 @@ def ticket_dependence_add_new(
form = TicketDependenceForm(
user=request.user,
structure=structure,
ticket_id=ticket.code,
ticket_id=ticket.pk,
ticket_dependences=ticket_dependences_code_list,
)
if request.method == "POST":
form = TicketDependenceForm(
request.POST,
user=request.user,
structure=structure,
ticket_id=ticket.code,
ticket_id=ticket.pk,
ticket_dependences=ticket_dependences_code_list,
)
if form.is_valid():
Expand Down

0 comments on commit 4ee3a1e

Please sign in to comment.