本文整理汇总了Python中model.Member类的典型用法代码示例。如果您正苦于以下问题:Python Member类的具体用法?Python Member怎么用?Python Member使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Member类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
def get(self):
template_values = {}
template_values['paged_member_keys'] = Member.get_paged_member_keys()
template_values['is_member'] = True if 'member' in self.session else False
if 'member' in self.session:
template_values['member'] = Member.get_member_json(self.session['member'])
self.render_template(template_name=None, template_values=template_values)
示例2: post
def post(self):
errors = []
username = str(self.get_cookie('username',''))
userflag = str(self.get_cookie('userflag',''))
if not username or not userflag:
self.write('403')
return
myfile = self.request.files.get('myfile',[0])[0]
if myfile:
im = Image.open(StringIO(myfile['body']))
max_w = 73
max_h = 73
if im.size[0] > max_w or im.size[1] > max_w:
ss = max(float(im.size[0])/max_w, float(im.size[1])/max_h)
im = im.resize((int(im.size[0]/ss), int(im.size[1]/ss)), Image.ANTIALIAS)
output = StringIO()
im.convert('RGB').save(output, 'JPEG', quality = 95)#95
img_data = output.getvalue()
output.close()
#self.set_header('Content-Type','image/jpeg')
#self.write(img_data)
#return
if IMG_STORAGE=='sae':
file_path_name = '%s.jpg'% username
avatar = put_obj2storage(file_name = file_path_name, data = img_data, domain_name = DOMAIN_NAME_AVATAR)
elif IMG_STORAGE=='upyun':
u = UpYun(DOMAIN_NAME_AVATAR, UPYUN_USER, UPYUN_PW)
file_path_name = '/avatar/%s.jpg'% username
avatar = u.writeFile( file_path_name, img_data, True)
if avatar:
if username == 'admin':
Member.set_flag(username, '99')
if userflag == '1':
if Member.set_flag(username, '2'):
self.set_cookie('userflag', '2', path="/", expires_days = 365 )
clear_cache_multi(['cur_user:' + username])
self.redirect('/setavatar')
return
else:
errors.append('服务器暂时出错,请稍后再试')
else:
self.redirect('/setavatar')
return
else:
errors.append('保存图片出错,请稍后再试')
else:
errors.append('图片没有正确上传')
self.echo('setavatar.html', {
'title': "设置头像",
'errors':errors,
'wb_avatar_large': '',
}, layout='_layout.html')
示例3: post
def post(self, email):
if not self.session['member'] == email:
self.response.out.write('access denied')
return
image = self.get_uploads("member-image-upload")
image_key = str(image[0].key()) if image else None
image_coords = [float(coord) for coord in self['image_coords'].split(',')] if self['image_coords'] else None
key = email if email else self['email']
image_url = '/api/members/'+key+'/image' if image_key else None
Member.create_or_update(key, name=self['name'], organization=self["organization"],
designation=self["designation"], image=image_key, website=self["website"],
twitter_handle=self["twitter_handle"], facebook_id=self["facebook_id"], bio=self["bio"],
password=self['password'], image_coords=image_coords, image_url=image_url)
self.redirect("/members/profile")
示例4: get
def get(self):
m_name = str(self.get_argument('name',''))
self.echo('setuserflag.html', {
'title': "设置用户权限",
'm_name': m_name,
'm_obj':Member.get_by_name_for_edit(m_name),
}, layout='_layout.html')
示例5: report_task
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)
示例6: expire_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'
示例7: nonone
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()
示例8: post
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)
示例9: get
def get(self):
track = Track.get_by_key_name(self['track_id'])
program = Program.get_by_key_name(self['program_id'], parent=track)
modules = ProgramModule.all().ancestor(program).order('name')
template_values = {'program':program,
'track':track,
'modules':modules,
'listing_heading':program.name}
template_values['is_member'] = True if 'member' in self.session else False
if 'member' in self.session:
email = self.session['member']
member = Member.get_by_email(email)
template_values['member'] = member
if member.role == MEMBER_ROLE[MANAGER]:
template_values['is_manager'] = True
else:
modules_count = modules.count()*1.0
completed_modules = []
for module in modules:
if module.completed:
completed_modules.append(module)
completed_modules_count = len(completed_modules)
score = (completed_modules_count/modules_count)*100.0
engage_score = round(score*random(),0)
engage_score = int(engage_score) if engage_score > 1 else 1
template_values['donuts'] = DonutFactory.get_donuts(100, 0.875, [('Engineer1', [DonutSegment(engage_score, '#1c758a'), DonutSegment(score, '#58c4dd')], '/assets/img/tracks/mobile_dev.png')], 'transparent', '#ddd')
self.render_template(template_name='program_listing.html', template_values=template_values)
示例10: cur_user
def cur_user(self):
user_name_cookie = self.get_cookie('username','')
user_code_cookie = self.get_cookie('usercode','')
if user_name_cookie and user_code_cookie:
from model import Member
return Member.check_loged_user(user_name_cookie, user_code_cookie)
else:
return None
示例11: members_with_status
def members_with_status(self, status_name):
index = search.Index(name='members')
results = index.search(query=search.Query('status:' + status_name, options=search.QueryOptions(limit=LIMIT)))
ret = list()
for document in results:
ret.append(Member.search_member_from_document(document))
return ret
示例12: get
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))
示例13: do_index_verification
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
示例14: create_new_member_no
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)
示例15: get
def get(self):
template_values = {}
upcoming_events, past_events = Event.get_paged_events()
template_values['past_events'] = past_events
template_values['upcoming_events'] = upcoming_events
template_values['is_member'] = True if 'member' in self.session else False
if 'member' in self.session:
template_values['member'] = Member.get_member_json(self.session['member'])
self.render_template(template_name='events.html', template_values=template_values)