forked from 0x2620/pandora
avoid double entries in accessed table
This commit is contained in:
parent
b92d54e68d
commit
4f14b923fa
1 changed files with 7 additions and 6 deletions
|
@ -794,12 +794,13 @@ def setUI(request, data):
|
||||||
|
|
||||||
if data.get('item'):
|
if data.get('item'):
|
||||||
item = get_object_or_404_json(Item, public_id=data['item'])
|
item = get_object_or_404_json(Item, public_id=data['item'])
|
||||||
if request.user.is_authenticated():
|
with transaction.atomic():
|
||||||
access, created = Access.objects.get_or_create(item=item, user=request.user)
|
if request.user.is_authenticated():
|
||||||
else:
|
access, created = Access.objects.get_or_create(item=item, user=request.user)
|
||||||
access, created = Access.objects.get_or_create(item=item, user=None)
|
else:
|
||||||
if not created:
|
access, created = Access.objects.get_or_create(item=item, user=None)
|
||||||
access.save()
|
if not created:
|
||||||
|
access.save()
|
||||||
if data.get('document'):
|
if data.get('document'):
|
||||||
import document.models
|
import document.models
|
||||||
doc = get_object_or_404_json(document.models.Document, id=ox.fromAZ(data['document']))
|
doc = get_object_or_404_json(document.models.Document, id=ox.fromAZ(data['document']))
|
||||||
|
|
Loading…
Reference in a new issue