Пример #1
0
    def save(self, usr):
        data = self.cleaned_data
        ecp = EcoProfile()
        ecp.user = usr
        ecp.water_this_month = data['water_bill']
        ecp.gas_this_month = int(data['gas'])
        ecp.heating_oil = data['heating_oil']
        ecp.natural_gas = int(data['natural_gas'])
        ecp.pounds_of_trash = data['trash_weight']
        ecp.current_month = data['date_on_bills']
        ecp.electricity_this_month = data['electric_bill']
        ecp.save()

        profile = UserProfile.objects.get(user=usr)
        profile.house_square_footage = data['house_sq']
        profile.number_of_people = data['occupants']
        profile.save()
        return ecp
Пример #2
0
 def save(self, usr):
     data = self.cleaned_data
     ecp = EcoProfile()
     ecp.user = usr
     ecp.water_this_month = data['water_bill']
     ecp.gas_this_month = int(data['gas'])
     ecp.heating_oil = data['heating_oil']
     ecp.natural_gas = int(data['natural_gas'])
     ecp.pounds_of_trash = data['trash_weight']
     ecp.current_month = data['date_on_bills']
     ecp.electricity_this_month = data['electric_bill']
     ecp.save()
     
     profile = UserProfile.objects.get(user = usr)
     profile.house_square_footage = data['house_sq']
     profile.number_of_people = data['occupants']
     profile.save()
     return ecp
Пример #3
0
def updateData(usr, data, method):
    record_date = data['date_on_bills']
    usp = UserProfile.objects.get(user=usr)
    if method == 'update':
        assert(recordExistsFor(usr, data))
        record = EcoProfile.objects.filter(user = usr).get(current_month = record_date)
    elif method == 'new':
        record = EcoProfile(user = usr)
    record.current_month = record_date
    record.water_this_month = data['water_bill']
    record.gas_this_month = data['gas']
    record.electricity_this_month = data['electric_bill']
    record.pounds_of_trash = data['trash_weight']
    record.natural_gas = data['natural_gas']
    record.heating_oil = data['heating_oil']
    usp.house_square_footage = data['house_sq']
    usp.number_of_people = data['occupants']
    usp.save()
    record.save()
Пример #4
0
def updateData(usr, data, method):
    record_date = data['date_on_bills']
    usp = UserProfile.objects.get(user=usr)
    if method == 'update':
        assert (recordExistsFor(usr, data))
        record = EcoProfile.objects.filter(user=usr).get(
            current_month=record_date)
    elif method == 'new':
        record = EcoProfile(user=usr)
    record.current_month = record_date
    record.water_this_month = data['water_bill']
    record.gas_this_month = data['gas']
    record.electricity_this_month = data['electric_bill']
    record.pounds_of_trash = data['trash_weight']
    record.natural_gas = data['natural_gas']
    record.heating_oil = data['heating_oil']
    usp.house_square_footage = data['house_sq']
    usp.number_of_people = data['occupants']
    usp.save()
    record.save()