Ejemplo n.º 1
0
    def action(user_object, message, event):
        work_item = user_object.get_work_item()
        user_email = str(event['user']['email'])
        user_email = user_email.split("@")[0] + '@staff.gramedia.com'
        work_item.requested_by = user_email

        if message == "Fill your own..":
            work_item.save()
            user_object.state = OtherSoftwareType.STATE_LABEL
            user_object.save()

            send_message(text_format("Please enter your own software type"), user_object.name)
            return generate_update_response(text_format("You have chosen `%s`" % message))

        work_item.third_party = message
        work_item.save()
        user_object.state = SeverityChoice.STATE_LABEL
        user_object.save()

        if user_object.is_finished:
            user_object.state = EndState.STATE_LABEL
            user_object.save()
            card = generate_edit_work_item(work_item, EndState.STATE_LABEL)
        else:
            card = generate_choices("How severe is this issue?", work_item.severities_list, SeverityChoice.STATE_LABEL)

        send_message(card, user_object.name)
        return generate_update_response(text_format("You have chosen `%s`" % message))
Ejemplo n.º 2
0
    def action(user_object, message, event):
        work_item = user_object.get_work_item()

        user_object.is_finished = True
        user_object.save()

        if message == "save":
            user_object.is_finished = False
            user_object.save()

            path_dict = work_item.path_dict
            fields_dict = generate_fields_dict(work_item)

            work_item_dict = {}

            for key, value in path_dict.items():
                work_item_dict[value] = fields_dict[key]

            req = create_work_item(work_item_dict, create_url_of_work_item(work_item), user_object)

            user_object.state = InitialState.STATE_LABEL
            user_object.save()
            work_item.delete()

            card = generate_saved_work_item(work_item, req['_links']['html']['href'])

            send_message(card, user_object.name)
            return generate_update_response(text_format("Your work item has been saved."))

        elif message == "Title":
            user_object.state = TitleState.STATE_LABEL
            user_object.save()

            return text_format("Please enter your issue Title.")

        elif message == "Description":
            user_object.state = DescriptionState.STATE_LABEL
            user_object.save()

            return text_format("Please describe your issue.")

        elif message == "Hardware Type":
            user_object.state = HardwareChoice.STATE_LABEL
            user_object.save()

            return generate_choices("Choose Hardware Type", work_item.hardware_list, HardwareChoice.STATE_LABEL)

        elif message == "Severity":
            user_object.state = SeverityChoice.STATE_LABEL
            user_object.save()

            return generate_choices("How severe is this issue?", work_item.severities_list,
                                    SeverityChoice.STATE_LABEL)

        elif message == "Third Party":
            user_object.state = SoftwareChoice.STATE_LABEL
            user_object.save()

            return generate_choices("Choose 3rd Party Software", work_item.software_list,
                                    SoftwareChoice.STATE_LABEL)
Ejemplo n.º 3
0
    def action(user_object, message, event):
        work_item = user_object.get_work_item()
        work_item.severity = message
        work_item.save()

        user_object.state = EndState.STATE_LABEL
        user_object.save()
        card = generate_edit_work_item(work_item, EndState.STATE_LABEL)

        send_message(card, user_object.name)
        return generate_update_response(text_format("You have chosen `%s`" % message))
Ejemplo n.º 4
0
    def action(user_object, message, event):
        if message == available_types[0]:
            work_item_object = HardwareSupport.objects.create()
        elif message == available_types[1]:
            work_item_object = SoftwareSupport.objects.create()

        user_object.work_item = work_item_object
        user_object.state = TitleState.STATE_LABEL
        user_object.save()

        # For every card clicked event, update card with "You have chosen..." message and send
        # the next instruction asynchronously using the send_message() function
        send_message(text_format("Please enter your issue Title."), user_object.name)
        return generate_update_response(text_format("You have chosen `%s`" % message))
Ejemplo n.º 5
0
    def action(user_object, message, event):
        work_item = user_object.get_work_item()
        work_item.hardware_type = message
        work_item.save()
        user_object.state = SeverityChoice.STATE_LABEL
        user_object.save()

        if user_object.is_finished:
            user_object.state = EndState.STATE_LABEL
            user_object.save()
            card = generate_edit_work_item(work_item, EndState.STATE_LABEL)
        else:
            card = generate_choices("How severe is this issue?", work_item.severities_list, SeverityChoice.STATE_LABEL)

        send_message(card, user_object.name)
        return generate_update_response(text_format("You have chosen `%s`" % message))