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


Python Member.user方法代码示例

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


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

示例1: create_callback

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import user [as 别名]
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,代码行数:12,代码来源:signals.py

示例2: home

# 需要导入模块: from models import Member [as 别名]
# 或者: from models.Member import user [as 别名]
def home(request):
	try:
		member = Member.objects.get(user=request.user)
		registration_complete = True

		# We have a batch job that expires members, but do it here as well to make sure
		# the web is up to date with information if necessary.
		if member.paiduntil and member.paiduntil < date.today():
			MemberLog(member=member,
					  timestamp=datetime.now(),
					  message="Membership expired").save()
			member.membersince = None
			member.paiduntil = None
			member.save()

	except Member.DoesNotExist:
		# No record yet, so we create one. Base the information on whatever we
		# have already.
		member = Member(user=request.user, fullname=request.user.first_name)
		registration_complete = False

	if request.method == "POST":
		form = MemberForm(data=request.POST, instance=member)
		if form.is_valid():
			member = form.save(commit=False)
			member.user = request.user
			member.save()
			if not registration_complete:
				MemberLog(member=member,
						  timestamp=datetime.now(),
						  message="Registration received, awaiting payment").save()
				registration_complete = True # So we show the payment info!
			elif form.has_changed():
				# Figure out what changed
				MemberLog(member=member,
						  timestamp=datetime.now(),
						  message="Modified registration data for field(s): %s" % (", ".join(form._changed_data)),
						  ).save()
			if request.POST["submit"] == "Generate invoice":
				# Generate an invoice for the user
				if member.activeinvoice:
					raise Exception("This should not happen - generating invoice when one already exists!")
				manager = InvoiceManager()
				processor = InvoiceProcessor.objects.get(processorname="membership processor")
				invoicerows = [('PostgreSQL Europe - 2 years membership - %s' % request.user.email, 1, 10),]
				member.activeinvoice = manager.create_invoice(
					request.user,
					request.user.email,
					request.user.first_name + ' ' + request.user.last_name,
					'', # We don't have an address
					'PostgreSQL Europe membership for %s'% request.user.email,
					datetime.now(),
					datetime.now(),
					invoicerows,
					processor = processor,
					processorid = member.pk,
					bankinfo = False,
					accounting_account = settings.ACCOUNTING_MEMBERSHIP_ACCOUNT
					)
				member.activeinvoice.save()
				member.save()

				# We'll redirect back to the same page, so make sure
				# someone doing say a hard refresh on the page doesn't
				# cause weird things to happen.
				return HttpResponseRedirect('/membership/')
	else:
		form = MemberForm(instance=member)

	logdata = MemberLog.objects.filter(member=member).order_by('-timestamp')[:30]

	return render_to_response('membership/index.html', {
		'form': form,
		'member': member,
		'invoice': InvoicePresentationWrapper(member.activeinvoice, "%s/membership/" % settings.SITEBASE_SSL),
		'registration_complete': registration_complete,
		'logdata': logdata,
		'amount': 10, # price for two years
	}, context_instance=RequestContext(request))
开发者ID:louiseGrandjonc,项目名称:pgeu-website,代码行数:81,代码来源:views.py


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