0001-notifications-don-t-make-ack-imply-forget-25186.patch
combo/apps/notifications/models.py | ||
---|---|---|
42 | 42 |
return qs.filter(search_id) |
43 | 43 | |
44 | 44 |
def ack(self): |
45 |
self.filter(end_timestamp__isnull=True).update(acked=True, end_timestamp=now() - timedelta(seconds=5)) |
|
46 |
self.filter(end_timestamp__isnull=False).update(acked=True) |
|
45 |
self.update(acked=True) |
|
47 | 46 | |
48 | 47 |
def visible(self, user=None, n=None): |
49 | 48 |
qs = self |
... | ... | |
159 | 158 |
self.save(update_fields=['end_timestamp', 'acked']) |
160 | 159 | |
161 | 160 |
def ack(self): |
162 |
if self.end_timestamp: |
|
163 |
self.acked = True |
|
164 |
self.save(update_fields=['acked']) |
|
165 |
else: |
|
166 |
self.acked = True |
|
167 |
self.end_timestamp = now() - timedelta(seconds=5) |
|
168 |
self.save(update_fields=['acked', 'end_timestamp']) |
|
161 |
self.acked = True |
|
162 |
self.save(update_fields=['acked']) |
|
169 | 163 | |
170 | 164 | |
171 | 165 |
@register_cell_class |
tests/test_notification.py | ||
---|---|---|
458 | 458 | |
459 | 459 |
Notification.objects.visible(john_doe).ack() |
460 | 460 | |
461 |
# acking a notification without and end_timestamp, forget it
|
|
461 |
# acking a notification without and end_timestamp, still visible
|
|
462 | 462 |
freezer.move_to(start + timedelta(days=365, seconds=1)) |
463 | 463 |
content = cell.render(context) |
464 |
assert Notification.objects.visible(john_doe).count() == 0
|
|
465 |
assert 'notibar' not in content
|
|
464 |
assert Notification.objects.visible(john_doe).count() == 1
|
|
465 |
assert 'notibar' in content |
|
466 | 466 |
assert 'notifoo' not in content |
467 |
- |