Prevent resizing but allow moving tasks in Dynamic Scheduling

Hello,

I would like to allow users to move tasks in the Gantt chart
but prevent them from changing the task duration.

What is the recommended way to enforce this behavior
in Dynamic Scheduling?

Should this be implemented via save handlers or custom allocation behavior?

I’m trying to achieve this using custom allocation behavior,
but I’m not sure how to implement it correctly, and I could not find
examples of how to structure the function for this use case.

Are there any examples of enforcing fixed duration while allowing shifts?

Thanks!

Hey @YoshinoriGoto!

I didn’t find any existing solution for your problem, but it’s totally possible to use a save handler action backed by a function that check if the gap between start date and end date change or not. If it changes, raise an error, if not, proceed to the ontology edit.

Here is an example of python function:

def reschedule_test(
    log_id: str, test: Test, end_date: Timestamp | None, start_date: Timestamp | None
) -> list[OntologyEdit]:
    original_start: Timestamp | None = test.start_date
    original_end: Timestamp | None = test.end_date

    if original_start is not None and original_end is not None:
        original_duration = original_end - original_start
    else:
        original_duration = None

    if start_date is not None and end_date is not None:
        new_duration = end_date - start_date
    else:
        new_duration = None

    if original_duration is not None and new_duration is not None:
        if new_duration != original_duration:
            raise ValueError(
                f"Duration must remain unchanged. Original duration: {original_duration}, New duration: {new_duration}."
            )

    ontology_edits = FoundryClient().ontology.edits()

    test_edit = ontology_edits.objects.Test.edit(test)
    if end_date:
        test_edit.end_date = end_date
    if start_date:
        test_edit.start_date = start_date
    test_edit.log_id = log_id

    return ontology_edits.get_edits()

I hope you find this helpful. Feel free to ask if you have any question.

Nathan :slight_smile:

Hi @Donat ,

Thanks for looking into the custom allocation and for your support.
It seems that implementing this via a save handler is the right approach.

I also appreciate the code example — it helps a lot.

Thanks!