Ejemplo n.º 1
0
class UserWidgetSerializer(serializers.ModelSerializer):
    url = HyperLinkField(view_name="api_report",
                         read_only=True,
                         lookup_mapping={
                             "widget_id": "widget",
                         })
    class Meta:
        model = UserWidgets
Ejemplo n.º 2
0
class TaskResultSerializer(serializers.ModelSerializer):
    url = HyperLinkField(view_name='api_taskresult_detail',
                         read_only=True,
                         lookup_mapping={
                             "app_uuid": "app",
                             "result_uuid": "self"
                         })

    class Meta:
        model = TaskResults
        fields = ('uuid', 'sid', 'remote_ip', 'elapsed', 'rc', 'url')
Ejemplo n.º 3
0
class WidgetSerializer(serializers.ModelSerializer):
    kind = serializers.SerializerMethodField()
    url = HyperLinkField(view_name="api_report",
                         read_only=True,
                         lookup_mapping={
                             "widget_id": "self",
                         })
    class Meta:
        model = Widgets
        fields = ('id', 'name', 'kind', 'url')

    def get_kind(self, obj):
        return obj.get_kind_display()
Ejemplo n.º 4
0
class TaskStepSerializer(serializers.ModelSerializer):
    state = serializers.SerializerMethodField()
    url = HyperLinkField(view_name='api_taskstep_result',
                         read_only=True,
                         lookup_mapping={
                             "app_uuid": "app",
                             "task_uuid": "task",
                             "step_uuid": "self"
                         })

    class Meta:
        model = TaskSteps
        fields = ('uuid', 'name', 'state', 'status', 'stepid', 'url')

    def get_state(self, obj):
        return obj.get_status_display()
Ejemplo n.º 5
0
class ScriptSerializer(serializers.ModelSerializer):
    mode = serializers.SerializerMethodField()
    url = HyperLinkField(view_name='script_update',
                         read_only=True,
                         lookup_mapping={
                             "app_uuid": "app",
                             "script_uuid": "self"
                         })

    class Meta:
        model = Scripts
        fields = ('uuid', 'name', 'mode', 'userid', 'create_user', 'app',
                  'param', 'url')

    def get_mode(self, obj):
        return obj.get_mode_display()
Ejemplo n.º 6
0
class WorkFlowSerializer(serializers.ModelSerializer):
    mode = serializers.SerializerMethodField()
    flow = serializers.SlugRelatedField(many=True,
                                        read_only=True,
                                        slug_field='name')
    url = HyperLinkField(view_name='workflow_update',
                         read_only=True,
                         lookup_mapping={
                             "app_uuid": "app",
                             "workflow_uuid": "self"
                         })

    class Meta:
        model = WorkFlows
        fields = ('uuid', 'name', 'mode', 'create_user', 'created_at', 'url',
                  'flow')

    def get_mode(self, obj):
        return obj.get_mode_display()
Ejemplo n.º 7
0
class TaskSerializer(serializers.ModelSerializer):
    progress = serializers.SerializerMethodField()
    url = HyperLinkField(view_name='api_taskstep',
                         read_only=True,
                         lookup_mapping={
                             "app_uuid": "app",
                             "task_uuid": "self"
                         })
    triggers = serializers.SerializerMethodField()

    class Meta:
        model = Tasks
        fields = ('uuid', 'user', 'progress', 'status', 'app_alias',
                  'triggers', 'url', 'start_at', 'finish_at', 'name')

    def get_progress(self, obj):
        return obj.get_status_display()

    def get_triggers(self, obj):
        return obj.get_triggers_display()
Ejemplo n.º 8
0
class RoleSerializer(serializers.ModelSerializer):
    staff = serializers.SerializerMethodField()
    rexec = serializers.SerializerMethodField()
    url = HyperLinkField(view_name='role_update', 
                     read_only=True,
                     lookup_mapping={
                         "app_uuid": "app",
                         "role_uuid": "self"})

    class Meta:
        model = AuthRoles
        fields = ('uuid', 'name', 'staff', 'rexec', 'idrange', 'created_user', \
                'created_at', 'app', 'url', 'platforms', 'users')

    def get_staff(self, obj):
        return obj.get_staff_display()

    def get_rexec(self, obj):
        maps = {"1": u"执行", "2": u"读", "4": u"写"}
        display = []
        for i in obj.rexec.split():
            display.append(maps.get(i, ""))
        return "".join(display)