clean views of trade documents
This commit is contained in:
parent
c8b0c56bbb
commit
b7e652906e
|
@ -543,7 +543,6 @@ class ConfirmDocument(ActionWithMultipleDocuments):
|
|||
if data['documents'] == OrderedSet():
|
||||
return
|
||||
|
||||
documents = []
|
||||
for doc in data['documents']:
|
||||
if not doc.lot.trade:
|
||||
return
|
||||
|
@ -553,13 +552,7 @@ class ConfirmDocument(ActionWithMultipleDocuments):
|
|||
if not doc.actions:
|
||||
continue
|
||||
|
||||
ac = doc.actions[-1]
|
||||
|
||||
if ac.t == 'ConfirmDocument' and not ac.user == g.user:
|
||||
# If document is confirmed but is not for g.user, then need confirm
|
||||
documents.append(doc)
|
||||
|
||||
if not documents:
|
||||
if not doc.trading == 'Need Confirmation':
|
||||
txt = 'No there are documents to confirm'
|
||||
raise ValidationError(txt)
|
||||
|
||||
|
@ -574,10 +567,10 @@ class RevokeDocument(ActionWithMultipleDocuments):
|
|||
This is not checked in the view becouse the list of documents is inmutable
|
||||
|
||||
"""
|
||||
# import pdb; pdb.set_trace()
|
||||
if data['documents'] == OrderedSet():
|
||||
return
|
||||
|
||||
documents = []
|
||||
for doc in data['documents']:
|
||||
if not doc.lot.trade:
|
||||
return
|
||||
|
@ -587,12 +580,7 @@ class RevokeDocument(ActionWithMultipleDocuments):
|
|||
if not doc.actions:
|
||||
continue
|
||||
|
||||
ac = doc.actions[-1]
|
||||
|
||||
if ac.t == 'ConfirmDocument' and ac.user == g.user:
|
||||
documents.append(doc)
|
||||
|
||||
if not documents:
|
||||
if not doc.trading in ['Document Confirmed', 'Confirm']:
|
||||
txt = 'No there are documents to revoke'
|
||||
raise ValidationError(txt)
|
||||
|
||||
|
@ -610,7 +598,6 @@ class ConfirmRevokeDocument(ActionWithMultipleDocuments):
|
|||
if data['documents'] == OrderedSet():
|
||||
return
|
||||
|
||||
documents = []
|
||||
for doc in data['documents']:
|
||||
if not doc.lot.trade:
|
||||
return
|
||||
|
@ -618,18 +605,13 @@ class ConfirmRevokeDocument(ActionWithMultipleDocuments):
|
|||
if not doc.actions:
|
||||
continue
|
||||
|
||||
ac = doc.actions[-1]
|
||||
|
||||
if ac.t == 'RevokeDocument' and not ac.user == g.user:
|
||||
# If document is revoke before you can Confirm now
|
||||
# and revoke is an action of one other user
|
||||
data['action'] = ac
|
||||
documents.append(doc)
|
||||
|
||||
if not documents:
|
||||
if not doc.trading == 'Revoke':
|
||||
txt = 'No there are documents with revoke for confirm'
|
||||
raise ValidationError(txt)
|
||||
|
||||
data['action'] = doc.actions[-1]
|
||||
|
||||
|
||||
class ConfirmRevoke(ActionWithMultipleDevices):
|
||||
__doc__ = m.ConfirmRevoke.__doc__
|
||||
|
|
|
@ -58,7 +58,7 @@ class TradeView():
|
|||
db.session.add(confirm_devs)
|
||||
|
||||
if self.trade.documents:
|
||||
confirm_docs = Confirm(user=g.user,
|
||||
confirm_docs = ConfirmDocument(user=g.user,
|
||||
action=self.trade,
|
||||
documents=self.trade.documents)
|
||||
db.session.add(confirm_docs)
|
||||
|
|
Reference in a new issue