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


Python Notification.deleted方法代码示例

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


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

示例1: project

# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import deleted [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.deleted方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。