Additional changes from review

This commit is contained in:
John Westcott IV 2022-06-10 10:25:14 -04:00
parent 1180634ba7
commit fddf292d47
3 changed files with 7 additions and 8 deletions

View File

@ -4683,7 +4683,7 @@ class ScheduleSerializer(LaunchConfigurationBaseSerializer, SchedulePreviewSeria
timezone = serializers.SerializerMethodField(
help_text=_(
'The timezone this schedule runs in. This field is extracted from the RRULE. If the timezone in the RRULE is a link to another timezone this field will show the links name.'
'The timezone this schedule runs in. This field is extracted from the RRULE. If the timezone in the RRULE is a link to another timezone, the link will be reflected in this field.'
),
)
until = serializers.SerializerMethodField(

View File

@ -578,8 +578,7 @@ class ScheduleZoneInfo(APIView):
swagger_topic = 'System Configuration'
def get(self, request):
zone_info = models.Schedule.get_zoneinfo_with_links()
return Response(zone_info)
return Response({'zones': models.Schedule.get_zoneinfo(), 'links': models.Schedule.get_zoneinfo_links()})
class LaunchConfigCredentialsBase(SubListAttachDetachAPIView):

View File

@ -85,16 +85,16 @@ class Schedule(PrimordialModel, LaunchTimeConfig):
next_run = models.DateTimeField(null=True, default=None, editable=False, help_text=_("The next time that the scheduled action will run."))
@classmethod
def get_zoneinfo(self):
def get_zoneinfo(cls):
return sorted(get_zonefile_instance().zones)
@classmethod
def get_zoneinfo_with_links(self):
def get_zoneinfo_links(cls):
return_val = {}
zone_instance = get_zonefile_instance()
return_val = {'zones': sorted(zone_instance.zones), 'links': {}}
for zone_name in return_val['zones']:
for zone_name in zone_instance.zones:
if str(zone_name) != str(zone_instance.zones[zone_name]._filename):
return_val['links'][zone_name] = zone_instance.zones[zone_name]._filename
return_val[zone_name] = zone_instance.zones[zone_name]._filename
return return_val
@property