javrasya / django-river

Django workflow library that supports on the fly changes ⛵
BSD 3-Clause "New" or "Revised" License
742 stars 105 forks source link

Action Button not rendering #59

Closed Qoyyuum closed 6 years ago

Qoyyuum commented 6 years ago

There is a problem with the action buttons not rendering for some odd reason.

I'm using Django 2.0.4 and applied all of the compatibility issue changes and fixed, thanks to https://github.com/javrasya/django-river/pull/56

So far implementing django-river was smooth and easy! Except for the action buttons which I have trouble setting up.

My code:

def create_action_button(obj, proceeding):
    return """
        <input
            type="button"
            style="margin:2px;2px;2px;2px;"
            value="%s"
            onclick = "location.href=\'%s\'"
        />
    """ % (proceeding.meta.transition,
            #reverse('proceed_ticket',
            #    kwargs={'ticket_id': obj.pk, 'next_state_id': proceeding.meta.transition.destination_state.pk})
            ""
            )

class ContractAdmin(admin.ModelAdmin):
    ordering = ['updated_on']
    search_fields = ['contract_number']
    list_display = ('contract_number', 'user_id', 'created_on', 'updated_on', 'contract_status', 'contract_action')
    list_filter = ('created_on', 'updated_on', 'contract_number',)
    list_per_page = 100

    def get_list_display(self, request):
        self.user = request.user
        return super(ContractAdmin, self).get_list_display(request)

    def contract_action(self, obj):
        content = ""
        for proceeding in obj.get_available_proceedings(self.user):
            content += create_action_button(obj, proceeding)

        return content

    contract_action.allow_tags = True

Here's what I got after I runserver and tried to do some workflow business processing stuff.

action-button-not-rendering

javrasya commented 6 years ago

I think it is because of Django version. With newer version of django, you need to return your html content as return format_html(content).

abd-Hirz commented 3 years ago

I have change to format_html(content) but I'm not rendering the button to be display in admin page: image image