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


Python Notification.content方法代码示例

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


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

示例1: send_notification

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import content [as 别名]
def send_notification():
	form = SendNotificationForm()
	if form.validate_on_submit():
		noti = Notification()
		noti.content = form.notification.data
		db.session.add(noti)
		db.session.commit()

	return redirect(url_for('notify.send_notification'))
开发者ID:berc-web,项目名称:berc_web,代码行数:11,代码来源:__init__.py

示例2: profile

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import content [as 别名]
def profile(request):
	basic = get_basic(request)
	try:
		profile = Profile.objects.get(user=request.GET['id'])
		edit = None
		invitables = None
		if request.method == 'POST' and request.POST['invite']:
			try:
				obj = Membership.objects.filter(
						project_id=request.POST['invite']
					).get(
						user_id=request.GET['id']
					)
			except Membership.DoesNotExist:
				obj = Membership(project_id=request.POST['invite'],
					user_id=request.GET['id'])
			obj.approved_by_proj=True
			note = Notification(
				user=obj.user, subject=obj.project.user, 
				project=obj.project)
			if obj.approved_by_user:
				note.content = "accepted your request to join the project"
			else:
				note.content = "invited you to join the project"
			obj.save()
			send_note(note)
		if request.user.id == profile.id:
			edit = 'edit'
		elif basic:
			committed = Membership.objects.filter(
				user=profile.user.id).filter(
				approved_by_proj=True).select_related('project')
			invitables = Project.objects.filter(
				user=request.user.id).exclude(
				id__in=committed.values_list('project', flat=True))
		memberships = get_memberships(profile.user)
		ac = are_colleagues(request.user, profile.user)
		return render(request, 'profile.html', {'profile': profile, 'basic': basic,
			'edit': edit, 'memberships': memberships, 'invitables': invitables,
			'are_colleagues': ac})
	except Profile.DoesNotExist:
		return HttpResponseRedirect("/profiles")
开发者ID:nmasur,项目名称:creationdex,代码行数:44,代码来源:views.py

示例3: project

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import content [as 别名]
def project(request):
	basic = get_basic(request)
	try:
		project = Project.objects.get(id=request.GET['id'])
		member_status = None
		if basic:
			try:
				memberships = Membership.objects.filter(user_id=request.user.id)
				membership = memberships.get(project_id=project.id)
			except Membership.DoesNotExist:
				membership = Membership(user=request.user, project=project)
			if request.user.id == project.user.id:
				member_status = 'admin'
			elif membership.is_staff:
				member_status = 'staff'
			elif membership.approved_by_user and not membership.approved_by_proj:
				member_status = 'requested'
			elif membership.approved_by_proj and not membership.approved_by_user:
				member_status = 'invited'
			elif membership.approved_by_user and membership.approved_by_proj:
				member_status = 'member'
			if request.method == 'POST':
				note = Notification(user=project.user, subject=membership.user,
					project=project)
				if request.POST.get('makepost'):
					return HttpResponseRedirect(
						"/makepost?id=" + str(project.id))
				elif request.POST.get('manageproject'):
					return HttpResponseRedirect(
						"/manageproject?id=" + str(project.id))
				elif request.POST.get('join'):
					membership.approved_by_user = True
					if membership.approved_by_proj == True:
						note.content = "accepted your invitation to join"
						member_status = 'member'
					else:
						note.content = "requested to join your project"
						note.request = True
						member_status = 'requested'
				elif request.POST.get('withdraw'):
					membership.approved_by_user = False
					note.deleted = True
					member_status = None
				elif request.POST.get('leave'):
					membership.approved_by_user = False
					membership.approved_by_proj = False
					membership.is_staff = False
					note.content = "left your project"
					member_status = None
				elif request.POST.get('quit'):
					membership.is_staff = False
					note.content = "is no longer a staff member of"
					if membership.approved_by_proj and membership.approved_by_user:
						member_status = 'member'
					else:
						member_status = None
				membership.save()
				send_note(note)
		memberships = Membership.objects.filter(project_id=project.id)
		members = memberships.filter(approved_by_user=True).filter(approved_by_proj=True)
		staff = members.filter(is_staff=True)
		participants = members.filter(is_staff=False)
		posts = Post.objects.filter(
				project_id=project.id
			).filter(
				deleted=False
			).order_by(
				'-posted'
			)
		if not basic:
			posts = posts.filter(public=True)
		posts = posts[:7]
		return render(request, 'project.html', {'project': project, 'basic': basic, 
			'member_status': member_status, 'staff': staff, 'participants': participants,
			'posts': posts, 'is_member': is_member(request.user, project)})
	except ObjectDoesNotExist:
		return HttpResponseRedirect("/projects")
开发者ID:nmasur,项目名称:creationdex,代码行数:79,代码来源:views.py


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