当前位置: 首页>>代码示例>>Python>>正文


Python Member.all方法代码示例

本文整理汇总了Python中model.Member.all方法的典型用法代码示例。如果您正苦于以下问题:Python Member.all方法的具体用法?Python Member.all怎么用?Python Member.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.Member的用法示例。


在下文中一共展示了Member.all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: nonone

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import all [as 别名]
def nonone():
    """ Mass update fields set to 'None'. Please don't ask. """
    for member in Member.all().fetch(10000):
        mod = False
        if member.email == 'None':
            member.email = None
            mod = True

        if member.phone == 'None':
            member.phone = None
            mod = True

        if member.phone_work == 'None':
            member.phone_work = None
            mod = True

        if member.phone_home == 'None':
            member.phone_home = None
            mod = True

        if member.address == 'None':
            member.address = None
            mod = True

        if mod:
            member.put()
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:28,代码来源:editcodes.py

示例2: report_task

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import all [as 别名]
    def report_task(self):
        diff = datetime.timedelta(days=150)
        cutoff_date = datetime.date.today() - diff

        filename = self.get_filename(self.id())
        member_list = Member.all().fetch(LIMIT_ALL)

        lines = list()
        lines.append("number;name;zip;city;date;bil\n")
        for member in member_list:
            if member.member_since >= cutoff_date and member.status.name == "Medlem":
                cars = member.cars.fetch(1)
                if len(cars) > 0:
                    model = cars[0].model.name
                else:
                    model = ""
                lines.append(
                    '"%s";"%s";"%s";"%s";"%s";"%s"\n'
                    % (
                        unicode(member.number),
                        unicode(member.name),
                        unicode(member.zipcode),
                        unicode(member.city),
                        member.member_since.isoformat(),
                        model,
                    )
                )

        self.write_report(filename, lines)
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:31,代码来源:newmembers.py

示例3: expire_members

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import all [as 别名]
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'
开发者ID:,项目名称:,代码行数:29,代码来源:

示例4: do_index_verification

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import all [as 别名]
def do_index_verification():
	member_list = Member.all().fetch(LIMIT_ALL)
	index = search.Index(name='members')
	for member in member_list:
		query =

		result = index.search(query=search.Query('number:' + member.number, options=search.QueryOptions(limit=10)))
		logging.debug('Found ' + str(len(result))) + ' members with number ' + member.number
		
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:10,代码来源:verifyindex.py

示例5: create_new_member_no

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import all [as 别名]
def create_new_member_no():
    """Assign new member no. Not *that* time critical but some form of
    transactions would be nice. Or required. This makes my hair stand up
    but...

    It works."""

    members = Member.all().order('-number').fetch(1)
    return str(int(members[0].number) + 1)
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:11,代码来源:dbutils.py

示例6: create_index

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import all [as 别名]
 def create_index(self):
     print 'Creating member index'
     members = Member.all().fetch(10000)
     docs = []
     for member in members:
         print 'Indexing member',member.number
         docs.append(member.create_document())
         if len(docs) > 100:
             index = search.Index(name='members')
             index.put(docs)
             docs = []
开发者ID:,项目名称:,代码行数:13,代码来源:

示例7: create_member_car

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import all [as 别名]
    def create_member_car(self, car, range_name, model_name, note):
        members = Member.all().filter('number',car.memberno).fetch(10)
        if len(members) == 0:
            print 'WARNING: Could not look up member with no.',car.memberno
            return

        member_car = Car()
        member_car.member = members[0]
        member_car.model = self.get_model(model_name)
        member_car.registration = car.registration
        member_car.year = int(car.year)
        member_car.notes = note
        member_car.serial_no = ''
        member_car.put()
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:16,代码来源:load.py

示例8: index_verification

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import all [as 别名]
    def index_verification(self):
        logging.info('Retrieving member list')
        member_list = Member.all().fetch(10000)
        logging.info('Found ' + str(len(member_list)) + ' members')
        index = search.Index(name='members')
        for member in member_list:
            try:
                result = index.search(query=search.Query('number:' + member.number, options=search.QueryOptions(limit=10)))
                if not result.results:
                    logging.warning('Found no entry for member with number ' + member.number + '. Adding to index')
                    member.update_index()

            except ex:
                logging.warning('Got exception ex ' + ex)            
        logging.info('Completed verification')
开发者ID:,项目名称:,代码行数:17,代码来源:

示例9: report_task

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import all [as 别名]
    def report_task(self):
        filename = self.get_filename(self.id())
        member_list = Member.all().fetch(LIMIT_ALL)

        lines = list()
        lines.append('number;name;address;zip;city;country;type\n')
        for member in member_list:
            typename = member.membertype.name
            if typename == u'Medlem' or typename == u'Hedersmedlem':
                lines.append('"%s";"%s";"%s";"%s";"%s";"%s";"%s"\n' % (
                    unicode(member.number), unicode(member.name), unicode(member.address),
                    unicode(member.zipcode), unicode(member.city), unicode(member.country.name),
                    typename))

        self.write_report(filename, lines, 'cp1252')
开发者ID:,项目名称:,代码行数:17,代码来源:

示例10: report_task

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import all [as 别名]
    def report_task(self):
        filename = self.get_filename(self.id())
        member_list = Member.all().fetch(LIMIT_ALL)
        current_year = datetime.datetime.now().year
        final_list = list()

        for member in member_list:
            # Skip if the member doesn't pay fees
            if member.membertype.fee == 0:
                continue

            # Retrieve dues and check if status is set to paid
            dues = MembershipDues.all().ancestor(member).fetch(YEAR_MAX)
            paid = False
            for due in dues:
                if due.year == current_year:
                    paid = due.paid
                    break
            if not paid:
                final_list.append(member)

        # Make CSV file
        lines = list()
        lines.append(
            'number;name;address;zip;city;country;email;phone;member_since;type;status\n')
        for member in final_list:
            datestr = ''
            if member.member_since:
                datestr = member.member_since.strftime('%Y-%m-%d')
            phonestr = ''
            if member.phone and member.phone != 'None':
                phonestr = unicode(member.phone)
            emailstr = ''
            if member.email and member.email != 'None':
                emailstr = unicode(member.email)
            lines.append('"%s";"%s";"%s";"%s";"%s";"%s";"%s";"%s";%s;"%s";"%s"\n' % (
                unicode(member.number), unicode(
                    member.name), unicode(member.address),
                unicode(member.zipcode), unicode(
                    member.city), unicode(member.country.name),
                emailstr, phonestr, datestr,
                unicode(member.membertype.name), unicode(member.status.name)))

        self.write_report(filename, lines)
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:46,代码来源:unpaid.py

示例11: create_index

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import all [as 别名]
 def create_index(self):
     """Create a new index"""
     members = Member.all().fetch(20000)
     docs = []
     count = 0
     for member in members:
         try:
             docs.append(member.create_document())
             if len(docs) > 100:
                 index = search.Index(name='members')
                 index.put(docs)
                 docs = []
             count = count + 1
         except Exception as ex:
             logging.warning('Got exception ex %s', ex)
     if len(docs) > 0:
         index = search.Index(name='members')
         index.put(docs)
         docs = []
     logging.info('Reindexed %d members', count)
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:22,代码来源:__init__.py

示例12: post

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import all [as 别名]
    def post(self):
        # User (tries to) log in. Check member no and access code.
        try:
            memberno = self.get_required('memberno')
            access_code = self.get_required('accesscode')

            members = Member.all().filter('number', memberno).fetch(1)
            if len (members) < 1:
                self.abort(400)

            if members[0].edit_access_code.lower() != access_code:
                self.abort(400)

            self.create_cookie(memberno, access_code)

            return self.redirect('profile/' + str(members[0].key()) + '/edit')

        except Exception as ex:
            print 'Got exception:',ex
            # bounce to login page
            self.response.delete_cookie(COOKIE_NAME)
            return self.redirect('profile')
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:24,代码来源:profile.py

示例13: expire_members

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import all [as 别名]
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))
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:40,代码来源:expire.py

示例14: post

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import all [as 别名]
    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)

#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:

示例15: generate_edit_codes

# 需要导入模块: from model import Member [as 别名]
# 或者: from model.Member import all [as 别名]
def generate_edit_codes():
    """ Mass update edit codes for members """
    for member in Member.all().fetch(10000):
        member.generate_access_code()
        member.put()
开发者ID:KlubbAlfaRomeoNorge,项目名称:members,代码行数:7,代码来源:editcodes.py


注:本文中的model.Member.all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。