本文整理汇总了Python中models.Notification.request方法的典型用法代码示例。如果您正苦于以下问题:Python Notification.request方法的具体用法?Python Notification.request怎么用?Python Notification.request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Notification
的用法示例。
在下文中一共展示了Notification.request方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: project
# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import request [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")