Rename shift's approved to provider_approved
This commit is contained in:
parent
f34115736b
commit
967a061d3d
20
caremyway/api/migrations/0003_auto_20180622_0338.py
Normal file
20
caremyway/api/migrations/0003_auto_20180622_0338.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.1 on 2018-06-22 03:38
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('api', '0002_shift_approved'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='shift',
|
||||||
|
old_name='approved',
|
||||||
|
new_name='provider_approved',
|
||||||
|
),
|
||||||
|
]
|
|
@ -65,5 +65,5 @@ class Shift(models.Model):
|
||||||
actual_end = models.DateTimeField(null=True)
|
actual_end = models.DateTimeField(null=True)
|
||||||
description = models.CharField(max_length=100, null=True)
|
description = models.CharField(max_length=100, null=True)
|
||||||
chart = models.TextField(max_length=1000, null=True)
|
chart = models.TextField(max_length=1000, null=True)
|
||||||
approved = models.NullBooleanField(blank=True)
|
provider_approved = models.NullBooleanField(blank=True)
|
||||||
deleted = models.BooleanField(default=False)
|
deleted = models.BooleanField(default=False)
|
||||||
|
|
|
@ -196,8 +196,8 @@ class CShiftSerializer(ShiftSerializer):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Shift
|
model = Shift
|
||||||
fields = ('uuid', 'chart', 'get_price_uuid', 'price', 'set_price', 'set_date', 'set_start', 'set_end', 'actual_start', 'actual_end', 'amount', 'description', 'approved', 'deleted')
|
fields = ('uuid', 'chart', 'get_price_uuid', 'price', 'set_price', 'set_date', 'set_start', 'set_end', 'actual_start', 'actual_end', 'amount', 'description', 'provider_approved', 'deleted')
|
||||||
read_only_fields = ('chart', 'price', 'set_price', 'set_date', 'actual_start', 'actual_end', 'approved', 'deleted')
|
read_only_fields = ('chart', 'price', 'set_price', 'set_date', 'actual_start', 'actual_end', 'provider_approved', 'deleted')
|
||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
user = self.context['request'].user
|
user = self.context['request'].user
|
||||||
|
@ -240,7 +240,7 @@ class CShiftSerializer(ShiftSerializer):
|
||||||
raise serializers.ValidationError("Can't update after check in.")
|
raise serializers.ValidationError("Can't update after check in.")
|
||||||
|
|
||||||
# Reset approval on update
|
# Reset approval on update
|
||||||
instance.approved = None
|
instance.provider_approved = None
|
||||||
|
|
||||||
return super().update(instance, validated_data)
|
return super().update(instance, validated_data)
|
||||||
|
|
||||||
|
@ -249,31 +249,31 @@ class PShiftSerializer(ShiftSerializer):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Shift
|
model = Shift
|
||||||
fields = ('uuid', 'action', 'chart', 'price', 'set_price', 'set_date', 'set_start', 'set_end', 'actual_start', 'actual_end', 'amount', 'description', 'approved', 'deleted')
|
fields = ('uuid', 'action', 'chart', 'price', 'set_price', 'set_date', 'set_start', 'set_end', 'actual_start', 'actual_end', 'amount', 'description', 'provider_approved', 'deleted')
|
||||||
read_only_fields = ('uuid', 'price', 'set_price', 'set_date', 'set_start', 'set_end', 'actual_start', 'actual_end', 'description', 'deleted')
|
read_only_fields = ('uuid', 'price', 'set_price', 'set_date', 'set_start', 'set_end', 'actual_start', 'actual_end', 'description', 'deleted')
|
||||||
|
|
||||||
def update(self, instance, validated_data):
|
def update(self, instance, validated_data):
|
||||||
approved = validated_data['approved']
|
provider_approved = validated_data['provider_approved']
|
||||||
action = validated_data['action']
|
action = validated_data['action']
|
||||||
chart = validated_data['chart']
|
chart = validated_data['chart']
|
||||||
|
|
||||||
if approved == True:
|
if provider_approved == True:
|
||||||
if instance.deleted:
|
if instance.deleted:
|
||||||
raise serializers.ValidationError("Shift was deleted.")
|
raise serializers.ValidationError("Shift was deleted.")
|
||||||
|
|
||||||
instance.approved = True
|
instance.provider_approved = True
|
||||||
|
|
||||||
elif approved == False:
|
elif provider_approved == False:
|
||||||
if instance.actual_start:
|
if instance.actual_start:
|
||||||
raise serializers.ValidationError("Can't disapprove after check in.")
|
raise serializers.ValidationError("Can't disapprove after check in.")
|
||||||
|
|
||||||
instance.approved = False
|
instance.provider_approved = False
|
||||||
|
|
||||||
if action == 'checkin':
|
if action == 'checkin':
|
||||||
if instance.deleted:
|
if instance.deleted:
|
||||||
raise serializers.ValidationError("Shift was deleted.")
|
raise serializers.ValidationError("Shift was deleted.")
|
||||||
if not instance.approved:
|
if not instance.provider_approved:
|
||||||
raise serializers.ValidationError("Shift hasn't been approved.")
|
raise serializers.ValidationError("Shift hasn't been approved by the provider..")
|
||||||
if instance.actual_start:
|
if instance.actual_start:
|
||||||
raise serializers.ValidationError("Already checked in.")
|
raise serializers.ValidationError("Already checked in.")
|
||||||
if chart:
|
if chart:
|
||||||
|
|
|
@ -120,7 +120,7 @@ def shift_filter(get_self):
|
||||||
user = get_self.request.user
|
user = get_self.request.user
|
||||||
qp = get_self.request.query_params
|
qp = get_self.request.query_params
|
||||||
completed = validate_param(qp.get('completed', 'unspecified'), serializers.BooleanField())
|
completed = validate_param(qp.get('completed', 'unspecified'), serializers.BooleanField())
|
||||||
approved = validate_param(qp.get('approved', 'unspecified'), serializers.NullBooleanField())
|
provider_approved = validate_param(qp.get('provider_approved', 'unspecified'), serializers.NullBooleanField())
|
||||||
manage = validate_param(qp.get('manage'), serializers.UUIDField(allow_null=True))
|
manage = validate_param(qp.get('manage'), serializers.UUIDField(allow_null=True))
|
||||||
work_type = validate_param(qp.get('work_type'), serializers.UUIDField(allow_null=True))
|
work_type = validate_param(qp.get('work_type'), serializers.UUIDField(allow_null=True))
|
||||||
|
|
||||||
|
@ -128,11 +128,11 @@ def shift_filter(get_self):
|
||||||
.filter(
|
.filter(
|
||||||
Q(price__management__client__user__username=user)
|
Q(price__management__client__user__username=user)
|
||||||
| Q(price__management__provider__user__username=user)) \
|
| Q(price__management__provider__user__username=user)) \
|
||||||
.order_by('approved', 'set_start')
|
.order_by('provider_approved', 'set_start')
|
||||||
if completed is not 'unspecified':
|
if completed is not 'unspecified':
|
||||||
shifts = shifts.exclude(actual_end__isnull=completed)
|
shifts = shifts.exclude(actual_end__isnull=completed)
|
||||||
if approved is not 'unspecified':
|
if provider_approved is not 'unspecified':
|
||||||
shifts = shifts.filter(approved=approved)
|
shifts = shifts.filter(provider_approved=provider_approved)
|
||||||
if manage:
|
if manage:
|
||||||
shifts = shifts.filter(price__management__uuid=manage)
|
shifts = shifts.filter(price__management__uuid=manage)
|
||||||
if work_type:
|
if work_type:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user