Skip to content

Commit

Permalink
[refs codefordurham#384] Cleaner way to fix this issue
Browse files Browse the repository at this point in the history
  • Loading branch information
vrocha committed Jul 6, 2016
1 parent 89da018 commit 3eb928b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
19 changes: 2 additions & 17 deletions frontend/app/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
va app = angular.module("schoolsApp", [
var app = angular.module("schoolsApp", [
'ngRoute',
'SchoolsApp.directives',
'SchoolsApp.geoDecoder',
Expand Down Expand Up @@ -135,21 +135,6 @@ angular.module('SchoolsApp.controllers', ["leaflet-directive", "ngSanitize"])
className: "school_point " + school.level
}
};
$scope.extendedCare = function(profile) {
var noBeforeCareMessage = "This school does not offer before care.";
var noAfterCareMessage = "This school does not offer after care.";
var display;
if (profile.after_care_offered && profile.before_care_offered && profile.after_care_offered != noAfterCareMessage && profile.before_care_offered != noBeforeCareMessage) {
display = 'This school offers before and after care.';
} else if (profile.after_care_offered && profile.after_care_offered != noAfterCareMessage) {
display = 'This school offers after care and does not offer before care.';
} else if (profile.before_care_offered && profile.before_care_offered != noBeforeCareMessage) {
display = "This school offers before care and does not offer after care.";
} else {
display = "This school does not offer extended care.";
}
return display;
};
$scope.report_card_link = function() {
//url is of the form: base/<unit-code>_year_<g1>-<g2>-<School/Charter>.pdf
var link_base = 'https://ncreportcards.ondemand.sas.com/snapshots/';
Expand All @@ -171,7 +156,7 @@ angular.module('SchoolsApp.controllers', ["leaflet-directive", "ngSanitize"])
type = '-School';
}
return link_base + $scope.school.profile.state_id + year + grades + type + link_end;
}
};
angular.extend($scope.school);
});
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/templates/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h2>School Services</h2>
<p><strong>Transportation: </strong> <span title="Transportation provided">{{ school.profile.transportation_display }} <span ng-bind-html="school.profile.transportation_explanation | linky"></span></span></p>
<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>
<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>
<p><strong>Extended care: </strong><span title="extended care provided">{{ extendedCare(school.profile) }}</span></p>
<p><strong>Extended care: </strong><span title="extended care provided">{{ school.profile.extended_care_offered }}</span></p>
<p><strong>Extended care cost: </strong>{{ school.profile.extended_care_cost }}</p>
<p><strong>Extended care financial assistance: </strong> <span ng-bind-html="school.profile.extended_care_financial_assistance | linky"></span></p>
</div>
Expand Down
12 changes: 12 additions & 0 deletions schools/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class SchoolProfileSerilaizer(serializers.ModelSerializer):
breakfast_free_and_reduced = serializers.SerializerMethodField('breakfast_free_and_reduced_display')
before_care_offered = serializers.SerializerMethodField('before_care_offered_display')
after_care_offered = serializers.SerializerMethodField('after_care_offered_display')
extended_care_offered = serializers.SerializerMethodField('_extended_care_offered')

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

def _extended_care_offered(self, obj):
if obj.before_care_offered and obj.after_care_offered:
msg = 'This school offers before and after care.'
elif obj.before_care_offered:
msg = 'This school offers before care.'
elif obj.after_care_offered:
msg = 'This school offers after care.'
else:
msg = 'This school does not offer extended care.'
return msg

def before_care_offered_display(self, obj):
if obj.before_care_offered:
return "This school offers before care."
Expand Down

0 comments on commit 3eb928b

Please sign in to comment.