示例#1
0
def task_member_restore(items):

    for item in items:
        member = Member()
        member.number = item['number']
        member.address = item['address']
        if item['email'] != '' and item['email'] != None:
            member.email = db.Email(item['email'])
        member.name = item['name']
        member.member_since = string_to_date(item['memberSince'])
        if item['phone'] != '' and item['phone'] != None:
            member.phone = db.PhoneNumber(item['phone'])
        if item['phoneWork'] != '' and item['phoneWork'] != None:
            member.phone_work = item['phoneWork']
        if item['phoneHome'] != '' and item['phoneHome'] != None:
            member.phone_home = item['phoneHome']
        member.notes = item['notes']
        member.zipcode = item['zipcode']
        member.city = item['city']
        member.county = item['county']
        member.country = db.get(db.Key.from_path('Country', item['countryId']))
        member.status = db.get(db.Key.from_path('Status', item['statusId']))
        member.membertype = db.get(
            db.Key.from_path('MemberType', item['typeId']))
        member.put()

        for itemdue in item['membershipDues']:
            due = MembershipDues(parent=member,
                                 year=itemdue['year'],
                                 paid=itemdue['paid'])
            due.put()

        for itemcar in item['cars']:
            car = Car()
            car.member = member
            car.registration = itemcar['registration']
            car.model = db.get(db.Key.from_path('CarModel',
                                                itemcar['modelId']))
            car.bought_year = itemcar['boughtYear']
            car.sold_year = itemcar['soldYear']
            car.year = itemcar['year']
            car.notes = itemcar['notes']
            car.serial_no = itemcar['serialNo']
            car.put()
示例#2
0
def task_member_restore(items):

    for item in items:
        member = Member()
        member.number = item['number']
        member.address = item['address']
        if item['email'] != '' and item['email'] != None:
            member.email = db.Email(item['email'])
        member.name = item['name']
        member.member_since = string_to_date(item['memberSince'])
        if item['phone'] != '' and item['phone'] != None:
            member.phone = db.PhoneNumber(item['phone'])
        if item['phoneWork'] != '' and item['phoneWork'] != None:
            member.phone_work = item['phoneWork']
        if item['phoneHome'] != '' and item['phoneHome'] != None:
            member.phone_home = item['phoneHome']
        member.notes = item['notes']
        member.zipcode = item['zipcode']
        member.city = item['city']
        member.county = item['county']
        member.country = db.get(db.Key.from_path('Country', item['countryId']))
        member.status = db.get(db.Key.from_path('Status', item['statusId']))
        member.membertype = db.get(db.Key.from_path('MemberType', item['typeId']))
        member.put()

        for itemdue in item['membershipDues']:
            due = MembershipDues(parent=member, year=itemdue['year'],paid=itemdue['paid'])
            due.put()

        for itemcar in item['cars']:
            car = Car()
            car.member = member
            car.registration = itemcar['registration']
            car.model = db.get(db.Key.from_path('CarModel', itemcar['modelId']))
            car.bought_year = itemcar['boughtYear']
            car.sold_year = itemcar['soldYear']
            car.year = itemcar['year']
            car.notes = itemcar['notes']
            car.serial_no = itemcar['serialNo']
            car.put()
示例#3
0
    def import_members(self, member_csv):
        member_csv = member_csv.split('\n')
        lines = self.unmangle(member_csv)

        count = 0
        for fields in lines:
            #fields.reverse()
            print '-' * 80
            print fields
            print '=' * 80
            fields.reverse()
            member = Member()

            (fee2009, fee2010, fee2011, fee2012,
             fee2013, fee2014) = (fields.pop(), fields.pop(), fields.pop(),
                                  fields.pop(), fields.pop(), fields.pop())

            member.address = fields.pop()
            # Skip the cars
            for carno in range(1, 6):
                (car, registration) = (fields.pop(), fields.pop())

            email = fields.pop()
            if email != '':
                member.email = db.Email(email)

            (lastname, firstname) = (fields.pop(), fields.pop())
            full_name = firstname + ' ' + lastname
            member.name = full_name.strip()

            member.county = fields.pop().strip()
            member_since = fields.pop()
            date = self.string_to_date(member_since)
            if date:
                member.member_since = date
            else:
                print 'Error converting date from', member_since

            country = fields.pop().strip()
            if country == '':
                country = 'Norge'
            member.country = self.string_to_country(country)
            member.membertype = self.string_to_type(fields.pop())
            member.number = fields.pop()
            mobile = fields.pop()
            if mobile != '':
                member.phone = db.PhoneNumber(mobile)

            member.notes = fields.pop()
            member.zipcode = fields.pop()
            member.city = fields.pop()
            work = fields.pop()
            home = fields.pop()
            if work != '':
                member.phone_work = db.PhoneNumber(work)
            if home != '':
                member.phone_home = db.PhoneNumber(home)
            member.status = self.get_status('Medlem')
            member.generate_access_code()
            member.put()

            self.add_due(member, 2009, fee2009 == 'Betalt')
            self.add_due(member, 2010, fee2010 == 'Betalt')
            self.add_due(member, 2011, fee2011 == 'Betalt')
            self.add_due(member, 2012, fee2012 == 'Betalt')
            self.add_due(member, 2013, fee2013 == 'Betalt')
            self.add_due(member, 2014, fee2014 == 'Betalt')
            count = count + 1

        print 'Imported', count, 'members'
示例#4
0
    def import_members(self, member_csv):
        member_csv = member_csv.split('\n')
        lines = self.unmangle(member_csv)

        count = 0
        for fields in lines:
            #fields.reverse()
            print '-'*80
            print fields
            print '='*80
            fields.reverse()
            member = Member()

            (fee2009, fee2010, fee2011,
                fee2012, fee2013, fee2014) = (
                    fields.pop(), fields.pop(), fields.pop(),
                    fields.pop(), fields.pop(), fields.pop())

            member.address = fields.pop()
            # Skip the cars
            for carno in range(1,6):
                (car, registration) = (fields.pop(), fields.pop())

            email = fields.pop()
            if email != '':
                member.email = db.Email(email)

            (lastname, firstname) = (fields.pop(), fields.pop())
            full_name = firstname + ' ' + lastname
            member.name = full_name.strip()

            member.county = fields.pop().strip()
            member_since = fields.pop()
            date = self.string_to_date(member_since)
            if date:
                member.member_since = date
            else:
                print 'Error converting date from',member_since

            country = fields.pop().strip()
            if country == '':
                country = 'Norge'
            member.country = self.string_to_country(country)
            member.membertype = self.string_to_type(fields.pop())
            member.number = fields.pop()
            mobile = fields.pop()
            if mobile != '':
                member.phone = db.PhoneNumber(mobile)

            member.notes = fields.pop()
            member.zipcode = fields.pop()
            member.city = fields.pop()
            work = fields.pop()
            home = fields.pop()
            if work != '':
                member.phone_work = db.PhoneNumber(work)
            if home != '':
                member.phone_home = db.PhoneNumber(home)
            member.status = self.get_status('Medlem')
            member.generate_access_code()
            member.put()

            self.add_due(member, 2009, fee2009=='Betalt')
            self.add_due(member, 2010, fee2010=='Betalt')
            self.add_due(member, 2011, fee2011=='Betalt')
            self.add_due(member, 2012, fee2012=='Betalt')
            self.add_due(member, 2013, fee2013=='Betalt')
            self.add_due(member, 2014, fee2014=='Betalt')
            count = count + 1


        print 'Imported',count,'members'