示例#1
0
    def post(self, member_id):
        import constants
        member = Member.get(member_id)
        if member.status.name == constants.SIGNUP_STATUS_NAME:
            member.status = self.get_status(constants.WELCOME_LETTER_NAME)
            # update the status to paid membership due.
            dues = MembershipDues.all().ancestor(member).fetch(25)

            current_year = datetime.datetime.now().year
            # Set next year if this at the end of the previous.
            if (datetime.datetime.now().month >= 11):
                current_year = current_year + 1

            found = False
            for due in dues:
                if due.year == current_year:
                    due.paid = True
                    found = True
                    print('Updated existing due')
                    due.put()
            if not found:
                print('Due not found, created new')
                due = MembershipDues(parent=member,
                                     year=current_year,
                                     paid=True)
                due.put()
            member.put()
        elif member.status.name == constants.WELCOME_LETTER_NAME:
            member.status = self.get_status(
                constants.DEFAULT_MEMBER_STATUS_NAME)
            member.put()
        destination = self.request.get('return')
        return self.redirect(destination)
示例#2
0
 def add_missing_dues(self, dues, start, stop):
     years = range(start, stop + 1)
     for due in dues:
         if due.year in years:
             years.remove(due.year)
     for year in years:
         dues.append(MembershipDues(year=year, paid=False))
示例#3
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()
示例#4
0
 def save_dues(self, member):
     current_dues = MembershipDues.all().ancestor(member).fetch(25)
     current_year = datetime.datetime.now().year
     for year in range(current_year + config.DUES_AHEAD,
                       config.FIRST_YEAR_WITH_DUES, -1):
         due_value = self.request.get('due' + str(year))
         if not due_value:
             continue
         paid = True if due_value == 'True' else False
         exists = False
         for due in current_dues:
             if due.year == year:
                 exists = True
                 if due.paid != paid:
                     due.paid = paid
                     due.put()
         if not exists:
             new_due = MembershipDues(parent=member, year=year, paid=paid)
             new_due.put()
示例#5
0
 def add_due(self, member, year, paid):
     due = MembershipDues(parent=member, year=year, paid=paid)
     due.put()