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


Python Member.generate_auth_token_str方法代码示例

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


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

示例1: verify_default_claims

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import generate_auth_token_str [as 别名]
    def verify_default_claims(HOST):

        today = datetime.date.today()
        claims = Claim.objects.filter(
            status=Claim.STAT_CURRENT,
            claimed_task__scheduled_date__range=[today+THREEDAYS, today+FOURDAYS],
            # REVIEW: Is the following 'claiming_member' restriction actually required?
            claiming_member=F('claimed_task__recurring_task_template__default_claimant'),
            date_verified__isnull=True)

        if len(claims) == 0:
            # No default claims to process.
            return

        text_content_template = get_template('tasks/email-verify-claim.txt')
        html_content_template = get_template('tasks/email-verify-claim.html')

        for claim in claims:
            b64, md5 = Member.generate_auth_token_str(
                lambda token: Nag.objects.filter(auth_token_md5=token).count() == 0)  # uniqueness test

            nag = Nag.objects.create(who=claim.claiming_member, auth_token_md5=md5)
            nag.claims.add(claim)
            nag.tasks.add(claim.claimed_task)

            dow = claim.claimed_task.scheduled_weekday()

            d = {
                'claimant': claim.claiming_member,
                'claim': claim,
                'task': claim.claimed_task,
                'dow': dow,
                'auth_token': b64,
                'host': HOST,
            }

            # Send email messages:
            subject = 'Please verify your availability for this {}'.format(dow)
            from_email = EMAIL_VOLUNTEER
            bcc_email = EMAIL_ARCHIVE
            to = claim.claiming_member.email
            text_content = text_content_template.render(d)
            html_content = html_content_template.render(d)
            msg = EmailMultiAlternatives(subject, text_content, from_email, [to], [bcc_email])
            msg.attach_alternative(html_content, "text/html")
            msg.send()
开发者ID:adrianboyko,项目名称:xerocraft-django,代码行数:48,代码来源:nag.py

示例2: verify_default_claims

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import generate_auth_token_str [as 别名]
    def verify_default_claims(HOST):

        text_content_template = get_template('tasks/email-verify-claim.txt')
        html_content_template = get_template('tasks/email-verify-claim.html')

        today = datetime.date.today()
        for claim in Claim.objects.filter(
          status = Claim.STAT_CURRENT,
          claimed_task__scheduled_date__range=[today+THREEDAYS, today+FOURDAYS],
          claiming_member=F('claimed_task__recurring_task_template__default_claimant'),
          date_verified__isnull=True):
            b64, md5 = Member.generate_auth_token_str(
                lambda token: Nag.objects.filter(auth_token_md5=token).count() == 0)  # uniqueness test

            nag = Nag.objects.create(who=claim.claiming_member, auth_token_md5=md5)
            nag.claims.add(claim)
            nag.tasks.add(claim.claimed_task)

            dow = claim.claimed_task.scheduled_weekday()

            d = Context({
                'claimant': claim.claiming_member,
                'claim': claim,
                'task': claim.claimed_task,
                'dow': dow,
                'auth_token': b64,
                'host': HOST,
            })

            # Send email messages:
            subject = 'Please verify your availability for this {}'.format(dow)
            from_email = VC_EMAIL
            bcc_email = XIS_EMAIL
            to = claim.claiming_member.email
            text_content = text_content_template.render(d)
            html_content = html_content_template.render(d)
            msg = EmailMultiAlternatives(subject, text_content, from_email, [to], [bcc_email])
            msg.attach_alternative(html_content, "text/html")
            msg.send()
开发者ID:SRCprogramming,项目名称:cirqueroots-django,代码行数:41,代码来源:nag.py

示例3: nag_for_workers

# 需要导入模块: from members.models import Member [as 别名]
# 或者: from members.models.Member import generate_auth_token_str [as 别名]
    def nag_for_workers(HOST):
        today = datetime.date.today()

        # Find out who's doing what over the next 2 weeks. Who's already scheduled to work and who's heavily scheduled?
        ppl_already_scheduled = Claim.sum_in_period(today, today+TWOWEEKS)
        ppl_heavily_scheduled = set([member for member, dur in ppl_already_scheduled.items() if dur >= datetime.timedelta(hours=6.0)])

        # Rule out the following sets:
        ppl_excluded = set()
        ppl_excluded |= set([worker.member for worker in Worker.objects.filter(should_nag=False)])
        ppl_excluded |= set(Member.objects.filter(auth_user__email=""))
        ppl_excluded |= set(Member.objects.filter(auth_user__is_active=False))

        # Cycle through future days' NAGGING tasks to see which need workers and who should be nagged.
        nag_lists = {}
        emergency_tasks = []
        for task in Task.objects.filter(scheduled_date__gte=today, scheduled_date__lt=today+THREEDAYS, should_nag=True):

            # No need to nag if task is fully claimed or not workable.
            if (not task.is_active()) or task.is_fully_claimed():
                continue

            potentials = task.all_eligible_claimants()
            potentials -= task.claimant_set(Claim.STAT_CURRENT)
            potentials -= task.claimant_set(Claim.STAT_UNINTERESTED)
            # potentials -= task.claimant_set(Claim.STAT_EXPIRED) Their claim expired but they're still a possibility.
            potentials -= task.claimant_set(Claim.STAT_ABANDONED)
            potentials -= ppl_excluded

            panic_situation = task.scheduled_date == today and task.priority == Task.PRIO_HIGH
            if panic_situation:
                emergency_tasks.append(task)
            else:
                # Don't bother heavily scheduled people if it's not time to panic
                potentials -= ppl_heavily_scheduled

            for member in potentials:
                if member not in nag_lists:
                    nag_lists[member] = []
                nag_lists[member] += [task]

        # Send staffing emergency message to staff list:
        if len(emergency_tasks) > 0:
            Command.send_staffing_emergency_message(emergency_tasks, HOST)

        # Send email nag messages to potential workers:
        text_content_template = get_template('tasks/email_nag_template.txt')
        html_content_template = get_template('tasks/email_nag_template.html')
        for member, tasks in nag_lists.items():

            b64, md5 = Member.generate_auth_token_str(
                lambda token: Nag.objects.filter(auth_token_md5=token).count() == 0  # uniqueness test
            )

            nag = Nag.objects.create(who=member, auth_token_md5=md5)
            nag.tasks.add(*tasks)

            d = {
                'token': b64,
                'member': member,
                'tasks': tasks,
                'host': HOST,
            }
            subject = 'Call for Volunteers, ' + datetime.date.today().strftime('%a %b %d')
            from_email = EMAIL_VOLUNTEER
            bcc_email = EMAIL_ARCHIVE
            to = member.email
            text_content = text_content_template.render(d)
            html_content = html_content_template.render(d)
            msg = EmailMultiAlternatives(subject, text_content, from_email, [to], [bcc_email])
            msg.attach_alternative(html_content, "text/html")
            msg.send()
开发者ID:adrianboyko,项目名称:xerocraft-django,代码行数:74,代码来源:nag.py


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