class HeightCurveFemaleYears(generics.RetrieveAPIView): """ Height-based growth curve for females aged 3 to 20 years view. """ serializer_class = HeightCurveSerializer def get_object(self): """ Get the specific curve. """ self.graphic = HeightCurve(gender=Constants.FEMALE, age=Constants.YEARS) return self.graphic.make() def get_serializer_context(self): """ Insert some attribute inside serializer. """ context = super(HeightCurveFemaleYears, self).get_serializer_context() context['graphic'] = self.graphic.make_charts(years=True) return context
class HeightCurveMaleMonths(generics.RetrieveAPIView): """ Height-based growth curve for males aged 0 to 36 months view. """ serializer_class = HeightCurveSerializer def get_object(self): """ Get the specific curve. """ self.graphic = HeightCurve(gender=Constants.MALE, age=Constants.MONTHS) return self.graphic.make() def get_serializer_context(self): """ Insert some attribute inside serializer. """ context = super(HeightCurveMaleMonths, self).get_serializer_context() context['graphic'] = self.graphic.make_charts() return context