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')
def expire_members(): types = MemberType.all().fetch(30) expired_type = None for mt in types: if mt.name == MEMBER_TYPE_EXPIRED: expired_type = mt break if not expired_type: print 'Could not find member type for expired members' members = Member.all().fetch(3000) expired_count = 0 last_year = datetime.datetime.now().year - 1 for member in members: dues = MembershipDues.all().ancestor(member).fetch(30) all_paid = False for due in dues: if due.year >= last_year and due.paid: all_paid = True break if not all_paid and member.membertype.name == DEFAULT_MEMBER_NAME and member.status.name == DEFAULT_MEMBER_STATUS_NAME: print 'Member no', member.number, 'has an expired membership' member.membertype = expired_type member.put() expired_count = expired_count + 1 print expired_count, 'memberships have been ended'
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))
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')
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))
def task_type_restore(items): for item in items: mtype = MemberType(key_name=item['typeId']) mtype.order = item['order'] mtype.name = item['name'] mtype.fee = item['fee'] mtype.put()
def post(self, type_id): if self.request.get('cancel') == '1': return self.redirect('/types') membertype = MemberType.get(type_id) membertype.name = self.request.get('typename') membertype.order = int(self.request.get('order')) membertype.fee = int(self.request.get('fee')) membertype.put() return self.redirect('/types')
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))
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))
def import_types(self, type_csv): types = [] lines = type_csv.split('\n') for line in lines: if len(line.strip()) > 0: fields = line.split(';') membertype = MemberType() membertype.order = int(fields[0]) membertype.name = fields[1].strip() membertype.fee = int(fields[2]) membertype.put() types.append(membertype) return membertype
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))
def import_types(self, type_csv): types = [] lines = type_csv.split('\n') for line in lines: if len(line.strip()) > 0: fields = line.split(';') membertype = MemberType() membertype.order = int(fields[0]) membertype.name = fields[1].strip() membertype.fee = int(fields[2]) membertype.put() types.append(membertype) return membertype;
def expire_members(): logging.info('Expiring memberships') types = MemberType.all().fetch(10000) expired_type = None for mt in types: if mt.name == MEMBER_TYPE_EXPIRED: expired_type = mt break if not expired_type: logging.info( 'Could not find member type for expired members. Exiting.') return members = Member.all().fetch(10000) expired_count = 0 this_year = datetime.datetime.now().year total = 0 for member in members: total = total + 1 dues = MembershipDues.all().ancestor(member).filter( 'year', this_year).fetch(100) all_paid = False for due in dues: #logging.info('%s: Y: %s, paid: %s' % (member.number, due.year, due.paid)) if not all_paid and due.year == this_year and due.paid: all_paid = True # print 'All paid for %s ' % (member.number) if not all_paid: if member.membertype.name == DEFAULT_MEMBER_NAME: if member.status.name == DEFAULT_MEMBER_STATUS_NAME: print( 'Member no %s has an expired membership (type is %s, status is %s); new type will be %s' % (member.number, member.membertype.name, member.status.name, expired_type.name)) member.membertype = expired_type member.put() expired_count = expired_count + 1 print('%d memberships of %d will be expired' % (expired_count, total))
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))
def expire_members(): logging.info('Expiring memberships') types = MemberType.all().fetch(10000) expired_type = None for mt in types: if mt.name == MEMBER_TYPE_EXPIRED: expired_type = mt break if not expired_type: logging.info( 'Could not find member type for expired members. Exiting.') return members = Member.all().fetch(10000) expired_count = 0 this_year = datetime.datetime.now().year total = 0 for member in members: total = total + 1 dues = MembershipDues.all().ancestor(member).filter('year', this_year).fetch(100) all_paid = False for due in dues: #logging.info('%s: Y: %s, paid: %s' % (member.number, due.year, due.paid)) if not all_paid and due.year == this_year and due.paid: all_paid = True # print 'All paid for %s ' % (member.number) if not all_paid: if member.membertype.name == DEFAULT_MEMBER_NAME: if member.status.name == DEFAULT_MEMBER_STATUS_NAME: print ('Member no %s has an expired membership (type is %s, status is %s); new type will be %s' % (member.number, member.membertype.name, member.status.name, expired_type.name)) member.membertype = expired_type member.put() expired_count = expired_count + 1 print ('%d memberships of %d will be expired' % (expired_count, total))
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 = '*****@*****.**' 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))
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())
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())
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 = '*****@*****.**' 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))
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')
def get(self): template = JINJA_ENVIRONMENT.get_template('templates/types/list.html') types = MemberType.all().order('order').fetch(100) data = {'types': types, 'counter': DataStoreCounter()} self.response.write(template.render(data))
def get(self, type_id): template = JINJA_ENVIRONMENT.get_template( 'templates/types/detail.html') membertype = MemberType.get(type_id) data = {'membertype': membertype} self.response.write(template.render(data))
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')
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))
def get(self): template = JINJA_ENVIRONMENT.get_template('templates/types/list.html') types = MemberType.all().order('order').fetch(100) data = { 'types' : types, 'counter': DataStoreCounter() } self.response.write(template.render(data))
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() == '' or name.strip().startswith('http'): incomplete.append('name') else: values['name'] = name complete.append('name') address = self.request.get('address') # Spammers put URLs in the address field so we reject those right away if not address or address.strip() == '' or address.strip().startswith( 'http'): 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() new_member.update_index() 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))
def get(self, type_id): template = JINJA_ENVIRONMENT.get_template('templates/types/detail.html') membertype = MemberType.get(type_id) data = { 'membertype': membertype } self.response.write(template.render(data))