Skip to content

Commit

Permalink
Merge pull request #24 from gisce/fix_serializer_to_schema
Browse files Browse the repository at this point in the history
Fix serializer to schema
  • Loading branch information
ecarreras committed Jul 3, 2015
2 parents 1b77fed + 34156ac commit 842f429
Showing 1 changed file with 51 additions and 29 deletions.
80 changes: 51 additions & 29 deletions empowering/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,55 @@ class CustomerAddress(Schema):


class CustomerBuildingData(Schema):
buildingConstructionYear = fields.Integer()
dwellingArea = fields.Integer()
buildingVolume = fields.Integer()
buildingConstructionYear = Integer()
dwellingArea = Integer()
buildingVolume = Integer()
buildingType = fields.Select(['Single_house', 'Apartment'])
dwellingPositionInBuilding = fields.Select(['first_floor', 'middle_floor', 'last_floor', 'other'])
dwellingOrientation = fields.Select(['S', 'SE', 'E', 'NE', 'N', 'NW', 'W', 'SW'])
buildingWindowsType = fields.Select(['single_panel', 'double_panel', 'triple_panel', 'low_emittance', 'other'])
buildingWindowsFrame = fields.Select(['PVC', 'wood', 'aluminium', 'steel', 'other'])
buildingHeatingSource = fields.Select(['electricity', 'gas', 'gasoil', 'district_heating', 'biomass', 'other'])
buildingHeatingSourceDhw = fields.Select(['electricity', 'gas', 'gasoil', 'district_heating', 'biomass', 'other'])
buildingSolarSystem = fields.Select(['PV', 'solar_thermal_heating', 'solar_thermal_DHW', 'other', 'not_installed'])
dwellingPositionInBuilding = fields.Select([
'first_floor', 'middle_floor', 'last_floor', 'other'
])
dwellingOrientation = fields.Select([
'S', 'SE', 'E', 'NE', 'N', 'NW', 'W', 'SW'
])
buildingWindowsType = fields.Select([
'single_panel', 'double_panel', 'triple_panel', 'low_emittance', 'other'
])
buildingWindowsFrame = fields.Select([
'PVC', 'wood', 'aluminium', 'steel', 'other'
])
buildingHeatingSource = fields.Select([
'electricity', 'gas', 'gasoil', 'district_heating', 'biomass', 'other'
])
buildingHeatingSourceDhw = fields.Select([
'electricity', 'gas', 'gasoil', 'district_heating', 'biomass', 'other'
])
buildingSolarSystem = fields.Select([
'PV', 'solar_thermal_heating', 'solar_thermal_DHW', 'other',
'not_installed'
])


class CustomerProfileEducationLevel(Schema):
edu_prim = fields.Integer()
edu_sec = fields.Integer()
edu_uni = fields.Integer()
edu_noStudies = fields.Integer()
edu_prim = Integer()
edu_sec = Integer()
edu_uni = Integer()
edu_noStudies = Integer()


class CustomerProfile(Schema):
totalPersonNumber = fields.Integer()
minorsPersonsNumber = fields.Integer()
workingAgePersonsNumber = fields.Integer()
retiredAgePersonsNumber = fields.Integer()
malePersonsNumber = fields.Integer()
femalePersonsNumber = fields.Integer()
totalPersonNumber = Integer()
minorsPersonsNumber = Integer()
workingAgePersonsNumber = Integer()
retiredAgePersonsNumber = Integer()
malePersonsNumber = Integer()
femalePersonsNumber = Integer()
educationLevel = fields.Nested(CustomerProfileEducationLevel)

class CustomerCustomisedGroupingCriteria(Serializer):
class CustomerCustomisedGroupingCriteria(Schema):
pass


class CustomerCustomisedServiceParameters(Serializer):
class CustomerCustomisedServiceParameters(Schema):
OT101 = fields.String()
OT103 = fields.String()
OT105 = fields.String()
Expand All @@ -75,8 +90,12 @@ class Customer(Schema):
address = fields.Nested(CustomerAddress)
buildingData = fields.Nested(CustomerBuildingData)
profile = fields.Nested(CustomerProfile)
customisedGroupingCriteria = fields.Nested(CustomerCustomisedGroupingCriteria)
customisedServiceParameters = fields.Nested(CustomerCustomisedServiceParameters)
customisedGroupingCriteria = fields.Nested(
CustomerCustomisedGroupingCriteria
)
customisedServiceParameters = fields.Nested(
CustomerCustomisedServiceParameters
)


class Device(Schema):
Expand All @@ -85,7 +104,7 @@ class Device(Schema):
deviceId = fields.UUID()


class Contract(Serializer):
class Contract(Schema):
payerId = fields.UUID()
ownerId = fields.UUID()
signerId = fields.UUID()
Expand All @@ -94,7 +113,7 @@ class Contract(Serializer):
dateEnd = fields.DateTime(format='iso')
contractId = fields.String()
tariffId = fields.String()
version = fields.Integer()
version = Integer()
activityCode = fields.String()
meteringPointId = fields.UUID()
weatherStationId = fields.UUID()
Expand All @@ -107,9 +126,12 @@ class Contract(Serializer):


class Reading(Schema):
type = fields.Select(['electricityConsumption', 'electricityKiloVoltAmpHours', 'heatConsumption', 'gasConsumption',
'estimatedElectricityConsumption', 'estimatedElectricityKiloVoltAmpHours',
'estimatedHeatConsumption', 'estimatedGasConsumption'])
type = fields.Select([
'electricityConsumption', 'electricityKiloVoltAmpHours',
'heatConsumption', 'gasConsumption', 'estimatedElectricityConsumption',
'estimatedElectricityKiloVoltAmpHours', 'estimatedHeatConsumption',
'estimatedGasConsumption'
])
unit = fields.Select(['kWh', 'Wh'])
period = fields.Select(['INSTANT', 'CUMULATIVE', 'PULSE'])

Expand Down

0 comments on commit 842f429

Please sign in to comment.