cnr-ibba/IMAGE-InjectTool

Complete status update doesn't update submission detail buttons

Closed this issue · 1 comments

bunop commented

Describe the bug
Buttons don't changes their disabled class when submission goes in COMPLETED status

To Reproduce
Start InjectTool locally, and display a submission detail page. Then open python terminal with:

$ docker-compose run --rm uwsgi python manage.py shell

and simulate submission statues changes:

import asyncio
from common.helpers import send_message_to_websocket

from common.constants import WAITING, COMPLETED, SUBMITTED, STATUSES
from image_app.models import Submission

# get a submission object. Pk is the last part of the detail URL
submission_obj = Submission.objects.get(pk=1)

# define a fake method to simulate status update and message send
def fake_update(status):
    # submission_obj is taken outside this function
    submission_obj.status = status
    submission_obj.save()

    # send a message
    asyncio.get_event_loop().run_until_complete(
        send_message_to_websocket(
            {
                'message': STATUSES.get_value_display(status),
                'notification_message': submission_obj.message
            },
            submission_obj.id
        )
    )

# simulating status updates. This will set buttons correctly
fake_update(WAITING)

# simulating submitted steps. Buttons are ok
fake_update(SUBMITTED)

# simulating Completed phase. Buttons are equal to Waiting and Submitted phase
fake_update(COMPLETED)

# reloading page load buttons correctly

Expected behavior
Buttons are in the same status as for reloading the page

PR was created.