Implement mail tracker system
* Implement mail tracking Signed-off-by: Victor "multun" Collod <victor.collod@prologin.org> * Implement task merging * Add a mail tracker title format pattern * Autocomplete task names * Fix comment display * Track notification answers * Add a socket timeout for the mail worker A mail worker is a long running application. And sometimes, the IMAP server just hangs for hours for no apparent reason. imaplib doesn't enable setting a timeout, and setting it globally seems fine. * Only validate the merge form when submitted * Redirect to the new form when merging * Prettier task edit UI * Make task merging optional * Test mail tracking * Update documentation for mail tracking * Update dependencies * Add the TODO_COMMENT_CLASSES setting * Fix dependencies install order * Remove debug leftovers, improve documentation * Fail on missing from_address
This commit is contained in:
parent
d0212b8a55
commit
c7ad961ef3
28 changed files with 1069 additions and 136 deletions
29
todo/views/task_autocomplete.py
Normal file
29
todo/views/task_autocomplete.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
from dal import autocomplete
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.decorators import method_decorator
|
||||
from todo.models import Task
|
||||
from todo.utils import user_can_read_task
|
||||
|
||||
|
||||
class TaskAutocomplete(autocomplete.Select2QuerySetView):
|
||||
@method_decorator(login_required)
|
||||
def dispatch(self, request, task_id, *args, **kwargs):
|
||||
self.task = get_object_or_404(Task, pk=task_id)
|
||||
if not user_can_read_task(self.task, request.user):
|
||||
raise PermissionDenied
|
||||
|
||||
return super().dispatch(request, task_id, *args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
# Don't forget to filter out results depending on the visitor !
|
||||
if not self.request.user.is_authenticated:
|
||||
return Task.objects.none()
|
||||
|
||||
qs = Task.objects.filter(task_list=self.task.task_list).exclude(pk=self.task.pk)
|
||||
|
||||
if self.q:
|
||||
qs = qs.filter(title__istartswith=self.q)
|
||||
|
||||
return qs
|
Loading…
Add table
Add a link
Reference in a new issue