本文整理汇总了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'))
示例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")
示例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")