Beispiel #1
0
    def post(self):
        if self.request.get('store') != '1':
            self.redirect('/members')
            return

        try:
            member = Member()
            member.name = self.get_var('name')
            member.address = self.get_var('address')
            member.zipcode = self.get_var('zip')
            member.city = self.get_var('city')
            member.country = Country.get(self.get_var('country'))
            member.email = self.get_var('email', optional=True)
            member.mobile = self.get_var('mobile', optional=True)
            member.home = self.get_var('home', optional=True)
            member.work = self.get_var('work', optional=True)
            member.membertype = MemberType.get(self.get_var('type'))
            member.notes = self.get_var('comment', optional=True)
            member.status = Status.get(self.get_var('status'))
            member.number = dbutils.create_new_member_no()
            member.member_since = datetime.date.today()
            member.generate_access_code()
            mcount = self.get_var('magazine_count', optional=True)
            member.magazine_count = int(mcount) if mcount else 1
            member.put()
            self.redirect('/members/%s/edit' % member.key())
            return
        except MissingField:
            # TODO: Redirect
            template = JINJA_ENVIRONMENT.get_template(
                'templates/members/new_member.html')
            countries = Country.all().order('order').fetch(LIMIT)
            statuses = Status.all().order('order').fetch(LIMIT)
            types = MemberType.all().order('order').fetch(LIMIT)
            data = {}
            for name in [
                    'name', 'address', 'zip', 'country', 'email', 'mobile',
                    'home', 'work', 'type', 'comment', 'status'
            ]:
                data[name] = self.request.get(name)

            params = {
                'countries': countries,
                'statuses': statuses,
                'types': types,
                'data': data
            }
            self.response.write(template.render(params))
            return

        self.redirect('/members')
Beispiel #2
0
    def post(self):
        if self.request.get('store') != '1':
            self.redirect('/members')
            return

        try:
            member = Member()
            member.name = self.get_var('name')
            member.address = self.get_var('address')
            member.zipcode = self.get_var('zip')
            member.city = self.get_var('city')
            member.country = Country.get(self.get_var('country'))
            member.email = self.get_var('email', optional=True)
            member.mobile = self.get_var('mobile', optional=True)
            member.home = self.get_var('home', optional=True)
            member.work = self.get_var('work', optional=True)
            member.membertype = MemberType.get(self.get_var('type'))
            member.notes = self.get_var('comment', optional=True)
            member.status = Status.get(self.get_var('status'))
            member.number = dbutils.create_new_member_no()
            member.member_since = datetime.date.today()
            member.generate_access_code()
            mcount = self.get_var('magazine_count', optional=True)
            member.magazine_count = int(mcount) if mcount else 1
            member.put()
            self.redirect('/members/%s/edit' % member.key())
            return
        except MissingField:
            # TODO: Redirect
            template = JINJA_ENVIRONMENT.get_template('templates/members/new_member.html')
            countries = Country.all().order('order').fetch(LIMIT)
            statuses = Status.all().order('order').fetch(LIMIT)
            types = MemberType.all().order('order').fetch(LIMIT)
            data = { }
            for name in [ 'name', 'address', 'zip', 'country', 'email', 'mobile', 'home', 'work', 'type', 'comment', 'status']:
                data[name] = self.request.get(name)

            params = {
                'countries': countries,
                'statuses': statuses,
                'types': types,
                'data': data
            }
            self.response.write(template.render(params))
            return

        self.redirect('/members')