<commit_before>from viewflow import flow, lock, views as flow_views
from viewflow.base import this, Flow
from viewflow.site import viewsite


from .models import HelloWorldProcess
from .tasks import send_hello_world_request


class HelloWorldFlow(Flow):
    """
    Hello world

    This process demonstrates hello world approval request flow.

    1. User with *helloworld.can_start_process* permission creates hello world request
    2. Manager, who have *helloworld.can_approve_request* approves it
    3. And if request was approved, background celery job sends it to the world
    4. Elsewhere, request became cancelled
    """
    process_cls = HelloWorldProcess
    lock_impl = lock.select_for_update_lock

    start = flow.Start(flow_views.StartProcessView, fields=['text']) \
        .Permission(auto_create=True) \
        .Next(this.approve)

    approve = flow.View(flow_views.ProcessView, fields=['approved']) \
        .Permission(auto_create=True) \
        .Next(this.send)

    check_approve = flow.If(cond=lambda p: p.approved) \
        .OnTrue(this.send) \
        .OnFalse(this.end)

    send = flow.Job(send_hello_world_request) \
        .Next(this.end)

    end = flow.End()


viewsite.register(HelloWorldFlow)<commit_msg>Fix hello world sample flow<commit_after>from viewflow import flow, lock, views as flow_views
from viewflow.base import this, Flow
from viewflow.site import viewsite


from .models import HelloWorldProcess
from .tasks import send_hello_world_request


class HelloWorldFlow(Flow):
    """
    Hello world

    This process demonstrates hello world approval request flow.

    1. User with *helloworld.can_start_process* permission creates hello world request
    2. Manager, who have *helloworld.can_approve_request* approves it
    3. And if request was approved, background celery job sends it to the world
    4. Elsewhere, request became cancelled
    """
    process_cls = HelloWorldProcess
    lock_impl = lock.select_for_update_lock

    start = flow.Start(flow_views.StartProcessView, fields=['text']) \
        .Permission(auto_create=True) \
        .Next(this.approve)

    approve = flow.View(flow_views.ProcessView, fields=['approved']) \
        .Permission(auto_create=True) \
        .Next(this.check_approve)

    check_approve = flow.If(cond=lambda p: p.approved) \
        .OnTrue(this.send) \
        .OnFalse(this.end)

    send = flow.Job(send_hello_world_request) \
        .Next(this.end)

    end = flow.End()


viewsite.register(HelloWorldFlow)
{'fraction_non_alphanumeric': 0.08827037773359842, 'fraction_numerical': 0.0031809145129224653, 'mean_word_length': 3.421792618629174, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5610169', 'n_tokens_mistral': 767, 'n_tokens_neox': 730, 'n_words': 199}