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


Python Member.get_for_staff方法代码示例

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


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

示例1: api_member_details

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import get_for_staff [as 别名]
def api_member_details(request, member_card_str, staff_card_str):
    """ Respond with corresponding user/member info given the membership card string in the QR code. """

    success, info = Member.get_for_staff(member_card_str, staff_card_str)

    if not success:
        error_msg = info
        return JsonResponse({'error': error_msg})

    member, _ = info  # type: Tuple[Member, Member]
    data = {
        'pk': member.pk,
        'is_active': member.is_active,
        'username': member.username,
        'first_name': member.first_name,
        'last_name': member.last_name,
        'email': member.email,
        'tags': [tag.name for tag in member.tags.all()]
    }
    return JsonResponse(data)
开发者ID:adrianboyko,项目名称:xerocraft-django,代码行数:22,代码来源:views.py

示例2: kiosk_add_tag

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import get_for_staff [as 别名]
def kiosk_add_tag(request, member_card_str, staff_card_str, tag_pk):
    # We only get to this view from a link produced by a previous view.
    # This view assumes that the previous view is passing valid strs and pk.
    # Any exceptions raised in this view can be considered programming errors and are not caught.
    # This view DOES NOT use member PKs even though the previous view could provide them.
    # Using PKs would make this view vulnerable to brute force attacks to create unauthorized taggings.

    success, info = Member.get_for_staff(member_card_str, staff_card_str)

    if not success:
        error_msg = info
        return HttpResponse("Error: %s." % error_msg) #TODO: Use kiosk-domain-error template?

    tag = Tag.objects.get(pk=tag_pk)

    member, staff = info

    # The following can be considered an assertion that the given staff member is authorized to grant the given tag.
    Tagging.objects.get(can_tag=True, tagged_member=staff, tag=tag)

    # Create the new tagging and then go back to the member details view.
    Tagging.objects.create(tagged_member=member, authorizing_member=staff, tag=tag)
    return redirect('..')
开发者ID:adrianboyko,项目名称:xerocraft-django,代码行数:25,代码来源:views.py

示例3: kiosk_member_details

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import get_for_staff [as 别名]
def kiosk_member_details(request, member_card_str, staff_card_str):

    success, info = Member.get_for_staff(member_card_str, staff_card_str)

    if not success:
        return render(request, 'members/kiosk-invalid-card.html', {}) #TODO: use kiosk-domain-error template?

    member, staff = info  # type: Tuple[Member, Member]
    staff_can_tags = [ting.tag for ting in Tagging.objects.filter(can_tag=True, tagged_member=staff)]
    # staff member can't add tags that member already has, so:
    for tag in member.tags.all():
        if tag in staff_can_tags:
            staff_can_tags.remove(tag)

    return render(request, 'members/kiosk-member-details.html', {
        "staff_card_str" : staff_card_str,
        "staff_fname" : staff.first_name,
        "memb_fname" : member.first_name,
        "memb_name" : "%s %s" % (member.first_name, member.last_name),
        "username" : member.username,
        "email" : member.email,
        "members_tags" : member.tags.all(),
        "staff_can_tags" : staff_can_tags,
    })
开发者ID:adrianboyko,项目名称:xerocraft-django,代码行数:26,代码来源:views.py


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