validation.py (1280B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\campaigns\client\validation.py 2 from campaigns.client import errors 3 from jobboard.client.features.campaigns.job_restrictions import get_restricted_message_id 4 5 def check_can_commit(job): 6 if not job.objective: 7 raise errors.GenericObjectiveNotFoundError() 8 if not job.is_participant_state_unknown and not job.is_resigned: 9 raise errors.ObjectiveStateError() 10 if job.is_committed: 11 raise errors.ParticipantStateError() 12 if not job.is_active: 13 raise errors.ObjectiveStateError() 14 if job.target_progress is None: 15 raise errors.ObjectiveStateError() 16 if get_restricted_message_id(job) is not None: 17 raise errors.ParticipantStateError() 18 19 20 def check_can_resign(job): 21 if not job: 22 raise errors.GenericObjectiveNotFoundError() 23 if not job.is_committed: 24 raise errors.ParticipantStateError() 25 if not job.is_active: 26 raise errors.ObjectiveStateError() 27 if not job.remaining_personal_progress: 28 raise errors.ObjectiveStateError() 29 30 31 def check_can_redeem(project): 32 return True 33 34 35 def can_commit(job): 36 try: 37 check_can_commit(job) 38 return True 39 except RuntimeError: 40 return False