mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-21 23:43:11 +01:00
Associate queues with KB categories
This commit is contained in:
parent
606098d947
commit
5f29bb632e
@ -337,7 +337,7 @@ class PublicTicketForm(AbstractTicketForm):
|
||||
help_text=_('We will e-mail you when your ticket is updated.'),
|
||||
)
|
||||
|
||||
def __init__(self, hidden_fields=(), *args, **kwargs):
|
||||
def __init__(self, hidden_fields=(), readonly_fields=(), *args, **kwargs):
|
||||
"""
|
||||
Add any (non-staff) custom fields that are defined to the form
|
||||
"""
|
||||
@ -354,6 +354,8 @@ class PublicTicketForm(AbstractTicketForm):
|
||||
setting = field_hide_table.get(field, None)
|
||||
if (setting and hasattr(settings, setting)) or field in hidden_fields:
|
||||
self.fields[field].widget = forms.HiddenInput()
|
||||
if field in readonly_fields:
|
||||
self.fields[field].disabled = True
|
||||
|
||||
self.fields['queue'].choices = [('', '--------')] + [
|
||||
(q.id, q.title) for q in Queue.objects.filter(allow_public_submission=True)]
|
||||
|
@ -1216,6 +1216,15 @@ class KBCategory(models.Model):
|
||||
_('Description'),
|
||||
)
|
||||
|
||||
queue = models.ForeignKey(
|
||||
Queue,
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=models.CASCADE,
|
||||
verbose_name=_('Default queue when creating a ticket after viewing this category.'),
|
||||
)
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return '%s' % self.title
|
||||
|
||||
|
@ -41,5 +41,9 @@
|
||||
</div>
|
||||
{% ifequal itemnumperrow 'three' %}</div>{% endifequal %}
|
||||
{% endfor %}
|
||||
{% ifnotequal itemnumperrow 'three' %}</div>{% endifnotequal %}
|
||||
{% if category.queue %}
|
||||
<a href='{% url 'helpdesk:submit' %}?queue={{category.queue.pk}};_readonly_fields_=queue'><button type="button" class="btn btn-success btn-circle btn-xl float-right"><i class="fa fa-envelope fa-lg"></i> {% trans 'Get help with this topic' %}</button></a>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
@ -92,6 +92,7 @@ class BaseCreateTicketView(FormView):
|
||||
def get_form_kwargs(self, *args, **kwargs):
|
||||
kwargs = super().get_form_kwargs(*args, **kwargs)
|
||||
kwargs['hidden_fields'] = self.request.GET.get('_hide_fields_', '').split(',')
|
||||
kwargs['readonly_fields'] = self.request.GET.get('_readonly_fields_', '').split(',')
|
||||
return kwargs
|
||||
|
||||
def form_valid(self, form):
|
||||
|
Loading…
Reference in New Issue
Block a user