本文整理汇总了Python中members.models.Member.delegate方法的典型用法代码示例。如果您正苦于以下问题:Python Member.delegate方法的具体用法?Python Member.delegate怎么用?Python Member.delegate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类members.models.Member
的用法示例。
在下文中一共展示了Member.delegate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: done
# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import delegate [as 别名]
def done(self, fl, form_dict, **kwargs):
self.request.breadcrumbs( (
('registration','/reg/'),
) )
done_title = settings.TEMPLATE_CONTENT['reg']['register']['done']['title']
done_template = settings.TEMPLATE_CONTENT['reg']['register']['done']['template']
error_template = settings.TEMPLATE_CONTENT['reg']['register']['done']['error_template']
email_template = settings.TEMPLATE_CONTENT['reg']['register']['done']['email_template']
m_id = gen_member_id()
M = lvl = O = A = U = D = Gs = None
Us = []
ty = None
if self.kwargs:
for item in Member.MEMBER_TYPES:
if unicode(item[1]) == unicode(self.kwargs['type']):
ty = int(item[0])
else:
t_f = form_dict['type']
ty = int(t_f.cleaned_data['member_type'])
a_f = form_dict['address']
h_f = form_dict['head']
if a_f.is_valid() and h_f.is_valid():
A = a_f.save()
U = h_f.save()
#role for hol
Ro = Role(title="Head of List",user=U)
Ro.save()
#organisation
if ty == Member.ORG:
var = a_f.cleaned_data
o = a_f.cleaned_data['organisation']
O = Organisation(name=o,address=A)
O.save()
#get nb of users
lvl = int(h_f.cleaned_data['more'])+1 #add one for head-of-list
# delegate
delegate = h_f.cleaned_data['delegate']
if delegate:
d_f = form_dict['delegate']
if d_f.is_valid():
D = d_f.save()
D.save()
#role for delegate
Ro = Role(title="Delegate",user=D)
Ro.save()
#all users for ORG type
mu_fs = form_dict['more']
if mu_fs.is_valid():
for u in mu_fs:
if u.is_valid() and u.has_changed():
if u.cleaned_data['email']:
user = u.save(commit=False)
user.username = gen_username(user.first_name,user.last_name)
user.is_active = False
user.password = make_password(gen_random_password())
user.save()
Us.append(user)
#student
if ty == Member.STD:
sp_f = form_dict['student_proof']
if sp_f.is_valid():
M = sp_f.save(commit=False)
M.pk=m_id
M.type=ty
if M == None: M = Member(pk=m_id,type=ty)
# if of type org, add organisation to Member model
if ty == Member.ORG: M.organisation = O
# add address and head_of_list to Member model
M.address=A
M.head_of_list=U
#set the level (number of users) for ORG type
if lvl: M.lvl=lvl
# add delegate if exists
if D != None: M.delegate=D
# add member_type if in alt mode
M.type = ty
# save Member model
M.save()
# add all Users for ORG type
if Us != []: M.users=Us
reg_hash_code = gen_hash(settings.REG_SALT,M.head_of_list.email,15,M.address)
#.........这里部分代码省略.........