-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
132 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,75 @@ | ||
from viewflow import flow | ||
from viewflow.base import this, Flow | ||
from viewflow.site import flowsite | ||
from viewflow.views import ProcessView | ||
from viewflow.lock import select_for_update_lock | ||
|
||
from . import views | ||
from .models import ShipmentProcess, ShipmentTask | ||
|
||
|
||
class ShipmentFlow(Flow): | ||
""" | ||
Shipment delivery process | ||
""" | ||
process_cls = ShipmentProcess | ||
task_cls = ShipmentTask | ||
lock_impl = select_for_update_lock | ||
|
||
start = flow.Start(views.StartView) \ | ||
.Permission('shipment.can_start_request') \ | ||
.Next(this.split_clerk_warehouse) | ||
|
||
# clerk | ||
split_clerk_warehouse = flow.Split() \ | ||
.Next(this.shipment_type) \ | ||
.Next(this.package_goods) | ||
|
||
shipment_type = flow.View(views.ShipmentView, fields=["carrier"]) \ | ||
.Next(this.delivery_mode) \ | ||
.Assign(lambda p: p.created_by) | ||
|
||
delivery_mode = flow.If(cond=lambda p: p.is_normal_post()) \ | ||
.OnTrue(this.check_insurance) \ | ||
.OnFalse(this.request_quotes) | ||
|
||
request_quotes = flow.View(views.ShipmentView, fields=["carrier_quote"]) \ | ||
.Next(this.join_clerk_warehouse) \ | ||
.Assign(lambda p: p.created_by) | ||
|
||
check_insurance = flow.View(views.ShipmentView, fields=["need_insurance"]) \ | ||
.Next('split_on_insurance') \ | ||
.Assign(lambda p: p.created_by) | ||
|
||
split_on_insurance = flow.Split() \ | ||
.Next(this.take_extra_insurance, cond=lambda p: p.need_extra_insurance()) \ | ||
.Always(this.fill_post_label) | ||
|
||
fill_post_label = flow.View(views.ShipmentView, fields=["post_label"]) \ | ||
.Next(this.join_on_insurance) \ | ||
.Assign(lambda p: p.created_by) | ||
|
||
join_on_insurance = flow.Join() \ | ||
.Next(this.join_clerk_warehouse) | ||
|
||
# Logistic manager | ||
take_extra_insurance = flow.View(views.InsuranceView) \ | ||
.Next(this.join_on_insurance) \ | ||
.Permission('shipment.can_take_extra_insurance') | ||
|
||
# Warehouse worker | ||
package_goods = flow.View(ProcessView.as_view()) \ | ||
.Next(this.join_clerk_warehouse) \ | ||
.Permission('shipment.can_package_goods') | ||
|
||
join_clerk_warehouse = flow.Join() \ | ||
.Next(this.move_package) | ||
|
||
move_package = flow.View(ProcessView.as_view()) \ | ||
.Next(this.end) \ | ||
.Assign(this.package_goods.owner) | ||
|
||
end = flow.End() | ||
|
||
|
||
flowsite.register(ShipmentFlow) | ||
from viewflow import flow | ||
from viewflow.base import this, Flow | ||
from viewflow.site import viewsite | ||
from viewflow.views import ProcessView | ||
from viewflow.lock import select_for_update_lock | ||
|
||
from . import views | ||
from .models import ShipmentProcess, ShipmentTask | ||
|
||
|
||
class ShipmentFlow(Flow): | ||
""" | ||
Shipment delivery process | ||
""" | ||
process_cls = ShipmentProcess | ||
task_cls = ShipmentTask | ||
lock_impl = select_for_update_lock | ||
|
||
start = flow.Start(views.StartView) \ | ||
.Permission('shipment.can_start_request') \ | ||
.Next(this.split_clerk_warehouse) | ||
|
||
# clerk | ||
split_clerk_warehouse = flow.Split() \ | ||
.Next(this.shipment_type) \ | ||
.Next(this.package_goods) | ||
|
||
shipment_type = flow.View(views.ShipmentView, fields=["carrier"]) \ | ||
.Next(this.delivery_mode) \ | ||
.Assign(lambda p: p.created_by) | ||
|
||
delivery_mode = flow.If(cond=lambda p: p.is_normal_post()) \ | ||
.OnTrue(this.check_insurance) \ | ||
.OnFalse(this.request_quotes) | ||
|
||
request_quotes = flow.View(views.ShipmentView, fields=["carrier_quote"]) \ | ||
.Next(this.join_clerk_warehouse) \ | ||
.Assign(lambda p: p.created_by) | ||
|
||
check_insurance = flow.View(views.ShipmentView, fields=["need_insurance"]) \ | ||
.Next('split_on_insurance') \ | ||
.Assign(lambda p: p.created_by) | ||
|
||
split_on_insurance = flow.Split() \ | ||
.Next(this.take_extra_insurance, cond=lambda p: p.need_extra_insurance()) \ | ||
.Always(this.fill_post_label) | ||
|
||
fill_post_label = flow.View(views.ShipmentView, fields=["post_label"]) \ | ||
.Next(this.join_on_insurance) \ | ||
.Assign(lambda p: p.created_by) | ||
|
||
join_on_insurance = flow.Join() \ | ||
.Next(this.join_clerk_warehouse) | ||
|
||
# Logistic manager | ||
take_extra_insurance = flow.View(views.InsuranceView) \ | ||
.Next(this.join_on_insurance) \ | ||
.Permission('shipment.can_take_extra_insurance') | ||
|
||
# Warehouse worker | ||
package_goods = flow.View(ProcessView.as_view()) \ | ||
.Next(this.join_clerk_warehouse) \ | ||
.Permission('shipment.can_package_goods') | ||
|
||
join_clerk_warehouse = flow.Join() \ | ||
.Next(this.move_package) | ||
|
||
move_package = flow.View(ProcessView.as_view()) \ | ||
.Next(this.end) \ | ||
.Assign(this.package_goods.owner) | ||
|
||
end = flow.End() | ||
|
||
|
||
viewsite.register(ShipmentFlow) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
LayoutMixin) | ||
|
||
|
||
flowsite = ViewSite() | ||
viewsite = ViewSite() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters