Merge pull request #1667 from ryanpetrello/and-you-get-a-timezone

change timezone behavior slightly for Schedule.rrule to make things simpler for UI folks
This commit is contained in:
Ryan Petrello
2018-05-11 09:55:23 -04:00
committed by GitHub
11 changed files with 621 additions and 352 deletions

View File

@@ -4511,9 +4511,19 @@ class SchedulePreviewSerializer(BaseSerializer):
class ScheduleSerializer(LaunchConfigurationBaseSerializer, SchedulePreviewSerializer):
show_capabilities = ['edit', 'delete']
timezone = serializers.SerializerMethodField()
until = serializers.SerializerMethodField()
class Meta:
model = Schedule
fields = ('*', 'unified_job_template', 'enabled', 'dtstart', 'dtend', 'rrule', 'next_run',)
fields = ('*', 'unified_job_template', 'enabled', 'dtstart', 'dtend', 'rrule', 'next_run', 'timezone',
'until')
def get_timezone(self, obj):
return obj.timezone
def get_until(self, obj):
return obj.until
def get_related(self, obj):
res = super(ScheduleSerializer, self).get_related(obj)

View File

@@ -745,11 +745,11 @@ class ScheduleZoneInfo(APIView):
swagger_topic = 'System Configuration'
def get(self, request):
from dateutil.zoneinfo import get_zonefile_instance
return Response([
zones = [
{'name': zone}
for zone in sorted(get_zonefile_instance().zones)
])
for zone in Schedule.get_zoneinfo()
]
return Response(zones)
class LaunchConfigCredentialsBase(SubListAttachDetachAPIView):