from ecs.workflow import register, Activity, guard from ecs.workflow.models import Foo, FooReview from django.dispatch import Signal register(Foo) foo_change = Signal() class A(Activity): class Meta: model = Foo class B(Activity): class Meta: model = Foo class C(Activity): class Meta: model = Foo class D(Activity): def is_locked(self): return not self.workflow.data.flag class Meta: model = Foo signals = (foo_change,) def on_foo_change(sender, **kwargs): sender.workflow.unlock(D)
from django.core.urlresolvers import reverse from django.utils.translation import ugettext as _ from ecs.workflow import Activity, guard, register from ecs.workflow.patterns import Generic from ecs.users.utils import get_current_user, sudo from ecs.core.models import Submission from ecs.core.models.constants import SUBMISSION_LANE_RETROSPECTIVE_THESIS from ecs.core.signals import on_initial_review, on_categorization from ecs.checklists.models import ChecklistBlueprint, Checklist, ChecklistAnswer from ecs.checklists.utils import get_checklist_answer from ecs.tasks.models import Task from ecs.tasks.utils import block_duplicate_task, block_if_task_exists register(Submission, autostart_if=lambda s, created: bool(s.current_submission_form_id) and not s.workflow and not s.is_transient) ########################## # acknowledgement guards # ########################## @guard(model=Submission) def is_acknowledged(wf): return wf.data.newest_submission_form.is_acknowledged @guard(model=Submission) def is_initial_submission(wf): return wf.data.forms.filter(is_acknowledged=True).count() == 1
from ecs.workflow import Activity, guard, register from ecs.workflow.patterns import Generic from ecs.meetings.signals import on_meeting_start, on_meeting_end from ecs.notifications.models import ( Notification, CompletionReportNotification, ProgressReportNotification, SafetyNotification, CenterCloseNotification, AmendmentNotification, NOTIFICATION_MODELS, ) for cls in NOTIFICATION_MODELS: register(cls, autostart_if=lambda n, created: n.submission_forms.exists() and not n.workflow.workflows.exists()) @guard(model=Notification) def is_susar(wf): return SafetyNotification.objects.filter(pk=wf.data.pk).exists() @guard(model=Notification) def is_report(wf): return CompletionReportNotification.objects.filter( pk=wf.data.pk).exists() or ProgressReportNotification.objects.filter( pk=wf.data.pk).exists()
from ecs.workflow import Activity, register from ecs.workflow.tests.models import Foo register(Foo) class A(Activity): class Meta: model = Foo class B(Activity): def is_repeatable(self): return True class Meta: model = Foo class C(Activity): class Meta: model = Foo class D(Activity): def is_reentrant(self): return False class Meta: model = Foo class E(Activity): class Meta: model = Foo
from datetime import datetime from django.db.models.signals import post_save from django.core.urlresolvers import reverse from django.utils.translation import ugettext as _ from ecs.workflow import Activity, guard, register from ecs.workflow.patterns import Generic from ecs.users.utils import get_current_user from ecs.core.models import Submission, ChecklistBlueprint, Checklist, Vote register(Submission, autostart_if=lambda s: bool(s.current_submission_form_id)) register(Vote) @guard(model=Submission) def is_acknowledged(wf): return wf.data.current_submission_form.acknowledged @guard(model=Submission) def is_thesis(wf): if wf.data.thesis is None: return wf.data.current_submission_form.project_type_education_context is not None return wf.data.thesis @guard(model=Submission) def has_b2vote(wf): sf = wf.data.current_submission_form if sf.current_pending_vote: return sf.current_pending_vote.result == '2' if sf.current_published_vote: return sf.current_published_vote.result == '2'
from ecs.workflow import Activity, guard, register from ecs.votes.models import Vote from ecs.core.models import AdvancedSettings def vote_workflow_start_if(vote, created): # iff all of the following conditions are true: # - there is a result # - it's either not been in a meeting or the meeting has ended # - its workflow hasn't been started already # - it's not a draft (vote preparation) return vote.result and (not vote.top_id or vote.top.meeting.ended ) and not vote.workflow and not vote.is_draft register(Vote, autostart_if=vote_workflow_start_if) @guard(model=Vote) def is_final(wf): return wf.data.is_final_version @guard(model=Vote) def internal_vote_review_required(wf): s = AdvancedSettings.objects.get() return s.require_internal_vote_review class VoteReview(Activity): class Meta:
from django.conf import settings from django.dispatch import receiver from django.core.urlresolvers import reverse from django.db.models.signals import post_save from django.utils.translation import ugettext as _ from ecs.workflow import Activity, guard, register from ecs.checklists.models import Checklist from ecs.communication.utils import send_system_message_template from ecs.tasks.signals import task_declined from ecs.users.utils import sudo from ecs.meetings.models import Meeting from ecs.billing.models import Price register(Checklist) @guard(model=Checklist) def is_external_review_checklist(wf): return wf.data.blueprint.slug == 'external_review' @guard(model=Checklist) def checklist_review_review_failed(wf): return wf.data.status == 'review_fail' class ExternalReview(Activity): class Meta: model = Checklist