Skip to content

Commit 3b88074

Browse files
committed
make sure the project cannot be closed when contracts are still active
1 parent d7e0b3e commit 3b88074

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

por/dashboard/events.py

+8
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ def my_validator(fs):
153153
'project name or provide unique ID!',
154154
mapping={'fs_name_value': project_id})
155155
raise ValidationError(msg)
156+
157+
if fs.activated.value == False:
158+
active_contracts = [a for a in project.contracts if a.active]
159+
if active_contracts:
160+
msg = _('You cannot deactivate project! It has uncompleted '
161+
'contracts!')
162+
raise ValidationError(msg)
163+
156164
event.fs.validator = my_validator
157165

158166

0 commit comments

Comments
 (0)