[UPDT] HELPDESK: Updated helpdesk form widgets
This commit is contained in:
@@ -66,22 +66,16 @@ class FAQForm(ModelForm):
|
||||
exclude = ["is_active"]
|
||||
widgets = {
|
||||
"category": forms.HiddenInput(),
|
||||
"tags": forms.SelectMultiple(
|
||||
attrs={
|
||||
"class": "oh-select oh-select-2 select2-hidden-accessible",
|
||||
"onchange": "updateTag(this)",
|
||||
}
|
||||
),
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""
|
||||
Initializes the Ticket tag form instance.
|
||||
If an instance is provided, sets the initial value for the form's .
|
||||
"""
|
||||
"""Initializes the FAQ form instance and adjusts the tags field."""
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["tags"].choices = list(self.fields["tags"].choices)
|
||||
self.fields["tags"].choices.append(("create_new_tag", "Create new tag"))
|
||||
|
||||
if "tags" in self.fields:
|
||||
self.fields["tags"].choices = list(self.fields["tags"].choices)
|
||||
self.fields["tags"].widget.attrs.update({"onchange": "updateTag(this)"})
|
||||
self.fields["tags"].choices.append(("create_new_tag", "Create new tag"))
|
||||
|
||||
|
||||
class TicketForm(ModelForm):
|
||||
@@ -161,14 +155,6 @@ class TicketTagForm(ModelForm):
|
||||
fields = [
|
||||
"tags",
|
||||
]
|
||||
widgets = {
|
||||
"tags": forms.SelectMultiple(
|
||||
attrs={
|
||||
"class": "oh-select oh-select-2 select2-hidden-accessible",
|
||||
"onchange": "updateTag()",
|
||||
}
|
||||
),
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""
|
||||
@@ -177,7 +163,13 @@ class TicketTagForm(ModelForm):
|
||||
"""
|
||||
super().__init__(*args, **kwargs)
|
||||
request = getattr(horilla_middlewares._thread_locals, "request", None)
|
||||
if is_reportingmanager(request) or request.user.has_perm("base.add_tags"):
|
||||
|
||||
if (
|
||||
request
|
||||
and request.user.is_authenticated
|
||||
and (is_reportingmanager(request) or request.user.has_perm("base.add_tags"))
|
||||
):
|
||||
self.fields["tags"].widget.attrs.update({"onchange": "updateTag(this)"})
|
||||
self.fields["tags"].choices = list(self.fields["tags"].choices)
|
||||
self.fields["tags"].choices.append(("create_new_tag", "Create new tag"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user