本文整理汇总了Python中models.Member类的典型用法代码示例。如果您正苦于以下问题:Python Member类的具体用法?Python Member怎么用?Python Member使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Member类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get
def get(self):
db = getUtility(IRelationalDatabase)
cr = db.cursor()
number = self.member.number
if number:
cr.execute("""SELECT
id,
number,
name
FROM members
WHERE number = ?""",
(number,))
else:
cr.execute("""SELECT
id,
number,
name
FROM members""")
rst = cr.fetchall()
cr.close()
members = []
for record in rst:
id = record['id']
number = record['number']
name = record['name']
member = Member()
member.id = id
member.number = number
member.name = name
members.append(member)
return members
开发者ID:eugeneai,项目名称:ZCA,代码行数:31,代码来源:member.py
示例2: get
def get(self, args):
if not require_admin(self):
return
template_vals = generate_base_template_vals(self)
template_vals['title'] = 'Edit Member'
template_vals['page'] = 'members'
req_id = self.request.get('id')
if not req_id:
while True:
# Create a new ID and verify it is unique.
new_id = uuid4().hex
if not Member.query(Member.id == new_id).get():
new_member = Member()
new_member.id = new_id
new_member.name = 'New Member'
template_vals['member'] = new_member
break
else:
member = Member.query(Member.id == req_id).get()
if member:
template_vals['member'] = member
else:
self.error(404)
return
template_vals['semesters'] = get_all_semesters()
template = JINJA_ENVIRONMENT.get_template('member_edit.html')
self.response.write(template.render(template_vals))
开发者ID:zmyaro,项目名称:star-site,代码行数:32,代码来源:members.py
示例3: json_add_member
def json_add_member(request, band_id):
if isInBand(request.user, band_id):
#current user is in this band
if isManager(request.user, band_id):
#current user is a manager
if request.method == 'POST':
#load data
data = json.loads(request.body)
#add an invitation to the email provided
band = Band.objects.get(id=band_id)
if "email" in data:
email = data["email"]
else:
email = None
newInv = Invitation(band=band, email=email, active=True)
newInv.save()
#add the member to the band regardless
name = data["name"]
role = data["role"]
if "phone" in data:
phone = data["phone"]
else:
phone = None
status = data["status"]
newMem = Member(band=band, name=name, role=role, phone=phone, status=status, email=email)
newMem.save()
return HttpResponse("success")
return HttpResponse("failure")
开发者ID:nmyers322,项目名称:BandManager,代码行数:28,代码来源:views.py
示例4: get
def get(self, key):
edit = self.request.get('edit')
template_dict = {'key': key, 'show_form' : True,'members': Member.all(),
'edit':edit,'thing' : self.thing_descriptors.get(edit),'images':Image.all().filter('name != ', "no-name") }
if key == 'new':
template_dict['form_data'] = {
'author': Member.get_current_member().handle,
'date': unicode(datetime.date.today())}
else:
try:
if(edit=='news'):
thing = NewsArticleNew.get(Key(key))
form_data={'title':thing.title,'author':thing.author,'date':unicode(thing.date),'body':thing.body,'picture':thing.picture}
elif(edit=='talk'):
thing = TalkNew.get(Key(key))
form_data={'title':thing.title,'author':thing.author,'date':unicode(thing.date),'body':thing.body,'video':thing.video}
elif(edit=='hack'):
thing = Hack.get(Key(key))
form_data={'title':thing.title,'date':unicode(thing.date),'body':thing.body,'picture':thing.picture}
template_dict['form_data']=form_data
except BadKeyError:
template_dict['message'] = \
'Could not find %s with key %r.' % (self.thing_descriptors.get(edit), key)
template_dict['show_form'] = False
self.render_template('edit', template_dict)
开发者ID:Man-UP,项目名称:website,代码行数:25,代码来源:handlers.py
示例5: add_user
def add_user():
# dummy user and dummy member are created on first request.
# user is responsible for creating dummy events.
Event.create_table(fail_silently=True)
Member.create_table(fail_silently=True)
Minute.create_table(fail_silently=True)
Picture.create_table(fail_silently=True)
User.create_table(fail_silently=True)
#
# # create a dummy member
# try:
# member = Member(first_name="Bryan",
# last_name="Bennett",
# collegiate_chapter="Zeta Omicron "
# "(Georgia Southern University)",
# initiation_date=datetime.date(2006, 04, 06),
# office="Secretary, Warden",
# image_path="Bryan_Bennett.jpg")
# member.save()
# except IntegrityError as e:
# print e
#
# create a dummy user
try:
admin = User(username='bbenne10', email='[email protected]',
admin=True, active=True)
admin.set_password("password")
admin.save()
except IntegrityError as e:
print e
开发者ID:bbenne10,项目名称:atlsinfonia,代码行数:30,代码来源:routes.py
示例6: post
def post(self):
if len(self.request.POST) == 4 and 'handle' in self.request.POST \
and 'real_name' in self.request.POST \
and 'email' in self.request.POST \
and 'bio' in self.request.POST:
handle = self.request.POST.getall('handle')[0]
template_dict = {}
member = Member.get_current_member()
other = Member.gql('WHERE handle = :1', handle).get()
if (not handle or len(handle) > 12 or
any(l not in self.valid_letters for l in handle)):
template_dict['error'] = 'Pick something sensible, you moron.'
elif other and other.user_id != member.user_id:
template_dict['error'] = 'Sorry, already taken.'
elif handle.lower() in self.banned_names:
template_dict['error'] = self.banned_names[handle]
else:
real_name = self.request.POST.getall('real_name')[0]
if real_name:
member.real_name = real_name
email = self.request.POST.getall('email')[0]
if email:
member.email = email
bio = self.request.POST.getall('bio')[0]
if bio:
member.bio = bio
member.handle = handle
member.save()
template_dict['error'] = 'Profile updated'
self.render_template('account', template_dict)
开发者ID:Man-UP,项目名称:website,代码行数:35,代码来源:handlers.py
示例7: get
def get(self, member_id=""):
if member_id:
self.member_allowd(member_id)
members = Member.get_by_id(member_id)
else:
members = Member.get_by_uid(self.current_user)
result = {"data": members}
self.finish(result)
开发者ID:cnspica,项目名称:Joyaay,代码行数:8,代码来源:member.py
示例8: on_add_clicked
def on_add_clicked(self, *args):
number = self.ui.number.get_text()
name = self.ui.name.get_text()
member = Member()
member.number = number
member.name = name
self.add(member)
self.ui.list_store.append((member, number, name,))
开发者ID:eugeneai,项目名称:ZCA,代码行数:8,代码来源:vc.py
示例9: create_callback
def create_callback(sender, *args, **kwargs):
user = kwargs['user']
member = Member()
member.user = user
member.save()
#now we want to create a goal for this member,
#so they have something and get goals
goal = Goal(goal_name="Create more goals!",num_per_frame=1,time_frame_len='d')
goal.member = member
goal.save()
开发者ID:jackschultz,项目名称:streakflow,代码行数:10,代码来源:signals.py
示例10: create
def create(self):
"""Creates and returns a new member"""
member = MemberModel()
name = input("Name: ")
personal_number = self._read_personal_number("Pesonal Number:")
member.name = name
member.personal_number = personal_number
self.display(member)
if not self._read_binary("Is this correct?"):
self.edit(member)
return member
开发者ID:rk222ev,项目名称:1dv607_Member_registry,代码行数:11,代码来源:member.py
示例11: member
def member(request):
response = {}
if request.method == "POST":
user = request.data["userId"]
password = request.data["password"]
if user is None or password is None:
response["STS"] = ERR_USER_PARAM
response["MSG"] = MSG[ERR_USER_PARAM]
return Response(response)
member = Member(user=user, password=password)
member.save()
response["STS"] = SUCCESS
response["MSG"] = MSG[SUCCESS]
response["DAT"] = member.id
return Response(response)
if request.method == "GET":
user = request.query_params["userId"]
password = request.query_params["password"]
if user is None or password is None:
response["STS"] = ERR_USER_PARAM
response["MSG"] = MSG[ERR_USER_PARAM]
return Response(response)
member = Member.objects.filter(user=user, password=password)
if not member:
response["STS"] = ERR_DB_SELECT
response["MSG"] = "Login Fail. Check user id and password"
else:
resData = {}
resData["id"] = member[0].id
resData["user"] = member[0].user
request.session["login"] = True
request.session["member_id"] = member[0].id
request.session["member_user"] = member[0].user
response["STS"] = SUCCESS
response["MSG"] = MSG[SUCCESS]
response["DAT"] = resData
return Response(response)
开发者ID:ElvinKim,项目名称:django-angular-board-project,代码行数:51,代码来源:api.py
示例12: get_current_user
def get_current_user(self):
mid = self.session.get("mid")
logined = self.session.get("logined")
if mid and logined:
member = Member.getObjectByObjectId(mid)
return member
else:
member_cookie = self.get_secure_cookie(self.settings["cookie_name"])
if member_cookie:
member_json = self.parseJson(member_cookie)
if member_json.get("mid") and member_json.get("logined"):
member = Member.getObjectByObjectId(mid)
return member
return None
开发者ID:ergatea,项目名称:gitpub2,代码行数:14,代码来源:base.py
示例13: testLimitOffset
def testLimitOffset(self):
team = Team.create(name="Houkago Tea Time")
for name in self.names:
team.members.append(first_name=name[0], last_name=name[1], part=name[2], age=name[3])
# OFFSET 2
qs = Member.all().offset(2).order_by("id")
self.assertEqual(qs[0].first_name, "Yui")
self.assertEqual(qs[1].first_name, "Tsumugi")
self.assertEqual(qs.count(), 3)
# LIMIT 1 OFFSET 2
qs = Member.all().offset(2).limit(1).order_by("id")
self.assertEqual(qs[0].first_name, "Yui")
self.assertEqual(qs.count(), 1)
开发者ID:FrViPofm,项目名称:macaron,代码行数:15,代码来源:test_query.py
示例14: create_mention
def create_mention(**kwargs):
receiver = Member.getMemberByUsername(kwargs['username'])
if receiver:
kwargs.update(receiver=receiver)
reminder = Reminder.create(**kwargs)
else:
logging.error("no member found")
开发者ID:ergatea,项目名称:gitpub2,代码行数:7,代码来源:reminder.py
示例15: book_issue
def book_issue(self, member_number, book_barcode):
member = Member()
member.number = member_number
memberdboperation = getAdapter(member, IDbOperation)
member = memberdboperation.get()[0]
book = Book()
book.number = book_barcode
bookdboperation = getAdapter(book, IDbOperation)
book = bookdboperation.get()[0]
circulation = Circulation()
circulation.member = member
circulation.book = book
circulationdboperation = getAdapter(circulation, IDbOperation)
circulationdboperation.add()
开发者ID:eugeneai,项目名称:ZCA,代码行数:16,代码来源:vc.py
示例16: add_members_to_db
def add_members_to_db(fin=members_json):
from PyQt4 import QtCore
from models import Member
from assets.validators import valid_email, valid_phone
with open(fin, 'r') as members_file:
data = members_file.read()
data = json.loads(data)
sheets = data.keys()
for s in sheets:
print s
for member in data[s]:
if len(member) != 5:
print 'invalid member'
return
mob = member[0]
mob = mob if valid_phone(mob) else None
email = member[1]
email = email if valid_email(email) else None
grade = member[2]
name = member[3]
num = member[4]
if name and num.isdigit():
m = Member.add(name=name, mob=mob, email=email, note=grade)
if type(m) in [str, QtCore.QString]:
print m, name, num
开发者ID:elshobaky,项目名称:MeX-LMS,代码行数:25,代码来源:excel_import.py
示例17: render_template
def render_template(self, template_name, template_dict=None):
tag_line = 'Next meeting coming soon'
if template_dict is None:
template_dict = {}
user = Member.get_current_member()
if user:
if self.login_required:
redirect_target = '/'
else:
redirect_target = self.request.path
url_creator = users.create_logout_url
else:
redirect_target = '/login?url=%s' % self.request.path
url_creator = users.create_login_url
defaults = {
'user': user,
'is_admin': users.is_current_user_admin(),
'log_url': url_creator(redirect_target),
'tag_line': tag_line,
'title': self.title
}
for key in defaults:
if key not in template_dict:
template_dict[key] = defaults[key]
template_path = get_path(
os.path.join('templates', '%s.html' % template_name)
)
self.response.out.write(template.render(template_path, template_dict))
开发者ID:eldog,项目名称:man-up-website,代码行数:34,代码来源:handlers.py
示例18: put
def put(self, member_id):
self.member_allowd(member_id)
nickname = utf8(self.get_argument("nickname", ""))
if nickname:
birthday = self.get_argument("birthday", '2010-01-01')
sex = self.get_argument("sex", 'M')
if self.request.files and 'gravatar' in self.request.files:
file_metas = self.request.files['gravatar'][0]
filename = "%s.jpg" % rand_name(file_metas['filename'])
save(filename, file_metas['body'])
filename = "http://dstore-dstor.stor.sinaapp.com/%s" % filename
else:
filename = ''
Member.modify(member_id, nickname, birthday, sex, filename)
self.finish()
else:
raise HTTPAPIError(400)
开发者ID:cnspica,项目名称:Joyaay,代码行数:17,代码来源:member.py
示例19: get
def get(self):
if not check_authentication(self):
return
# Get all users from the given semester
selected_semester = self.request.get('semester')
if selected_semester:
members = Member.query(Member.show == True, Member.semesters_paid == selected_semester).order(Member.name).fetch(limit=None)
else:
members = Member.query(Member.show == True, Member.never_paid == False).order(Member.name).fetch(limit=None)
output = []
for member in members:
output.append(format_member(member))
self.response.headers['Content-Type'] = 'application/json'
self.response.write(json.dumps(output))
开发者ID:zmyaro,项目名称:star-site,代码行数:18,代码来源:api.py
示例20: add
def add(cls, jid, nick = None, show = None):
""" 添加一个成员
Arguments:
`jid` - 成员jid
`nick` - 昵称
`show` - stanze.show
"""
if cls.get_one(jid):
return
m = Member(jid, nick)
m.status = [Status(show, jid.resource)]
try:
session.add(m)
session.commit()
except:
session.rollback()
return m
开发者ID:Jack1007,项目名称:clubot,代码行数:18,代码来源:logics.py
注:本文中的models.Member类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论