Disallow changing worktype labels, don't show deleted employment

This commit is contained in:
Tanner Collin 2018-01-21 22:59:40 +00:00
parent 8a1f067e44
commit b5432060c0
3 changed files with 11 additions and 3 deletions

View File

@ -18,12 +18,17 @@ class WorkTypeSerializer(serializers.ModelSerializer):
class Meta:
model = WorkType
fields = ('uuid', 'color', 'label', 'deleted')
read_only_fields =('deleted',)
read_only_fields = ('deleted',)
def create(self, validated_data):
validated_data['client'] = self.context['request'].user.client
return serializers.ModelSerializer.create(self, validated_data)
def update(self, instance, validated_data):
if 'label' in validated_data:
raise serializers.ValidationError("Cannot update field.")
return super().update(instance, validated_data)
class PriceSerializer(serializers.ModelSerializer):
get_employee_uuid = serializers.UUIDField(write_only=True)
get_work_type_uuid = serializers.UUIDField(write_only=True)
@ -32,7 +37,7 @@ class PriceSerializer(serializers.ModelSerializer):
class Meta:
model = Price
fields = ('uuid', 'get_employee_uuid', 'get_work_type_uuid', 'work_type', 'amount', 'deleted')
read_only_fields =('deleted',)
read_only_fields = ('deleted',)
depth = 1
def create(self, validated_data):

View File

@ -88,7 +88,8 @@ class EmployerViewSet(viewsets.ModelViewSet):
http_method_names = ['get', 'head', 'put', 'options']
def get_queryset(self):
return Manage.objects.filter(provider__user__username=self.request.user)
return Manage.objects.filter(provider__user__username=self.request.user) \
.filter(deleted=False)
class PriceViewSet(viewsets.ModelViewSet):
lookup_field = 'uuid'

View File

@ -82,6 +82,8 @@ REST_FRAMEWORK = {
CORS_ORIGIN_WHITELIST = (
'localhost:3000',
'caremyway.ca',
'www.caremyway.ca',
)
MIDDLEWARE = [