Beispiel #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)
Beispiel #2
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)
Beispiel #3
0
    def get(self, member_id, car_id):
        template = JINJA_ENVIRONMENT.get_template('templates/members/car_detail.html')
        member = Member.get(member_id)
        car = Car.get(car_id)

        selector_template = JINJA_ENVIRONMENT.get_template('templates/carselector.html')

        data = {
            'car': car,
            'member': member,
            'carselector_html': selector_template.render()
        }
        self.response.write(template.render(data))
Beispiel #4
0
    def get_member(self, member_no):
        (memberno, access_code) = self.get_cookie()

        member = Member.get(member_no)
        if not member:
            self.abort(400)

        if not member.number == memberno:
            self.abort(400)

        if member.edit_access_code.lower().strip() != access_code:
            self.abort(400)

        return member
Beispiel #5
0
    def get_member(self, member_no):
        (memberno, access_code) = self.get_cookie()

        member = Member.get(member_no)
        if not member:
            self.abort(400)

        if not member.number == memberno:
            self.abort(400)

        if member.edit_access_code.lower().strip() != access_code:
            self.abort(400)

        return member
Beispiel #6
0
    def get(self, member_id, car_id):
        template = JINJA_ENVIRONMENT.get_template(
            'templates/members/car_detail.html')
        member = Member.get(member_id)
        car = Car.get(car_id)

        selector_template = JINJA_ENVIRONMENT.get_template(
            'templates/carselector.html')

        data = {
            'car': car,
            'member': member,
            'carselector_html': selector_template.render()
        }
        self.response.write(template.render(data))
Beispiel #7
0
 def get(self, member_id):
     template = JINJA_ENVIRONMENT.get_template('templates/members/member_detail.html')
     countries = Country.all().order('order').fetch(LIMIT)
     statuses = Status.all().order('order').fetch(LIMIT)
     types = MemberType.all().order('order').fetch(LIMIT)
     member = Member.get(member_id)
     dues = MembershipDues.all().ancestor(member).fetch(25)
     current_year = datetime.datetime.now().year
     self.add_missing_dues(dues, max(config.FIRST_YEAR_WITH_DUES, member.member_since.year), current_year + config.DUES_AHEAD)
     dues = sorted(dues, key=lambda item: item.year, reverse=True)
     data = {
         'countries': countries,
         'statuses': statuses,
         'types': types,
         'member': member,
         'dues': dues,
         'current_year': current_year
     }
     self.response.write(template.render(data))
Beispiel #8
0
 def get(self, member_id):
     template = JINJA_ENVIRONMENT.get_template(
         'templates/members/member_detail.html')
     countries = Country.all().order('order').fetch(LIMIT)
     statuses = Status.all().order('order').fetch(LIMIT)
     types = MemberType.all().order('order').fetch(LIMIT)
     member = Member.get(member_id)
     dues = MembershipDues.all().ancestor(member).fetch(25)
     current_year = datetime.datetime.now().year
     self.add_missing_dues(
         dues, max(config.FIRST_YEAR_WITH_DUES, member.member_since.year),
         current_year + config.DUES_AHEAD)
     dues = sorted(dues, key=lambda item: item.year, reverse=True)
     data = {
         'countries': countries,
         'statuses': statuses,
         'types': types,
         'member': member,
         'dues': dues,
         'current_year': current_year
     }
     self.response.write(template.render(data))
Beispiel #9
0
    def post(self, member_id):

        if self.request.get('cancel') == '1':
            return self.redirect('/members')

        if self.request.get('operation') == 'delete_car':
            car = Car.get(self.request.get('car_key'))
            if car:
                car.delete()
            return self.redirect('/members/' + member_id + '/edit')

        member = Member.get(member_id)

        if self.request.get('operation') == 'new_car':
            car = Car()
            car.member = member
            car.model = dbutils.get_default_model()
            car.registration = ''
            car.year = 0
            car.notes = ''
            car.serial_no = ''
            car.put()
            return self.redirect('/members/' + member_id + '/car/' + str(car.key()) + '/edit' )

        member.name = self.request.get('name')
        member.address = self.request.get('address')
        member.zipcode = self.request.get('zip')
        member.city = self.request.get('city')
        member.country = Country.get(self.request.get('country'))
        phone = self.request.get('mobile').strip()
        if phone != '':
            member.phone = db.PhoneNumber(phone)
        else:
            member.phone = None
        email = self.request.get('email').strip()
        if email != '':
            member.email = db.Email(email)
        else:
            member.email = None
        home = self.request.get('fixed').strip()
        if home != '':
            member.phone_home = db.PhoneNumber(home)
        else:
            member.phone_home = None
        work = self.request.get('work').strip()
        if work != '':
            member.phone_work = db.PhoneNumber(work)
        else:
            member.phone_work = None
        member.membertype = MemberType.get(self.request.get('type'))
        member.status = Status.get(self.request.get('status'))
        member.notes = self.request.get('note')

        if self.request.get('access_code') == '':
            member.generate_access_code()

        if self.request.get('magazine_count') != '':
            try:
                member.magazine_count = int(self.request.get('magazine_count'))
            except ValueError:
                pass

        member.put()
        member.update_index()

        # save membership dues
        self.save_dues(member)


        return self.redirect('/members')
Beispiel #10
0
    def post(self, member_id):

        if self.request.get('cancel') == '1':
            return self.redirect('/members')

        if self.request.get('operation') == 'delete_car':
            car = Car.get(self.request.get('car_key'))
            if car:
                car.delete()
            return self.redirect('/members/' + member_id + '/edit')

        member = Member.get(member_id)

        if self.request.get('operation') == 'new_car':
            car = Car()
            car.member = member
            car.model = dbutils.get_default_model()
            car.registration = ''
            car.year = 0
            car.notes = ''
            car.serial_no = ''
            car.put()
            return self.redirect('/members/' + member_id + '/car/' +
                                 str(car.key()) + '/edit')

        member.name = self.request.get('name')
        member.address = self.request.get('address')
        member.zipcode = self.request.get('zip')
        member.city = self.request.get('city')
        member.country = Country.get(self.request.get('country'))
        phone = self.request.get('mobile').strip()
        if phone != '':
            member.phone = db.PhoneNumber(phone)
        else:
            member.phone = None
        email = self.request.get('email').strip()
        if email != '':
            member.email = db.Email(email)
        else:
            member.email = None
        home = self.request.get('fixed').strip()
        if home != '':
            member.phone_home = db.PhoneNumber(home)
        else:
            member.phone_home = None
        work = self.request.get('work').strip()
        if work != '':
            member.phone_work = db.PhoneNumber(work)
        else:
            member.phone_work = None
        member.membertype = MemberType.get(self.request.get('type'))
        member.status = Status.get(self.request.get('status'))
        member.notes = self.request.get('note')

        if self.request.get('access_code') == '':
            member.generate_access_code()

        if self.request.get('magazine_count') != '':
            try:
                member.magazine_count = int(self.request.get('magazine_count'))
            except ValueError:
                pass

        member.put()
        member.update_index()

        # save membership dues
        self.save_dues(member)

        return self.redirect('/members')