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


Python Member.member_until方法代码示例

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


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

示例1: ActivitySignup

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import member_until [as 别名]
def ActivitySignup(request, activity_id, unique=None, person_id=None):
    if(unique is None or person_id is None):
        # View only mode
        view_only_mode = True
    else:
        view_only_mode = False

    activity = get_object_or_404(Activity, pk=activity_id)

    participants = ActivityParticipant.objects.filter(activity=activity).order_by('member__person__name')
    participating = False

    if(request.resolver_match.url_name == 'activity_view_person'):
        view_only_mode = True

    if unique:
        family = get_object_or_404(Family, unique=unique)
    else:
        family = None

    if person_id:
        try:
            person = family.person_set.get(pk=person_id)

            # Check not already signed up
            try:
                participant = ActivityParticipant.objects.get(activity=activity, member__person=person)
                # found - we can only allow one - switch to view mode
                participating = True
                view_only_mode = True
            except ActivityParticipant.DoesNotExist:
                participating = False # this was expected - if not signed up yet

        except Person.DoesNotExist:
            raise Http404('Person not found on family')
    else:
        person = None

    if(not activity.open_invite):
        ''' Make sure valid not expired invitation to event exists '''
        try:
            invitation = ActivityInvite.objects.get(activity=activity, person=person, expire_dtm__gte=timezone.now())
        except ActivityInvite.DoesNotExist:
            view_only_mode = True # not invited - switch to view mode
            invitation = None
    else:
        invitation = None

    # if activity is closed for signup, only invited persons can still join
    if activity.signup_closing < timezone.now().date() and invitation==None:
        view_only_mode = True # Activivty closed for signup

    # check if activity is full
    if activity.seats_left() <= 0:
        view_only_mode = True # activity full

    if(request.method == "POST"):
        if view_only_mode:
            return HttpResponse('Du kan ikke tilmelde dette event nu. (ikke inviteret / tilmelding lukket / du er allerede tilmeldt eller aktiviteten er fuldt booket)')

        if activity.max_age < person.age_years() or activity.min_age > person.age_years():
            return HttpResponse('Barnet skal være mellem ' + str(activity.min_age) + ' og ' + str(activity.max_age) + ' år gammel for at deltage. (Er fødselsdatoen udfyldt korrekt ?)')

        if Person.objects.filter(family=family).exclude(membertype=Person.CHILD).count() <=0:
            return HttpResponse('Barnet skal have en forælder eller værge. Gå tilbage og tilføj en før du tilmelder.')

        signup_form = ActivitySignupForm(request.POST)

        if signup_form.is_valid():
            # Sign up and redirect to payment link or family page

            # Calculate membership
            membership_start = timezone.datetime(year=activity.start_date.year, month=1, day=1)
            membership_end = timezone.datetime(year=activity.start_date.year, month=12, day=31)
            # check if person is member, otherwise make a member
            try:
                member = Member.objects.get(person=person)
            except Member.DoesNotExist:
                member = Member(
                    department = activity.department,
                    person=person,
                    member_since=membership_start,
                    member_until=membership_end,
                    )
                member.save()

            # update membership end date
            member.member_until=membership_end
            member.save()

            # Make ActivityParticipant
            participant = ActivityParticipant(member=member, activity=activity, note=signup_form.cleaned_data['note'])

            # update photo permission and contact open info
            participant.photo_permission = True # signup_form.cleaned_data['photo_permission']
            participant.contact_visible = signup_form.cleaned_data['address_permission'] == "YES"
            participant.save()

            return_link_url = reverse('activity_view_person', args=[family.unique, activity.id, person.id])

#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:


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