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


Python Profile.get_user_with_type方法代码示例

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


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

示例1: workshop_create

# 需要导入模块: from wye.profiles.models import Profile [as 别名]
# 或者: from wye.profiles.models.Profile import get_user_with_type [as 别名]
def workshop_create(request):
    template_name = 'workshops/workshop_create.html'
    context_dict = {}
    if not Organisation.list_user_organisations(request.user).exists():
        msg = """
                To request workshop you need to create organisaiton.\n\n
                Please use organisation tab above to create your organisation
            """
        return render(request, 'error.html', {'message': msg})
    if request.method == 'GET':
        form = WorkshopForm(user=request.user)
        context_dict['form'] = form
        return render(request, template_name, context_dict)
    form = WorkshopForm(user=request.user, data=request.POST)
    if not form.is_valid():
        context_dict['form'] = form
        context_dict['errors'] = form.errors
        return render(request, template_name, context_dict)
    workshop = form.save()
    domain = Site.objects.get_current().domain
    context = {
        'workshop': workshop,
        'date': workshop.expected_date,
        'workshop_url': domain + '/workshop/{}/'.format(workshop.id)
    }
    # Collage POC and admin email
    poc_admin_user = Profile.get_user_with_type(
        user_type=['Collage POC', 'admin']
    ).values_list('email', flat=True)

    org_user_emails = workshop.requester.user.filter(
        is_active=True).values_list('email', flat=True)
    # all presenter if any
    all_presenter_email = workshop.presenter.values_list(
        'email', flat=True)
    # List of tutor who have shown interest in that location
    region_interested_member = Profile.objects.filter(
        interested_locations=workshop.requester.location,
        usertype__slug='tutor'
    ).values_list('user__email', flat=True)
    all_email = []
    all_email.extend(org_user_emails)
    all_email.extend(all_presenter_email)
    all_email.extend(poc_admin_user)
    all_email.extend(region_interested_member)
    all_email = set(all_email)
    send_tweet(context)

    subject = '[PythonExpress] Workshop request status.'
    email_body = loader.get_template(
        'email_messages/workshop/create_workshop/message.html').render(context)
    text_body = loader.get_template(
        'email_messages/workshop/create_workshop/message.txt').render(context)
    send_email_to_list(
        subject,
        body=email_body,
        users_list=all_email,
        text_body=text_body)
    success_url = reverse_lazy('workshops:workshop_list')
    return HttpResponseRedirect(success_url)
开发者ID:pythonindia,项目名称:wye,代码行数:62,代码来源:views.py

示例2: workshop_create

# 需要导入模块: from wye.profiles.models import Profile [as 别名]
# 或者: from wye.profiles.models.Profile import get_user_with_type [as 别名]
def workshop_create(request):
    template_name = "workshops/workshop_create.html"
    context_dict = {}
    if not Organisation.list_user_organisations(request.user).exists():
        msg = """
                To request workshop you need to create organisaiton.\n\n
                Please use organisation tab above to create your organisation
            """
        return render(request, "error.html", {"message": msg})
    if request.method == "GET":
        form = WorkshopForm(user=request.user)
        context_dict["form"] = form
        return render(request, template_name, context_dict)
    form = WorkshopForm(user=request.user, data=request.POST)
    if not form.is_valid():
        context_dict["form"] = form
        context_dict["errors"] = form.errors
        return render(request, template_name, context_dict)
    workshop = form.save()
    domain = Site.objects.get_current().domain
    context = {
        "workshop": workshop,
        "date": workshop.expected_date,
        "workshop_url": domain + "/workshop/{}/".format(workshop.id),
    }
    # Collage POC and admin email
    poc_admin_user = Profile.get_user_with_type(user_type=["Collage POC", "admin"]).values_list("email", flat=True)

    org_user_emails = workshop.requester.user.filter(is_active=True).values_list("email", flat=True)
    # all presenter if any
    all_presenter_email = workshop.presenter.values_list("email", flat=True)
    # List of tutor who have shown interest in that location
    region_interested_member = Profile.objects.filter(
        interested_locations=workshop.requester.location, usertype__slug="tutor"
    ).values_list("user__email", flat=True)
    all_email = []
    all_email.extend(org_user_emails)
    all_email.extend(all_presenter_email)
    all_email.extend(poc_admin_user)
    all_email.extend(region_interested_member)
    all_email = set(all_email)
    send_tweet(context)

    subject = "[PythonExpress] Workshop request status."
    email_body = loader.get_template("email_messages/workshop/create_workshop/message.html").render(context)
    text_body = loader.get_template("email_messages/workshop/create_workshop/message.txt").render(context)
    send_email_to_list(subject, body=email_body, users_list=all_email, text_body=text_body)
    success_url = reverse_lazy("workshops:workshop_list")
    return HttpResponseRedirect(success_url)
开发者ID:shankisg,项目名称:wye,代码行数:51,代码来源:views.py

示例3: send_mail

# 需要导入模块: from wye.profiles.models import Profile [as 别名]
# 或者: from wye.profiles.models.Profile import get_user_with_type [as 别名]
    def send_mail(self, user, assigned):
        """Send email to presenter and org users."""

        workshop = self.object
        email_dir = 'workshops/email/assign_me/'
        last_presenter = user
        # Collage POC and admin email
        poc_admin_user = Profile.get_user_with_type(
            user_type=['Collage POC', 'admin']
        ).values_list('email', flat=True)
        # Org user email
        org_user_emails = workshop.requester.user.filter(
            is_active=True
        ).values_list('email', flat=True)
        # all presenter except current assigned presenter
        all_presenter_email = workshop.presenter.exclude(
            pk=last_presenter.pk
        ).values_list(
            'email', flat=True
        )
        context = {
            'presenter': True,
            'assigned': assigned,
            'date': workshop.expected_date,
            'presenter_name': last_presenter.username,
            'workshop_organization': workshop.requester,
            'workshop_url': self.request.build_absolute_uri(reverse(
                'workshops:workshop_detail', args=[workshop.pk]
            ))
        }
        # Send email to presenter
        send_mail([last_presenter.email], context, email_dir)
        # Send email to org users and other presenter(s).
        context['presenter'] = False
        all_email = []
        all_email.extend(org_user_emails)
        all_email.extend(all_presenter_email)
        all_email.extend(poc_admin_user)
        all_email = list(set(all_email))
        send_mail(all_email, context, email_dir)
开发者ID:ChillarAnand,项目名称:wye,代码行数:42,代码来源:views.py

示例4: send_mail_to_group

# 需要导入模块: from wye.profiles.models import Profile [as 别名]
# 或者: from wye.profiles.models.Profile import get_user_with_type [as 别名]
    def send_mail_to_group(self, context, exclude_emails=None):
        """
        Send email to org/group users.
        @param context: Is dict of data required by email template.
        @exclude_emails: Is list of email to be excluded from
        email update.
        """

        if exclude_emails is None:
            exclude_emails = []

        # Collage POC and admin email
        poc_admin_user = Profile.get_user_with_type(
            user_type=['Collage POC', 'admin']
        ).values_list('email', flat=True)
        # Org user email
        org_user_emails = self.object.requester.user.filter(
            is_active=True
        ).values_list('email', flat=True)
        # all presenter if any
        all_presenter_email = self.object.presenter.values_list(
            'email', flat=True
        )
        # List of tutor who have shown interest in that location
        region_interested_member = Profile.objects.filter(
            interested_locations=self.object.requester.location,
            usertype__slug='tutor'
        ).values_list('user__email', flat=True)

        all_email = []
        all_email.extend(org_user_emails)
        all_email.extend(all_presenter_email)
        all_email.extend(poc_admin_user)
        all_email.extend(region_interested_member)
        all_email = set(all_email)
        all_email = list(all_email.difference(exclude_emails))
        send_mail(all_email, context, self.email_dir)
开发者ID:pythonindia,项目名称:wye,代码行数:39,代码来源:mixins.py


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