Skip to content

Commit 3eb928b

Browse files
committed
[refs codefordurham#384] Cleaner way to fix this issue
1 parent 89da018 commit 3eb928b

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

frontend/app/app.js

+2-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
va app = angular.module("schoolsApp", [
1+
var app = angular.module("schoolsApp", [
22
'ngRoute',
33
'SchoolsApp.directives',
44
'SchoolsApp.geoDecoder',
@@ -135,21 +135,6 @@ angular.module('SchoolsApp.controllers', ["leaflet-directive", "ngSanitize"])
135135
className: "school_point " + school.level
136136
}
137137
};
138-
$scope.extendedCare = function(profile) {
139-
var noBeforeCareMessage = "This school does not offer before care.";
140-
var noAfterCareMessage = "This school does not offer after care.";
141-
var display;
142-
if (profile.after_care_offered && profile.before_care_offered && profile.after_care_offered != noAfterCareMessage && profile.before_care_offered != noBeforeCareMessage) {
143-
display = 'This school offers before and after care.';
144-
} else if (profile.after_care_offered && profile.after_care_offered != noAfterCareMessage) {
145-
display = 'This school offers after care and does not offer before care.';
146-
} else if (profile.before_care_offered && profile.before_care_offered != noBeforeCareMessage) {
147-
display = "This school offers before care and does not offer after care.";
148-
} else {
149-
display = "This school does not offer extended care.";
150-
}
151-
return display;
152-
};
153138
$scope.report_card_link = function() {
154139
//url is of the form: base/<unit-code>_year_<g1>-<g2>-<School/Charter>.pdf
155140
var link_base = 'https://ncreportcards.ondemand.sas.com/snapshots/';
@@ -171,7 +156,7 @@ angular.module('SchoolsApp.controllers', ["leaflet-directive", "ngSanitize"])
171156
type = '-School';
172157
}
173158
return link_base + $scope.school.profile.state_id + year + grades + type + link_end;
174-
}
159+
};
175160
angular.extend($scope.school);
176161
});
177162
}

frontend/app/templates/details.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h2>School Services</h2>
3030
<p><strong>Transportation: </strong> <span title="Transportation provided">{{ school.profile.transportation_display }} <span ng-bind-html="school.profile.transportation_explanation | linky"></span></span></p>
3131
<p><strong>Lunch: </strong><span title="Lunch provided">{{ school.profile.lunch_served_display }}</span> {{ school.profile.lunch_free_and_reduced }} <span ng-bind-html="school.profile.lunch_explanation | linky"></span></p>
3232
<p><strong>Breakfast: </strong><span title="Breakfast provided">{{ school.profile.breakfast_served_display }}</span> {{ school.profile.breakfast_free_and_reduced }} <span ng-bind-html="school.profile.breakfast_explanation | linky"></span></p>
33-
<p><strong>Extended care: </strong><span title="extended care provided">{{ extendedCare(school.profile) }}</span></p>
33+
<p><strong>Extended care: </strong><span title="extended care provided">{{ school.profile.extended_care_offered }}</span></p>
3434
<p><strong>Extended care cost: </strong>{{ school.profile.extended_care_cost }}</p>
3535
<p><strong>Extended care financial assistance: </strong> <span ng-bind-html="school.profile.extended_care_financial_assistance | linky"></span></p>
3636
</div>

schools/serializers.py

+12
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ class SchoolProfileSerilaizer(serializers.ModelSerializer):
150150
breakfast_free_and_reduced = serializers.SerializerMethodField('breakfast_free_and_reduced_display')
151151
before_care_offered = serializers.SerializerMethodField('before_care_offered_display')
152152
after_care_offered = serializers.SerializerMethodField('after_care_offered_display')
153+
extended_care_offered = serializers.SerializerMethodField('_extended_care_offered')
153154

154155
class Meta:
155156
model = schools_models.SchoolProfile
@@ -164,6 +165,17 @@ def breakfast_free_and_reduced_display(self, obj):
164165
return "This school participates in the National Free and Reduced Breakfast Program."
165166
return "This school does not participate in the National Free and Reduced Breakfast Program."
166167

168+
def _extended_care_offered(self, obj):
169+
if obj.before_care_offered and obj.after_care_offered:
170+
msg = 'This school offers before and after care.'
171+
elif obj.before_care_offered:
172+
msg = 'This school offers before care.'
173+
elif obj.after_care_offered:
174+
msg = 'This school offers after care.'
175+
else:
176+
msg = 'This school does not offer extended care.'
177+
return msg
178+
167179
def before_care_offered_display(self, obj):
168180
if obj.before_care_offered:
169181
return "This school offers before care."

0 commit comments

Comments
 (0)