Implment most of external ticket filing system
This commit is contained in:
parent
929f8df727
commit
be9a87fc0f
5 changed files with 22 additions and 10 deletions
|
@ -49,7 +49,8 @@ class EditItemForm(ModelForm):
|
|||
# must find other members of the groups the current list belongs to.
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditItemForm, self).__init__(*args, **kwargs)
|
||||
self.fields['assigned_to'].queryset = get_user_model().objects.filter(groups__in=[self.instance.task_list.group])
|
||||
self.fields['assigned_to'].queryset = get_user_model().objects.filter(
|
||||
groups__in=[self.instance.task_list.group])
|
||||
|
||||
due_date = forms.DateField(widget=forms.DateInput(attrs={'type': 'date'}), required=False)
|
||||
|
||||
|
@ -66,12 +67,12 @@ class AddExternalItemForm(ModelForm):
|
|||
)
|
||||
note = forms.CharField(
|
||||
widget=forms.widgets.Textarea(),
|
||||
help_text='Foo',
|
||||
help_text='Please describe the issue.',
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = Item
|
||||
exclude = ('list', 'created_date', 'due_date', 'created_by', 'assigned_to',)
|
||||
exclude = ('task_list', 'created_date', 'due_date', 'created_by', 'assigned_to',)
|
||||
|
||||
|
||||
class SearchForm(forms.Form):
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
<div id="TaskEdit">
|
||||
<h3>File Trouble Ticket</h3>
|
||||
<p>Trouble with a computer or other technical system at the J-School? <br />
|
||||
<p>Do you have a support issue? <br />
|
||||
Use this form to report the difficulty - we'll get right back to you. </p>
|
||||
|
||||
{% if form.errors %}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Dear {{ task.assigned_to.first_name }} -
|
||||
{{ task.assigned_to.first_name }} -
|
||||
|
||||
A new task on the list {{ task.task_list.name }} has been assigned to you by {{ task.created_by.first_name }} {{ task.created_by.last_name }}:
|
||||
A new task on the list {{ task.task_list.name }} has been assigned to you by {{ task.created_by.get_full_name }:
|
||||
|
||||
{{ task.title }}
|
||||
|
||||
|
|
|
@ -46,9 +46,10 @@ urlpatterns = [
|
|||
name="search"),
|
||||
|
||||
# View reorder_tasks is only called by JQuery for drag/drop task ordering
|
||||
# Fix me - this could be an op in the same view, rather than a separate view.
|
||||
path('reorder_tasks/', views.reorder_tasks, name="reorder_tasks"),
|
||||
|
||||
path('ticket/add/', views.external_add, name="external-add"),
|
||||
path('ticket/add/', views.external_add, name="external_add"),
|
||||
path('recent/added/', views.list_detail, {'list_slug': 'recent-add'}, name="recently_added"),
|
||||
path('recent/completed/', views.list_detail, {'list_slug': 'recent-complete'}, name="recently_completed"),
|
||||
]
|
||||
|
|
|
@ -290,16 +290,26 @@ def search(request):
|
|||
|
||||
@login_required
|
||||
def external_add(request):
|
||||
"""Allow users who don't have access to the rest of the ticket system to file a ticket in a specific list.
|
||||
Public tickets are unassigned unless settings.DEFAULT_ASSIGNEE exists.
|
||||
"""Allow authenticated users who don't have access to the rest of the ticket system to file a ticket
|
||||
in the list specified in settings (e.g. django-todo can be used a ticket filing system for a school, where
|
||||
students can file tickets without access to the rest of the todo system).
|
||||
|
||||
Publicly filed tickets are unassigned unless settings.DEFAULT_ASSIGNEE exists.
|
||||
"""
|
||||
|
||||
if not settings.DEFAULT_LIST_ID:
|
||||
raise RuntimeError("This feature requires DEFAULT_LIST_ID in settings. See documentation.")
|
||||
|
||||
if not TaskList.objects.filter(id=settings.DEFAULT_LIST_ID).exists():
|
||||
raise RuntimeError("There is no TaskList with ID specified for DEFAULT_LIST_ID in settings.")
|
||||
|
||||
if request.POST:
|
||||
form = AddExternalItemForm(request.POST)
|
||||
|
||||
if form.is_valid():
|
||||
current_site = Site.objects.get_current()
|
||||
item = form.save(commit=False)
|
||||
item.list_id = settings.DEFAULT_LIST_ID
|
||||
item.task_list = TaskList.objects.get(id=settings.DEFAULT_LIST_ID)
|
||||
item.created_by = request.user
|
||||
if settings.DEFAULT_ASSIGNEE:
|
||||
item.assigned_to = User.objects.get(username=settings.DEFAULT_ASSIGNEE)
|
||||
|
|
Loading…
Reference in a new issue