Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions service/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
def api_root(request, format=None):

return Response({
'workflows': reverse('net-list', request=request, format=format),
'transitions': reverse('transition-list', request=request, format=format),
'locations': reverse('location-list', request=request, format=format),
'arcs': reverse('arc-list', request=request, format=format),
'messages': reverse('message-list', request=request, format=format),
'workflows': reverse('workflow-list', request=request, format=format),
'cases': reverse('case-list', request=request, format=format),
'actions': reverse('action-list', request=request, format=format),
'parameters': reverse('parameter-list', request=request, format=format),
'values': reverse('value-list', request=request, format=format),
'conditions': reverse('condition-list', request=request, format=format),
'messages': reverse('message-list', request=request, format=format),
'users': reverse('user-list', request=request, format=format),
'tokens': reverse('token-list', request=request, format=format),
'groups': reverse('group-list', request=request, format=format),
})

28 changes: 28 additions & 0 deletions service/workflow/actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
"""

Action Behaviors
================

Implementations for the various behaviors action objects may have.


"""

from workflow import models


def request_data(case, action):
"""Requests a piece of data by creating a message
that is displayed by the submission form."""
request_message = models.Message(
message_type='Request',
view=action.output.view,
case=case,
response=action.output,
content='The data is requested',
section='upload'
)
request_message.save()
request_message.origin.add(action),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the actual functions that implement the behavior of action objects

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved from operations.py; still more to come.

235 changes: 192 additions & 43 deletions service/workflow/admin.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,203 @@
from django.contrib import admin
from workflow import models
from django.contrib.admin import register
from django.contrib.admin import ModelAdmin
from django.contrib.admin import SimpleListFilter

from django.core.exceptions import FieldError

from django.contrib.auth.models import User, Group

from workflow.models import Workflow
from workflow.models import Case
from workflow.models import Action
from workflow.models import Parameter
from workflow.models import Condition
from workflow.models import Message
from workflow.models import Value


class WorkflowListFilter(SimpleListFilter):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This filter is new

"""Filter an object list by workflow"""

title = 'Workflow'
parameter_name = 'workflow'
default_value = None

def lookups(self, request, model_admin):
"""Returns a list of tuples. The first element in each
tuple is the coded value for the option that will
appear in the URL query. The second element is the
human-readable name for the option that will appear
in the right sidebar."""

return sorted([(str(workflow.id), workflow.name)
for workflow in Workflow.objects.all()])

def queryset(self, request, queryset):
"""Returns the filtered queryset based on the value
provided in the query string and retrievable via
`self.value()`."""

if self.value():
try:
return queryset.filter(workflow_id=self.value())
except FieldError:
return queryset.filter(workflows=self.value())
return queryset


class CaseListFilter(SimpleListFilter):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This filter is new

"""Filter an object list by workflow"""

title = 'Case'
parameter_name = 'case'
default_value = None

def lookups(self, request, model_admin):
"""Returns a list of tuples. The first element in each
tuple is the coded value for the option that will
appear in the URL query. The second element is the
human-readable name for the option that will appear
in the right sidebar."""

return sorted([(str(case.id), case.id)
for case in Case.objects.all()])

@admin.register(models.Net)
class Net(admin.ModelAdmin):
list_display = (
def queryset(self, request, queryset):
"""Returns the filtered queryset based on the value
provided in the query string and retrievable via
`self.value()`."""

if self.value():
try:
return queryset.filter(case_id=self.value())
except FieldError:
return queryset.filter(case=self.value())
return queryset


@register(Workflow)
class WorkflowAdmin(ModelAdmin):

list_display = [
'name',
'description'
)
]

@admin.register(models.Transition)
class Transition(admin.ModelAdmin):
list_display = (
"name",
"transition_class",
)

@admin.register(models.Token)
class Token(admin.ModelAdmin):
list_display = (
'id',
@register(Case)
class CaseAdmin(ModelAdmin):

def get_workflow_name(self, object):
return object.workflow.name

get_workflow_name.admin_order_field = 'name' # Allows column order sorting
get_workflow_name.short_description = 'Workflow Name' # Renames column head

list_display = [
"id",
"get_workflow_name"
]

list_filter = [
WorkflowListFilter
]


@register(Action)
class ActionAdmin(ModelAdmin):

list_display = [
'name',
'color',
'location'
)
'description',
'action_function'
]

list_filter = [
WorkflowListFilter
]


@register(Parameter)
class ParameterAdmin(ModelAdmin):

@admin.register(models.Location)
class Location(admin.ModelAdmin):
list_display = (
list_display = [
"name",
"description"
)

@admin.register(models.Arc)
class Arc(admin.ModelAdmin):
list_display = (
"type",
"transition",
"location"
)

@admin.register(models.Case)
class Case(admin.ModelAdmin):
list_display = (
"id",
"net",
#"messages"
)
"view"
]

list_filter = [
WorkflowListFilter
]


@register(Value)
class ValueAdmin(ModelAdmin):

list_display = [
'case',
'parameter',
'value',
'state'
]

list_filter = [
WorkflowListFilter,
CaseListFilter
]


@register(Condition)
class ConditionAdmin(ModelAdmin):

def get_action_name(self, object):
return object.action.name

def get_data_name(self, object):
return object.data.name

def get_workflow_name(self, object):
return object.workflow.name

get_action_name.admin_order_field = 'name'
get_data_name.admin_order_field = 'name'
get_workflow_name.admin_order_field = 'name'

get_action_name.short_descripition = 'Action'
get_data_name.short_description = 'Data'
get_workflow_name.short_description = 'Workflow Name'

list_display = [
'get_data_name',
'state',
'type',
'get_action_name',
'get_workflow_name'
]

list_filter = [
WorkflowListFilter
]


@register(Message)
class MessageAdmin(ModelAdmin):

def get_case_id(self, object):
return object.case.id

get_case_id.admin_order_field = 'id'
get_case_id.short_description = 'case'

list_display = [
'id',
'case',
'timestamp'
]

list_filter = [
WorkflowListFilter,
CaseListFilter
]


@admin.register(models.Message)
class Message(admin.ModelAdmin):
list_display = ("id", )
#

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the admin classes got updated to reflect model changes

Loading