Skip to content

Commit

Permalink
Update DjangoRestFramework to 3.10.1 (#29)
Browse files Browse the repository at this point in the history
* Updated DRF to 3.5.4

* Update DRF to 3.6.4

* Updated DRF to 3.7.7

* Updated DRF to 3.8.2

* Updating DRF to 3.9.4

* Updated DRF to 3.10.1 and Markdown to 3.1.1

* Updated django-filter to 2.2.0
  • Loading branch information
aparsons authored Jul 19, 2019
1 parent e3f71b8 commit 786265f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 24 deletions.
59 changes: 41 additions & 18 deletions project/boh_api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,49 @@
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = get_user_model()
fields = ('id', 'username', 'first_name', 'last_name', 'email', 'is_active', 'last_login')
fields = ['id', 'username', 'first_name', 'last_name', 'email', 'is_active', 'last_login']
read_only_fields = fields


class TagSerializer(serializers.ModelSerializer):
class Meta:
model = models.Tag
fields = ['id', 'name', 'color', 'description']


class PersonSerializer(serializers.ModelSerializer):
class Meta:
model = models.Person
fields = ['id', 'first_name', 'last_name', 'email', 'role', 'phone_work', 'phone_mobile', 'job_title']


class OrganizationSerializer(serializers.ModelSerializer):
people = PersonSerializer(many = True, read_only = True)

class Meta:
model = models.Organization
fields = ['id', 'name', 'description', 'people']


class ActivityTypeSerializer(serializers.ModelSerializer):
class Meta:
model = models.ActivityType
fields = ['id', 'name', 'documentation']


class ActivitySerializer(serializers.ModelSerializer):
activity_type = ActivityTypeSerializer(read_only = True)
users = UserSerializer(many = True, read_only = True)

class Meta:
model = models.Activity
fields = ['id', 'status', 'description', 'open_date', 'close_date', 'duration', 'activity_type', 'engagement', 'users']


class DataElementSerializer(serializers.ModelSerializer):
class Meta:
model = models.DataElement
fields = ['id', 'name', 'description']


class ApplicationSerializer(serializers.ModelSerializer):
Expand All @@ -35,13 +66,15 @@ def get_key(self, custom_field_value):
return custom_field_value.custom_field.key

threadfix_metrics = serializers.SerializerMethodField()
organization = OrganizationSerializer(read_only=True)
tags = TagSerializer(many=True, read_only=True)
custom_fields = ApplicationCustomFieldValueSerializer(source='applicationcustomfieldvalue_set', many=True, read_only=True)
organization = OrganizationSerializer(read_only = True)
tags = TagSerializer(many = True, read_only = True)
data_elements = DataElementSerializer(many = True, read_only = True)
custom_fields = ApplicationCustomFieldValueSerializer(source='applicationcustomfieldvalue_set', many = True, read_only = True)
people = PersonSerializer(many = True, read_only = True)

class Meta:
model = models.Application
fields = ['id', 'organization', 'name', 'description', 'business_criticality', 'platform', 'lifecycle', 'origin', 'user_records', 'revenue', 'external_audience', 'internet_accessible', 'threadfix_metrics', 'tags', 'custom_fields', 'people']
fields = ['id', 'organization', 'name', 'description', 'business_criticality', 'platform', 'lifecycle', 'origin', 'user_records', 'revenue', 'external_audience', 'internet_accessible', 'threadfix_metrics', 'tags', 'data_elements', 'custom_fields', 'people']

def get_threadfix_metrics(self, application):
try:
Expand All @@ -59,21 +92,11 @@ def get_threadfix_metrics(self, application):
return None


class PersonSerializer(serializers.ModelSerializer):
class Meta:
model = models.Person


class ActivitySerializer(serializers.ModelSerializer):
class Meta:
model = models.Activity


class EngagementSerializer(serializers.ModelSerializer):
requestor = PersonSerializer(read_only = True)

class Meta:
model = models.Engagement
fields = ['id', 'status', 'start_date', 'end_date', 'description', 'open_date', 'close_date', 'duration', 'requestor', 'application']


class ActivityTypeSerializer(serializers.ModelSerializer):
class Meta:
model = models.ActivityType
5 changes: 2 additions & 3 deletions project/project/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,14 @@
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
),
'DEFAULT_FILTER_BACKENDS': (
'rest_framework.filters.DjangoFilterBackend',
),
'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend'],
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
),
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 25,
}
6 changes: 3 additions & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Django==1.11.22
django-formtools==1.0
djangorestframework==3.4.7
django-filter==1.1.0
djangorestframework==3.10.1
django-filter==2.2.0
django-widget-tweaks==1.4.1
Markdown==2.6.11
Markdown==3.1.1
phonenumbers==8.9.10
Pygments==2.2.0
pytz==2018.5
Expand Down

0 comments on commit 786265f

Please sign in to comment.