本文整理汇总了Python中members.models.Member.get_local_member方法的典型用法代码示例。如果您正苦于以下问题:Python Member.get_local_member方法的具体用法?Python Member.get_local_member怎么用?Python Member.get_local_member使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类members.models.Member
的用法示例。
在下文中一共展示了Member.get_local_member方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: desktop_verify_parking_permit
# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import get_local_member [as 别名]
def desktop_verify_parking_permit(request):
if request.method == "POST":
owner = request.user
try:
# Process the email address the owner provided.
owner_email = request.session.get("owner_email")
if owner.email == "":
owner.email == owner_email
owner.save()
elif owner.email != owner_email:
pass
# TODO: Save as an alternate email (member app) and log as a WARNING or INFO?
# Create the parking permit in the database
perm = ParkingPermit.objects.create(
owner=request.user.member,
short_desc=request.session.get("short_desc"),
ok_to_move=request.session.get("ok_to_move"),
approving_member=Member.get_local_member(request.session.get("approving_member_username")),
)
_clear_session(request)
return HttpResponse("SUCCESS " + str(perm.pk))
except Exception as e:
return HttpResponse("ERROR " + str(e))
else: # For GET and any other methods:
return render(request, "inventory/desktop-parking-permit-verify.html")
示例2: member_tags
# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import get_local_member [as 别名]
def member_tags(request, tag_pk=None, member_pk=None, op=None):
staff = request.user.member
member = None if member_pk is None else Member.objects.get(pk=member_pk)
if member is not None and tag_pk is not None and op is not None:
tag = Tag.objects.get(pk=tag_pk)
if op == "+": Tagging.add_if_permitted(staff, member, tag)
if op == "-": Tagging.remove_if_permitted(staff, member, tag)
staff_can_tags = None
staff_addable_tags = None
members_tags = None
if request.method == 'POST': # Process the form data.
form = Desktop_ChooseUserForm(request.POST)
if form.is_valid():
member_id = form.cleaned_data["userid"]
member = Member.get_local_member(member_id)
else:
# We get here if the userid field was blank.
member = None
else: # If a GET (or any other method) we'll create a blank form.
username = None if member is None else member.username
form = Desktop_ChooseUserForm(initial={'userid': username})
if member is not None:
members_tags = member.tags.all()
staff_can_tags = [tagging.tag for tagging in Tagging.objects.filter(can_tag=True, tagged_member=staff)]
staff_addable_tags = list(staff_can_tags) # copy contents, not pointer.
# staff member can't add tags that member already has, so:
for tag in member.tags.all():
if tag in staff_addable_tags:
staff_addable_tags.remove(tag)
today = date.today()
visits = VisitEvent.objects.filter(when__gt=today)
visitors = [visit.who for visit in visits]
return render(request, 'members/desktop-member-tags.html', {
'form': form,
'staff': staff,
'member': member,
'members_tags': members_tags,
'staff_can_tags': staff_can_tags,
'staff_addable_tags': staff_addable_tags,
'visitors': set(visitors),
})