Пример #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()
Пример #5
0
    def save(self):
        data = self.cleaned_data
        self.checkUsername(data['username'])
        if data['password'] == data['password_v']:
            user = User.objects.create_user(data['username'], data['email'], data['password'])
        else:
            raise validators.ValidationError('Passwords do not match')
        user.first_name = data['first_name']
        user.last_name = data['last_name']
        user.save()
        
        profile = user.get_profile()
        profile.address = data['address']
        profile.zip_code = data['zip_code']
        profile.house_square_footage = data['house_square_feet']
        profile.number_of_people = data['number_of_residents']
        profile.heating_fuel_type = data['heating_fuel']
        profile.save()
        data['affinity_group'].members.add(user)

        
        eco_profile = EcoProfile(user=user)
        eco_profile.save()
Пример #6
0
    def save(self):
        data = self.cleaned_data
        self.checkUsername(data['username'])
        if data['password'] == data['password_v']:
            user = User.objects.create_user(data['username'], data['email'],
                                            data['password'])
        else:
            raise validators.ValidationError('Passwords do not match')
        user.first_name = data['first_name']
        user.last_name = data['last_name']
        user.save()

        profile = user.get_profile()
        profile.address = data['address']
        profile.zip_code = data['zip_code']
        profile.house_square_footage = data['house_square_feet']
        profile.number_of_people = data['number_of_residents']
        profile.heating_fuel_type = data['heating_fuel']
        profile.save()
        data['affinity_group'].members.add(user)

        eco_profile = EcoProfile(user=user)
        eco_profile.save()