Ejemplo n.º 1
0
    def get(self):
    	logging.info("GET Request for MainHandler called. Pathname: " + self.request.path)

        current_page = ""
        
        #For now, the only pathnames that will succeed in the try-block are "/about", "/places", "/contact", "/guestbook",
        #and "/index".
        #All other pathnames (e.g. "/", "/about.html", "/blhahlsdu") should enter
        #the except-block and be redirected to the index page.
        try:
            if self.request.path.islower() == False:
                raise Exception ('pathname must be all lower case')
            template = JINJA_ENVIRONMENT.get_template("templates/" + self.request.path + ".html")
            #current_page should end up being one of the following four values: "INDEX", "ABOUT", "PLACES", "CONTACT"
            current_page = self.request.path[1:].upper()
        except:
            logging.info("Redirecting to index.html")
            template = JINJA_ENVIRONMENT.get_template("templates/index.html")
            current_page = "INDEX"

        
        login_status = loginStatus(self.request.path)

        self.response.write(template.render({"current_page": current_page, "logged_in": login_status['logged_in'], 
                                             "log_url": login_status['log_url']}))
Ejemplo n.º 2
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))
Ejemplo n.º 3
0
    def post(self, member_no):
        member = self.get_member(member_no)

        member.name = self.get_required('name')
        member.address = self.get_required('address')
        member.zipcode = self.get_required('zip')
        member.city = self.get_required('city')
        country = Country.get(self.get_required('country'))

        email = self.get_required('email')
        if email != '':
            member.email = db.Email(email)

        mobile = self.get_required('mobile')
        if mobile != '':
            member.phone = db.PhoneNumber(mobile)

        home = self.request.get('fixed')
        if home != '':
            member.phone_home = db.PhoneNumber(home)

        work = self.request.get('work')
        if work != '':
            member.phone_work = db.PhoneNumber(work)

        member.put()

        template = JINJA_ENVIRONMENT.get_template('templates/selfservice/profile_edit.html')
        countries = Country.all().order('order').fetch(FETCH_LIMIT)

        data = { 'message': 'Medlemsprofilen din er oppdatert.', 'member': member, 'countries': countries }
        self.response.write(template.render(data))
Ejemplo n.º 4
0
    def get(self):
        """get; show page with config values"""

        template = JINJA_ENVIRONMENT.get_template('templates/settings/detail.html')

        data = { 'config': Configuration() }
        self.response.write(template.render(data))
Ejemplo n.º 5
0
 def get(self):
     template_values = {
         'og_url': 'http://oclp622.com',
         'og_image': 'http://oclp622.com/assets/social_network.png'
     }
     template = JINJA_ENVIRONMENT.get_template('templates/info.html')
     self.response.write(template.render(template_values))
Ejemplo n.º 6
0
    def get(self):
        template = JINJA_ENVIRONMENT.get_template('templates/statuses/list.html')

        statuses = Status.all().order('order').fetch(100)

        data = { 'statuses' : statuses, 'counter': DataStoreCounter() }
        self.response.write(template.render(data))
Ejemplo n.º 7
0
    def post(self):
        template = JINJA_ENVIRONMENT.get_template('templates/backup/backup.html')
        dump = DataDump()
        filename = dump.do_backup()


        message = 'Backing up to %s' % (filename)
        self.response.write(template.render({'message': message, 'files': self.get_files() }))
Ejemplo n.º 8
0
 def get(self):
     template = JINJA_ENVIRONMENT.get_template('templates/selfservice/signup.html')
     countries = Country.all().order('order').fetch(100)
     self.response.write(template.render({
         'countries': countries,
         'incomplete': [],
         'complete': [],
         'values': { } }))
Ejemplo n.º 9
0
    def get(self):
        template = JINJA_ENVIRONMENT.get_template('templates/members/member_list.html')
        countries = Country.all().order('order').fetch(LIMIT)
        statuses = Status.all().order('order').fetch(LIMIT)
        types = MemberType.all().order('order').fetch(LIMIT)

        # TODO: Make sensible
        query_string = ''
        current_search = self.request.get('search')
        query_string +=  current_search

        current_status = self.request.get('status')
        if current_status != '':
            if query_string != '':
                query_string += ' AND '
            query_string += 'status:' + current_status

        current_type = self.request.get('type')
        if current_type != '':
            if query_string != '':
                query_string += ' AND '
            query_string += 'type:'+ current_type

        current_country = self.request.get('country')
        if current_country and current_country != '':
            if query_string != '':
                query_string += ' AND '
            query_string += 'country:' + current_country

        index = search.Index(name='members')
        result = index.search(query=search.Query(query_string, options=search.QueryOptions(limit=LIMIT)))

        members = list()
        for document in result.results:
            members.append(Member.search_member_from_document(document))

        members = sorted(members, key=lambda x: x.number)

        current_status_name = current_status
        current_type_name = current_type

        total = memcache.get('member_count')
        if not total:
            total = 0

        data = {
            'countries': countries,
            'statuses': statuses,
            'types': types,
            'members': members,
            'current_status': current_status,
            'current_type': current_type,
            'current_search': current_search,
            'found': result.number_found,
            'shown': len(members),
            'total': total
        }
        self.response.write(template.render(data))
Ejemplo n.º 10
0
 def get(self, range_id, model_id):
     template = JINJA_ENVIRONMENT.get_template('templates/carmodels/model_detail.html')
     model_range = ModelRange.get(range_id)
     car_model = CarModel.get(model_id)
     data = {
         'range': model_range,
         'model': car_model
     }
     self.response.write(template.render(data))
Ejemplo n.º 11
0
    def get(self, member_no):
        member = self.get_member(member_no)
        countries = Country.all().order('order').fetch(FETCH_LIMIT)

        # OK - everything checks out - show edit form
        template = JINJA_ENVIRONMENT.get_template('templates/selfservice/profile_edit.html')

        data = { 'member': member, 'countries': countries }
        self.response.write(template.render(data))
Ejemplo n.º 12
0
    def get(self):
        template = JINJA_ENVIRONMENT.get_template('templates/start.html')


        data = {
            'counter': utils.counter.DataStoreCounter(),
            'signed_up': self.members_with_status(constants.SIGNUP_STATUS_NAME),
            'welcome_letter': self.members_with_status(constants.WELCOME_LETTER_NAME)
            }
        self.response.write(template.render(data))
Ejemplo n.º 13
0
    def get(self, range_id):
        template = JINJA_ENVIRONMENT.get_template('templates/carmodels/range_detail.html')
        model_range = ModelRange().get(range_id)

        data = {
            'range': model_range,
            'models': sorted(model_range.models, key=lambda x: -x.year_from),
            'counter': utils.counter.DataStoreCounter()
        }

        self.response.write(template.render(data))
Ejemplo n.º 14
0
 def get(self):
     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 = {
         'countries': countries,
         'statuses': statuses,
         'types': types,
         'data': None
     }
     self.response.write(template.render(data))
Ejemplo n.º 15
0
 def post(self):
     logging.info('Guestbook post function')
     #Reference - GAE Guestbook tutorial
     template = JINJA_ENVIRONMENT.get_template("templates/guestbook.html")
     mes = GuestbookMessage(parent=ndb.Key('Guestbook', 'AliGuestbook'))
     mes.user = users.get_current_user().nickname()
     mes.message = self.request.get('message')
     mes.put()
     #Add a second to give time for message to be added to the database 
     #and appear with the rest of the messages on redirect (hacky solution for now)
     time.sleep(1)
     self.redirect('/guestbook')
Ejemplo n.º 16
0
 def render_template(self, template, values=None):
   """Renders the template and writes this to the reponse"""
   # Would love to use default value but it is dangerous to use {}
   if not values:
     values = {}
   values['user'] = users.get_current_user()
   if values['user']:
     values['logout_url'] = users.create_logout_url(self.request.url)
   values['navigation_pages'] = self.get_navigation_pages()
   #TODO: Handle error in event that self.url does not exist
   values['current_page'] = self
   template = JINJA_ENVIRONMENT.get_template(template)
   self.response.write(template.render(values))
Ejemplo n.º 17
0
    def get(self):
        template = JINJA_ENVIRONMENT.get_template('templates/caredit/list.html')

        unknown = CarModel.all().filter('name =', 'Annet').fetch(5)
        assert len(unknown)==1
        unknown_cars = Car.all().filter('model =', unknown[0]).fetch(50)

        other = CarModel.all().filter('name =', 'Annen Alfa Romeo').fetch(5)
        assert len(other)==1
        other_cars = Car.all().filter('model =', other[0]).fetch(50)

        data = { 'cars': other_cars + unknown_cars, 'linker': LookupReg() }
        self.response.write(template.render(data))
Ejemplo n.º 18
0
    def get(self):
        # List the files in the cloudstore reports dir.
        files = list()
        bucket_name = '/' + REPORT_BUCKET

        for stat in cloudstorage.listbucket(bucket_name, max_keys=100):
            date_str = datetime.datetime.fromtimestamp(stat.st_ctime).strftime('%d.%m.%Y kl %H:%M')
            report = self.get_report_from_file(stat.filename)
            files.append({ 'filename': stat.filename[len('/' + REPORT_BUCKET + '/'):], 'date': date_str, 'report': report, 'source': stat })

        # get reports in progress

        template = JINJA_ENVIRONMENT.get_template('templates/reports/list.html')
        data = { 'files': files, 'generators': report_generators }
        self.response.write(template.render(data))
Ejemplo n.º 19
0
    def send_notification_mails(self, member):
        """Send the notification mail"""
        config = Configuration()
        sender_address = config.get('WELCOME_MAIL_SENDER')
        subject = config.get('NOTIFICATION_MAIL_SUBJECT')
        recipients = config.get('NOTIFICATION_MAIL_RECIPIENTS')

        mail_template = JINJA_ENVIRONMENT.get_template('templates/emails/notification_signup.txt')
        data = {
            'member': member,
            'server_url': SERVER_URL
        }
        body = mail_template.render(data)

        mail.send_mail(sender_address, recipients, subject, body)
Ejemplo n.º 20
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')
Ejemplo n.º 21
0
    def get(self):
        logging.info('Guestbook get function')
        template = JINJA_ENVIRONMENT.get_template("templates/guestbook.html")

        #Reference - GAE documentation on Query Cursors

        #Sort the messages by most recent first
        message_query = GuestbookMessage.query().order(-GuestbookMessage.timestamp)
        messages = ''
        more_messages = 0

        message_block = self.request.get('start')
        logging.info('message_block is: ')
        logging.info(message_block)

        #User is on the first page of the guestbook (e.g. just navigated to the guestbook page)
        if not message_block:
            #Get the first ten messages in the guestbook
            messages, next_cursor, more_messages = message_query.fetch_page(10)
            message_block = 0
            memcache_key = 'block10'
            memcache.set(memcache_key, next_cursor)

        #User is not on the first page of the guestbook
        else:
            memcache_key = 'block' + message_block
            curs = memcache.get(memcache_key)
            
            #This should never happen because every time you retrieve the next 10 results,
            #you are setting the cursor to start at the beginning of the next message after that the ones
            #you just retrieved
            if not curs:
                logging.info("Error: curs is invalid")
                self.redirect('/guestbook')
            else:
                messages, next_cursor, more_messages = message_query.fetch_page(10, start_cursor=curs)
                if more_messages:
                    next_block = int(message_block) + 10
                    memcache_key = 'block' + str(next_block)
                    memcache.set(memcache_key, next_cursor)

        login_status = loginStatus(self.request.path)

        self.response.write(template.render({"current_page": "GUESTBOOK", "logged_in": login_status["logged_in"], "log_url": login_status["log_url"],
                                            "messages": messages, "more_messages":more_messages, "message_block" : int(message_block)}))
Ejemplo n.º 22
0
    def post(self):
        """post; Save the config and show the page again"""

        config = Configuration()
        config.set('WELCOME_MAIL_SENDER', self.request.get('welcome_sender'))
        config.set('WELCOME_MAIL_SUBJECT', self.request.get('welcome_subject'))
        config.set('NOTIFICATION_MAIL_RECIPIENTS', self.request.get('notification_recipients'))
        config.set('NOTIFICATION_MAIL_SUBJECT', self.request.get('notification_subject'))
        config.set('GIRO_ACCOUNT_NO', self.request.get('account_no'))
        config.set('GIRO_SUBJECT', self.request.get('heading'))
        config.set('GIRO_TEXT', self.request.get('body'))
        config.set('GIRO_ADDRESS', self.request.get('address'))
        config.set('WELCOME_MAIL_TEXT', self.request.get('welcome_body'))
        config.set('GIRO_MESSAGE', self.request.get('giro_message'))
        template = JINJA_ENVIRONMENT.get_template('templates/settings/detail.html')

        data = { 'config': config }
        self.response.write(template.render(data))
Ejemplo n.º 23
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))
Ejemplo n.º 24
0
    def post(self):
        template = JINJA_ENVIRONMENT.get_template('templates/backup/restore.html')
        self.response.write(template.render({ 'message': 'Importing ' + self.request.get('filename') } ))

        content = self.request.get('contents')
        data = json.loads(content)

        ts = datetime.datetime.now().strftime('%Y-%m-%dT%H%M%S')

        deferred.defer(task_user_restore, data['users'], _name=('users_%s' % ts))
        deferred.defer(task_config_restore, data['config'], _name=('config_%s' % ts))
        deferred.defer(task_country_restore, data['countries'], _name=('countries_%s' % ts))
        deferred.defer(task_type_restore, data['types'], _name=('types_%s' % ts))
        deferred.defer(task_status_restore, data['status'], _name=('status_%s' % ts))

        # The limit for each task is 100KB; must limit the car and member lists
        # to something manageable. Limit to 50 and 50 users, 10 and 10 car ranges
        model_list = data['modelRanges']
        work_list = list()
        counter = 0
        while len(model_list) > 0:
            work_list.append(model_list.pop())
            if len(work_list) == 10:
                counter = counter + 1
                deferred.defer(task_model_restore, work_list, _name=('car_model_%d_%s' % (counter, ts)))
                work_list = list()
        if len(work_list) > 0:
            counter = counter + 1
            deferred.defer(task_model_restore, work_list, _name=('car_model_%d_%s' % (counter, ts)))

        counter = 0
        member_list = data['members']
        work_list = list()
        while len(member_list) > 0:
            work_list.append(member_list.pop())
            if len(work_list) == 25:
                counter = counter + 1
                deferred.defer(task_member_restore, work_list, _countdown=60, _name=('members_%d_%s' % (counter, ts)))
                work_list = list()
        if len(work_list) > 0:
            counter = counter + 1
            deferred.defer(task_member_restore, work_list, _countdown=60, _name=('members_%d_%s' % (counter, ts)))
Ejemplo n.º 25
0
    def get(self, message_id):
        query = MessageRecord.query(MessageRecord.uid == message_id)
        queryRecords = query.fetch(1)

        # Protection
        if len(queryRecords) == 0:
            self.response.status = '302'
            self.response.headers['Location'] = '/'
            return

        template_values = {
            'og_url': 'http://oclp622.com/message/{mid}'.format(mid=message_id),
            'og_image': 'http://oclp622.com/image/{mid}/large'.format(mid=message_id),
            'og_description': u'全城{up_for}!向{no_to}說不! - {author}'.format(
                up_for=queryRecords[0].field1,
                no_to=queryRecords[0].field2,
                author=queryRecords[0].author
            )
        }
        template = JINJA_ENVIRONMENT.get_template('templates/index.html')
        self.response.write(template.render(template_values))
Ejemplo n.º 26
0
    def get(self):
        config = Configuration()
        ruler = """
--------------------------------------------------------------------------------
0________1_________2_________3_________4_________5_________6_________7_________8
1        0         0         0         0         0         0         0         0
--------------------------------------------------------------------------------
"""
        template = Template(config.get('WELCOME_MAIL_TEXT'))

        member = Member()
        member.name = 'Ola Normann'
        member.address = 'Norskeveien 1'
        member.zipcode = '9876'
        member.city = 'Olabyen'
        member.country = Country().all().order('order').fetch(1)[0]
        member.email = '[email protected]'
        member.phone = '916 75 105'
        member.phone_home = '939 90 115'
        member.phone_work = '101 33 116'
        member.number = '9669'
        member.access_code = 'BBQWTF'
        member.member_type = MemberType.all().order('order').fetch(1)[0]
        sample_data =  {
            'year': 2014,
            'fee': 400,
            'account_no': config.get('GIRO_ACCOUNT_NO'),
            'member': member,
            'profile_url': constants.PROFILE_URL
            }
        sample_text = template.render(sample_data)
        # Merge template before submitting text
        data = {'text': ruler + sample_text + ruler }

        template = JINJA_ENVIRONMENT.get_template('templates/settings/email_preview.html')
        self.response.write(template.render(data))
Ejemplo n.º 27
0
    def post(self):
        template = JINJA_ENVIRONMENT.get_template('templates/loader/loader.html')

        content = self.request.get('type')

        countries = []
        if content == 'countries.csv':
            countries = self.import_countries(self.request.get('data'))

        statuses = []
        if content == 'status.csv':
            statuses = self.import_statuses(self.request.get('data'))

        types = []
        if content == 'types.csv':
            types = self.import_types(self.request.get('data'))

        if content == 'member.csv':
            self.statuslist = Status.all().fetch(100)
            self.typelist = MemberType.all().fetch(100)
            self.countrylist = Country.all().fetch(100)
            self.import_members(self.request.get('data'))

        if content == 'model_ranges.csv':
            self.import_model_range(self.request.get('data'))

        if content == 'car_models.csv':
            self.import_car_models(self.request.get('data'))

        if content == 'cars.csv':
            self.import_member_cars(self.request.get('data'))

        if content == 'users.csv':
            self.import_users(self.request.get('data'))

        self.response.write(template.render())
Ejemplo n.º 28
0
 def get(self):
     template = JINJA_ENVIRONMENT.get_template('templates/backup/backup.html')
     self.response.write(template.render({ 'message': '', 'files': self.get_files() }))
Ejemplo n.º 29
0
 def get(self):
     # Delete the cookie and show the login form
     self.response.delete_cookie(COOKIE_NAME)
     template = JINJA_ENVIRONMENT.get_template('templates/selfservice/profile_login.html')
     self.response.write(template.render())
Ejemplo n.º 30
0
    def post(self):
        complete = []
        incomplete = []
        values = {}

        # Holy crap this is ugly. There has to be a better way.

        name = self.request.get('name')
        if not name or name.strip() == '':
            incomplete.append('name')
        else:
            values['name'] = name
            complete.append('name')


        address = self.request.get('address')
        if not address or address.strip() == '':
            incomplete.append('address')
        else:
            values['address'] = address
            complete.append('address')


        zipcode = self.request.get('zip')
        if (not zipcode or zipcode.strip() == '') or len(zipcode.strip()) < 4:
            incomplete.append('zip')
        else:
            values['zip'] = zipcode
            complete.append('zip')


        city = self.request.get('city')
        if not city or city.strip() == '':
            incomplete.append('city')
        else:
            values['city'] = city
            complete.append('city')

        if 'zip' in incomplete or 'city' in incomplete:
            incomplete.append('zipcity')


        country_key = self.request.get('country').strip()
        country = Country.get(country_key)

        countries = Country.all().order('order').fetch(100)

        if not country or not country_key or country_key.strip() == '':
            incomplete.append('country')
            # retrieve countries since we're going to need them
        else:
            values['country'] = country.name
            complete.append('country')

        email = self.request.get('email')
        if not email or email.strip() == '' or not mail.is_email_valid(email):
            incomplete.append('email')
        else:
            values['email'] = email
            complete.append('email')

        mobile = self.request.get('mobile')
        if mobile and mobile.strip() == '':
            mobile = None
        values['mobile'] = mobile

        home = self.request.get('home')
        if home and home.strip() == '':
            home = None
        values['home'] = home

        work = self.request.get('work')
        if work and work.strip() == '':
            work = None
        values['work'] = work

        member_type = self.request.get('type')
        if not member_type or member_type.strip() == '':
            member_type = '1'

        types = MemberType.all().fetch(100)

        mtype = None

        # TODO: Custom settings? Constants at least.
        if member_type == '1':
            mtype = next(t for t in types if t.name == DEFAULT_MEMBER_NAME)
        else:
            mtype = next(t for t in types if t.name == DEFAULT_SUPPORT_MEMBER_NAME)

        values['type'] = mtype.name
        comment = self.request.get('comment')
        complete.append('comment')
        values['comment'] = comment

        error_message = ''

        # Check if member exists;
        existing = Member.all().filter('email', email).fetch(1)

        if len(existing) > 0:
            incomplete.append('email')
            error_message = 'Det er allerede registrert noen i medlemsregisteret med denne epostadressen!'
            # TODO: Error message

        if len(incomplete) > 0:
            # missing field, redirect to signup page again
            template = JINJA_ENVIRONMENT.get_template('templates/selfservice/signup.html')
            return self.response.write(template.render({
                'countries': countries,
                'incomplete': incomplete,
                'complete': complete,
                'error_message': error_message,
                'values': values }))

        # invariant: fields are OK, create new member, send mail,
        # create payment history on member.
        template = JINJA_ENVIRONMENT.get_template('templates/selfservice/signup_receipt.html')
        data = {
            'values': values,
            'profile_url': PROFILE_URL
        }

        statuses = Status.all().fetch(100)

        # TODO: Handle existing members signing up again

        new_member = Member()

        new_member.name = name
        new_member.address = address
        new_member.zipcode = zipcode
        new_member.city = city
        new_member.notes = comment
        new_member.country = country
        new_member.membertype = mtype

        status = next(s for s in statuses if s.name == SIGNUP_STATUS_NAME)
        new_member.status = status

        new_member.number = dbutils.create_new_member_no()

        new_member.email = email
        new_member.member_since = datetime.date.today()
        if mobile:
            new_member.phone = mobile
        if work:
            new_member.phone_work = work
        if home:
            new_member.phone_home = home
        new_member.generate_access_code()
        new_member.member_since = datetime.date.today()
        new_member.member_type = mtype
        new_member.put()

        self.send_welcome_mail(new_member)
        self.send_notification_mails(new_member)

        # TODO: Invalidate counts for categories
        # Handle mutations on members gracefully

        return self.response.write(template.render(data))