Skip to content

Commit

Permalink
Merge pull request #130 from rdmorganiser/improve_api
Browse files Browse the repository at this point in the history
Improve api
  • Loading branch information
triole authored Apr 30, 2019
2 parents cbccc69 + d8f1d1f commit b992fb5
Show file tree
Hide file tree
Showing 82 changed files with 1,332 additions and 1,881 deletions.
File renamed without changes.
84 changes: 42 additions & 42 deletions rdmo/accounts/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,61 +58,61 @@
# ('auth', 'user', 'change_user'),
# ('auth', 'user', 'delete_user'),
('auth', 'user', 'view_user'),
# ('domain', 'attribute', 'add_attribute'),
# ('domain', 'attribute', 'change_attribute'),
# ('domain', 'attribute', 'delete_attribute'),
('domain', 'attribute', 'add_attribute'),
('domain', 'attribute', 'change_attribute'),
('domain', 'attribute', 'delete_attribute'),
('domain', 'attribute', 'view_attribute'),
# ('options', 'option', 'add_option'),
# ('options', 'option', 'change_option'),
# ('options', 'option', 'delete_option'),
('options', 'option', 'add_option'),
('options', 'option', 'change_option'),
('options', 'option', 'delete_option'),
('options', 'option', 'view_option'),
# ('options', 'optionset', 'add_optionset'),
# ('options', 'optionset', 'change_optionset'),
# ('options', 'optionset', 'delete_optionset'),
('options', 'optionset', 'add_optionset'),
('options', 'optionset', 'change_optionset'),
('options', 'optionset', 'delete_optionset'),
('options', 'optionset', 'view_optionset'),
# ('conditions', 'condition', 'add_condition'),
# ('conditions', 'condition', 'change_condition'),
# ('conditions', 'condition', 'delete_condition'),
('conditions', 'condition', 'add_condition'),
('conditions', 'condition', 'change_condition'),
('conditions', 'condition', 'delete_condition'),
('conditions', 'condition', 'view_condition'),
# ('questions', 'section', 'add_section'),
# ('questions', 'section', 'change_section'),
# ('questions', 'section', 'delete_section'),
('questions', 'section', 'add_section'),
('questions', 'section', 'change_section'),
('questions', 'section', 'delete_section'),
('questions', 'section', 'view_section'),
# ('questions', 'catalog', 'add_catalog'),
# ('questions', 'catalog', 'change_catalog'),
# ('questions', 'catalog', 'delete_catalog'),
('questions', 'catalog', 'add_catalog'),
('questions', 'catalog', 'change_catalog'),
('questions', 'catalog', 'delete_catalog'),
('questions', 'catalog', 'view_catalog'),
# ('questions', 'questionset', 'add_questionset'),
# ('questions', 'questionset', 'change_questionset'),
# ('questions', 'questionset', 'delete_questionset'),
('questions', 'questionset', 'add_questionset'),
('questions', 'questionset', 'change_questionset'),
('questions', 'questionset', 'delete_questionset'),
('questions', 'questionset', 'view_questionset'),
# ('questions', 'question', 'add_question'),
# ('questions', 'question', 'change_question'),
# ('questions', 'question', 'delete_question'),
('questions', 'question', 'add_question'),
('questions', 'question', 'change_question'),
('questions', 'question', 'delete_question'),
('questions', 'question', 'view_question'),
# ('tasks', 'task', 'add_task'),
# ('tasks', 'task', 'change_task'),
# ('tasks', 'task', 'delete_task'),
('tasks', 'task', 'add_task'),
('tasks', 'task', 'change_task'),
('tasks', 'task', 'delete_task'),
('tasks', 'task', 'view_task'),
# ('views', 'view', 'add_view'),
# ('views', 'view', 'change_view'),
# ('views', 'view', 'delete_view'),
('views', 'view', 'add_view'),
('views', 'view', 'change_view'),
('views', 'view', 'delete_view'),
('views', 'view', 'view_view'),
# ('projects', 'project', 'add_project'),
# ('projects', 'project', 'change_project'),
# ('projects', 'project', 'delete_project'),
('projects', 'project', 'add_project'),
('projects', 'project', 'change_project'),
('projects', 'project', 'delete_project'),
('projects', 'project', 'view_project'),
# ('projects', 'snapshot', 'add_snapshot'),
# ('projects', 'snapshot', 'change_snapshot'),
# ('projects', 'snapshot', 'delete_snapshot'),
('projects', 'snapshot', 'add_snapshot'),
('projects', 'snapshot', 'change_snapshot'),
('projects', 'snapshot', 'delete_snapshot'),
('projects', 'snapshot', 'view_snapshot'),
# ('projects', 'value', 'add_value'),
# ('projects', 'value', 'change_value'),
# ('projects', 'value', 'delete_value'),
('projects', 'value', 'add_value'),
('projects', 'value', 'change_value'),
('projects', 'value', 'delete_value'),
('projects', 'value', 'view_value'),
# ('projects', 'membership', 'add_membership'),
# ('projects', 'membership', 'change_membership'),
# ('projects', 'membership', 'delete_membership'),
('projects', 'membership', 'add_membership'),
('projects', 'membership', 'change_membership'),
('projects', 'membership', 'delete_membership'),
('projects', 'membership', 'view_membership'),
))
)
44 changes: 0 additions & 44 deletions rdmo/accounts/tests/test_viewsets.py

This file was deleted.

1 change: 1 addition & 0 deletions rdmo/accounts/urls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from ..views import profile_update, remove_user


urlpatterns = [
# edit own profile
re_path(r'^$', profile_update, name='profile_update'),
Expand Down
14 changes: 0 additions & 14 deletions rdmo/accounts/urls/v1.py

This file was deleted.

26 changes: 0 additions & 26 deletions rdmo/accounts/viewsets.py

This file was deleted.

97 changes: 0 additions & 97 deletions rdmo/conditions/serializers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,97 +0,0 @@
from rest_framework import serializers

from rdmo.domain.models import Attribute
from rdmo.options.models import Option

from ..models import Condition
from ..validators import ConditionUniqueKeyValidator


class ConditionIndexSerializer(serializers.ModelSerializer):

target_option_path = serializers.CharField(source='target_option.path', default=None, read_only=True)
target_option_text = serializers.CharField(source='target_option.text', default=None, read_only=True)

class Meta:
model = Condition
fields = (
'id',
'key',
'comment',
'source_path',
'relation_label',
'target_text',
'target_option_path',
'target_option_text'
)


class ConditionSerializer(serializers.ModelSerializer):

key = serializers.CharField(required=True)
source = serializers.PrimaryKeyRelatedField(queryset=Attribute.objects.all(), required=True)

class Meta:
model = Condition
fields = (
'id',
'uri_prefix',
'key',
'comment',
'source',
'relation',
'target_text',
'target_option'
)
validators = (ConditionUniqueKeyValidator(), )


class AttributeOptionSerializer(serializers.ModelSerializer):

class Meta:
model = Option
fields = (
'id',
'order',
'text'
)


class AttributeSerializer(serializers.ModelSerializer):

class Meta:
model = Attribute
fields = (
'id',
'path'
)


class OptionSerializer(serializers.ModelSerializer):

class Meta:
model = Option
fields = (
'id',
'optionset',
'order',
'text',
'label'
)


class ExportSerializer(serializers.ModelSerializer):

source = serializers.CharField(source='source.uri', default=None, read_only=True)
target_option = serializers.CharField(source='target_option.uri', default=None, read_only=True)

class Meta:
model = Condition
fields = (
'uri',
'comment',
'source',
'relation',
'target_text',
'target_option'
)
23 changes: 0 additions & 23 deletions rdmo/conditions/serializers/api.py

This file was deleted.

46 changes: 46 additions & 0 deletions rdmo/conditions/serializers/v1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from rest_framework import serializers

from rdmo.domain.models import Attribute
from rdmo.options.models import Option

from ..models import Condition
from ..validators import ConditionUniqueKeyValidator


class ConditionSerializer(serializers.ModelSerializer):

key = serializers.CharField(required=True)
source = serializers.PrimaryKeyRelatedField(queryset=Attribute.objects.all(), required=True)

class Meta:
model = Condition
fields = (
'id',
'uri_prefix',
'key',
'comment',
'source',
'relation',
'target_text',
'target_option'
)
validators = (ConditionUniqueKeyValidator(), )


class ConditionIndexSerializer(serializers.ModelSerializer):

target_option_path = serializers.CharField(source='target_option.path', default=None, read_only=True)
target_option_text = serializers.CharField(source='target_option.text', default=None, read_only=True)

class Meta:
model = Condition
fields = (
'id',
'key',
'comment',
'source_path',
'relation_label',
'target_text',
'target_option_path',
'target_option_text'
)
10 changes: 5 additions & 5 deletions rdmo/conditions/static/conditions/js/conditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ angular.module('conditions', ['core'])
/* configure resources */

var resources = {
conditions: $resource(baseurl + 'api/internal/conditions/conditions/:list_route/:id/'),
attributes: $resource(baseurl + 'api/internal/conditions/attributes/:id/'),
options: $resource(baseurl + 'api/internal/conditions/options/:id/'),
relations: $resource(baseurl + 'api/internal/conditions/relations/:id/'),
settings: $resource(baseurl + 'api/internal/conditions/settings/'),
conditions: $resource(baseurl + 'api/v1/conditions/conditions/:list_route/:id/'),
relations: $resource(baseurl + 'api/v1/conditions/relations/:id/'),
attributes: $resource(baseurl + 'api/v1/domain/attributes/:id/'),
options: $resource(baseurl + 'api/v1/options/options/:id/'),
settings: $resource(baseurl + 'api/v1/core/settings/'),
};

/* configure factories */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ <h2 class="modal-title">
data-model="service.values.target_option"
data-errors="service.errors.target_option"
data-options="service.options"
data-options-label="label"
data-options-label="text"
data-options-null="1">
</formgroup>
</div>
Expand Down
Loading

0 comments on commit b992fb5

Please sign in to comment.