Simplify code, remove import
This commit is contained in:
@@ -3,7 +3,6 @@ from __future__ import absolute_import
|
||||
from ast import literal_eval
|
||||
|
||||
from django.db import models
|
||||
from django.utils.timezone import now
|
||||
|
||||
from .settings import RECENT_COUNT
|
||||
|
||||
@@ -34,8 +33,8 @@ class RecentDocumentManager(models.Manager):
|
||||
if user.is_authenticated():
|
||||
new_recent, created = self.model.objects.get_or_create(user=user, document=document)
|
||||
if not created:
|
||||
# document already in the recent list, just update the accessed date and time
|
||||
new_recent.datetime_accessed = now()
|
||||
# document already in the recent list, just save to force
|
||||
# accessed date and time update
|
||||
new_recent.save()
|
||||
for recent_to_delete in self.model.objects.filter(user=user)[RECENT_COUNT:]:
|
||||
recent_to_delete.delete()
|
||||
|
||||
Reference in New Issue
Block a user