make per item document info editable if user can edit item
This commit is contained in:
parent
c19f80f2e5
commit
df44b0daf4
4 changed files with 11 additions and 6 deletions
|
|
@ -98,12 +98,13 @@ class Document(models.Model):
|
|||
def get_id(self):
|
||||
return ox.toAZ(self.id)
|
||||
|
||||
def editable(self, user):
|
||||
def editable(self, user, item=None):
|
||||
if not user or user.is_anonymous():
|
||||
return False
|
||||
if self.user == user or \
|
||||
user.is_staff or \
|
||||
user.get_profile().capability('canEditDocuments') == True:
|
||||
user.get_profile().capability('canEditDocuments') == True or \
|
||||
(item and item.editable(user)):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -82,8 +82,8 @@ def editDocument(request):
|
|||
item = 'item' in data and Item.objects.get(itemId=data['item']) or None
|
||||
if data['id']:
|
||||
document = models.Document.get(data['id'])
|
||||
if document.editable(request.user):
|
||||
document.edit(data, request.user, item=item)
|
||||
if document.editable(request.user, item):
|
||||
document.edit(data, request.user, item)
|
||||
document.save()
|
||||
response['data'] = document.json(user=request.user, item=item)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue